+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
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 $X \times Y$ meters (respectively $X$ meters horizontally and $Y$ 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, $T_x$ and $T_y$, and he’s currently standing in coordinates $W_x, W_y$. 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.
# input
This problem has multiple test cases. The first line contains $T$, the number of test cases to solve.
Each of the following $T$ lines contains six integers: the horizontal and vertical lengths of Pizzalandia $X$ and $Y$ , the Pizzatrain’s horizontal and vertical coordinates $𝑇_x$ and $T_y$, and finally Amin’s horizontal and vertical coordinates $W_x$ and $W_y$.
$$1 \leq T \leq 1000$$
$$1 \leq X, Y \leq 10^9$$
$$0 \leq T_x \leq X$$
$$0 \leq T_y \leq Y$$
+ The train is guaranteed to be (and stay!) on the border
$$0 \leq W_x \lt X$$
$$0 \leq W_y \lt Y$$
# output
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.
# example
### sample input 1
```
1
7 6 4 6 3 4
```
### sample output 1
```
5
```
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.