Sawda and Alayna have received a remote-controlled toy robot as a gift from their beloved uncle, Mridul. They are happily playing with it together in a rectangular room with meters in length and meters in width, surrounded by walls in all directions. The walls are parallel to either the North-South line or the East-West line. We can imagine this room with 2D coordinates, where means the North-West corner and means the South-East corner. The robot has minimal length and width, you can assume it as a point on the floor. The remote-controlled robot can do the following actions any number of times (possibly zero) -
Rotate clockwise, or
Go forward exactly meters in the direction the robot is currently facing. But if the distance to the wall in that direction is strictly less than meters, it crashes and stops at the wall.
However, the robot cannot rotate while moving or move while rotating.
The robot is currently in position, facing north. They want to move the robot to the position. I don't know why. They are children. They do weird things. But they don't want to crash it too many times, because too many crashes can break the toy.
Determine the minimum number of crashes required to move the robot from to , or report if it is impossible.
The first line contains an integer denoting the number of test cases. Each test case is described by four line lines -
The first line of each test case contains two space-separated integers and denoting the length and the width of the room in meters respectively.
The second line of each test case contains an integer denoting the distance the robot moves in meters in each ‘‘go forward’’ action if it doesn't crash in the meantime.
The third line contains two space-separated integers and denoting the initial coordinates of the robot.
The fourth line contains two space-separated integers and denoting the coordinates of the expected destination.
For each test case, print an integer in a single line denoting the minimum number of crashes required to go from to , or print
-1 if it is impossible.
2 3 3 1 1 1 2 2 3 3 2 2 1 1 1
For the first test case, the robot can go .
For the second test case, the robot can go .
Here bold letters imply that the robot has encountered a crash.