CF1759C.Thermostat

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Thermostat

Vlad came home and found out that someone had reconfigured the old thermostat to the temperature of aa.

The thermostat can only be set to a temperature from ll to rr inclusive, the temperature cannot change by less than xx. Formally, in one operation you can reconfigure the thermostat from temperature aa to temperature bb if abx|a - b| \ge x and lbrl \le b \le r.

You are given ll, rr, xx, aa and bb. Find the minimum number of operations required to get temperature bb from temperature aa, or say that it is impossible.

Input

The first line of input data contains the single integer tt (1t1041 \le t \le 10^4) — the number of test cases in the test.

The descriptions of the test cases follow.

The first line of each case contains three integers ll, rr and xx (109lr109-10^9 \le l \le r \le 10^9, 1x1091 \le x \le 10^9) — range of temperature and minimum temperature change.

The second line of each case contains two integers aa and bb (la,brl \le a, b \le r) — the initial and final temperatures.

Output

Output tt numbers, each of which is the answer to the corresponding test case. If it is impossible to achieve the temperature bb, output -1, otherwise output the minimum number of operations.

Note

In the first example, the thermostat is already set up correctly.

In the second example, you can achieve the desired temperature as follows: 41054 \rightarrow 10 \rightarrow 5.

In the third example, you can achieve the desired temperature as follows: 38273 \rightarrow 8 \rightarrow 2 \rightarrow 7.

In the fourth test, it is impossible to make any operation.

Samples

10
3 5 6
3 3
0 15 5
4 5
0 10 5
3 7
3 5 6
3 4
-10 10 11
-5 6
-3 3 4
1 0
-5 10 8
9 2
1 5 1
2 5
-1 4 3
0 2
-6 3 6
-1 -4
0
2
3
-1
1
-1
3
1
3
-1

在线编程 IDE

建议全屏模式获得最佳体验