## Two Tables solution codeforces

You have an axis-aligned rectangle room with width WW and height HH, so the lower left corner is in point (0,0)(0,0) and the upper right corner is in (W,H)(W,H).

There is a rectangular table standing in this room. The sides of the table are parallel to the walls, the lower left corner is in (x1,y1)(x1,y1), and the upper right corner in (x2,y2)(x2,y2).

You want to place another rectangular table in this room with width ww and height hh with the width of the table parallel to the width of the room.

The problem is that sometimes there is not enough space to place the second table without intersecting with the first one (there are no problems with tables touching, though).

You can’t rotate any of the tables, but you can move the first table inside the room.

The first line contains the single integer tt (1≤t≤50001≤t≤5000) — the number of the test cases.

The first line of each test case contains two integers WW and HH (1≤W,H≤1081≤W,H≤108) — the width and the height of the room.

The second line contains four integers x1x1, y1y1, x2x2 and y2y2 (0≤x1<x2≤W0≤x1<x2≤W; 0≤y1<y2≤H0≤y1<y2≤H) — the coordinates of the corners of the first table.

The third line contains two integers ww and hh (1≤w≤W1≤w≤W; 1≤h≤H1≤h≤H) — the width and the height of the second table.

For each test case, print the minimum distance you should move the first table, or −1−1 if there is no way to free enough space for the second table.

Your answer will be considered correct if its absolute or relative error doesn’t exceed 10−610−6.

input

5 8 5 2 1 7 4 4 2 5 4 2 2 5 4 3 3 1 8 0 3 1 6 1 5 8 1 3 0 6 1 5 1 8 10 4 5 7 8 8 5

output

1.000000000 -1 2.000000000 2.000000000 0.000000000

The configuration of the first test case is shown in the picture. But the movement of the first table is not optimal. One of the optimal movement, for example, is to move the table by (0,−1)(0,−1), so the lower left corner will move from (2,1)(2,1) to (2,0)(2,0). Then you can place the second table at (0,3)−(4,5)(0,3)−(4,5).

In the second test case, there is no way to fit both tables in the room without intersecting.

In the third test case, you can move the first table by (0,2)(0,2), so the lower left corner will move from (0,3)(0,3) to (0,5)(0,5).