این مسابقه در تاریخ پنج شنبه ۱۴ دی به صورت حضوری در سایت دانشکده برق و کامپیوتر دانشگاه تهران برگزار شد.
Amin grew tired of the cold and rainy winters in Tabriz. This year, he decided to spend his holidays in Italy, his home country, and to finally visit his favorite amusement park, Pizzalandia.
Pizzalandia, as seen from above, is a rectangle of meters (respectively meters horizontally and vertically). Its biggest attraction is without a doubt the Pizzatrain, which runs clockwise along the borders of the rectangle at a fixed speed of 1 meter per second.
Since Amin has already explored most of the park, he thinks it’s finally time for him to get on the train himself, which can be done simply by being on the border of the rectangle at the same second of the train.
He knows the current coordinates of the train, and , and he’s currently standing in coordinates . Inside the park, it’s only possible to move horizontally or vertically.
Amin wants to get on the train quickly, but having noticed that today the park is very crowded, he decided that he would simply choose a direction, move in that direction at a speed of 1 meter per second, and then just wait for the train to reach his location.
Help Filippo by figuring out the minimum time it will take him to board the train with this strategy.
This problem has multiple test cases. The first line contains , the number of test cases to solve.
Each of the following lines contains six integers: the horizontal and vertical lengths of Pizzalandia and , the Pizzatrain’s horizontal and vertical coordinates $𝑇_x$ and , and finally Amin’s horizontal and vertical coordinates and .
For each test case, you need to write a single line containing the minimum number of seconds it will take Amin to get on the train, by following his strategy of moving in only one direction.