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

The thermostat can only be set to a temperature from $l$ to $r$ inclusive, the temperature cannot change by less than $x$. Formally, in one operation you can reconfigure the thermostat from temperature $a$ to temperature $b$ if $|a - b| \ge x$ and $l \le b \le r$.

You are given $l$, $r$, $x$, $a$ and $b$. Find the minimum number of operations required to get temperature $b$ from temperature $a$, or say that it is impossible.


-----Input-----

The first line of input data contains the single integer $t$ ($1 \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 $l$, $r$ and $x$ ($-10^9 \le l \le r \le 10^9$, $1 \le x \le 10^9$) — range of temperature and minimum temperature change.

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


-----Output-----

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


-----Examples-----

Input
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
Output
0
2
3
-1
1
-1
3
1
3
-1


-----Note-----

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

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

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

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

Difficulty: EASY
Tags: Greedy algorithms

Mathematics

Shortest paths
Skill types: Greedy algorithms

Starter code:

Solutions:
import sys
input = sys.stdin.readline
for t in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	if abs(a - b) >= x:
		print(1)
		continue
	if a < b:
		if a - l >= x:
			print(2)
			continue
		if r - a >= x:
			if r - b >= x:
				print(2)
				continue
			if r - l >= x:
				if b - l >= x:
					print(3)
					continue
				print(-1)
				continue
			print(-1)
			continue
		print(-1)
		continue
	else:
		if r - a >= x:
			print(2)
			continue
		if a - l >= x:
			if b - l >= x:
				print(2)
				continue
			if r - l >= x:
				if r - b >= x:
					print(3)
					continue
				print(-1)
				continue
			print(-1)
			continue
		print(-1)
		continue


import collections
import heapq
import sys
import math
import bisect
import os
from io import BytesIO, IOBase
input = sys.stdin.readline

def solve():
	(l, r, s) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if a == b:
		return 0
	if a < b:
		if a + s <= b:
			return 1
		if a + s <= r and r - s >= b:
			return 2
		elif a - s >= l and l + s <= b:
			return 2
		if a + s <= r and l + s <= b:
			return 3
		return -1
	if a > b:
		if a - s >= b:
			return 1
		if a + s <= r and r - s >= b:
			return 2
		elif a - s >= l and l + s <= b:
			return 2
		if a - s >= l and r - s >= b:
			return 3
		return -1
for i in range(int(input())):
	print(solve())


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(l, r, x) = map(int, sys.stdin.readline().split())
	(a, b) = map(int, sys.stdin.readline().split())
	ji = 0
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
	elif abs(b - a) >= x:
		print(1)
	elif r - b >= x or (b - l >= x and a - l >= x):
		print(2)
	elif r - a >= x and (b - l >= x and r - l >= x):
		print(3)
	else:
		print(-1)


import sys
from collections import *
sys.setrecursionlimit(10 ** 5)
itr = (line for line in sys.stdin.read().strip().split('\n'))
INP = lambda : next(itr)

def ni():
	return int(INP())

def nl():
	return [int(_) for _ in INP().split()]

def solve(l, r, x, a, b):
	if a == b:
		print(0)
		return
	if a + x > r and a - x < l:
		print(-1)
		return
	if b + x > r and b - x < l:
		print(-1)
		return
	if abs(a - b) >= x:
		print(1)
		return
	best = 3
	if a + x <= r:
		if abs(r - b) >= x:
			best = 2
	if a - x >= l:
		if abs(b - l) >= x:
			best = 2
	print(best)
	return
t = ni()
for _ in range(t):
	(l, r, x) = nl()
	(a, b) = nl()
	solve(l, r, x, a, b)


import sys
input = sys.stdin.readline
from math import ceil
list_input = lambda x=int: list(map(x, input().strip().split()))
mult_input = lambda x=int: map(x, input().strip().split())
str_input = lambda : input().rstrip('/r/n')

def dist(x, p, q):
	if p == q:
		return 0
	if abs(p - q) >= x:
		return 1
	return -1

def solve():
	(l, r, x) = mult_input()
	(a, b) = mult_input()
	ans = dist(x, a, b)
	if ans != -1:
		return ans
	if dist(x, b, l) == -1 and dist(x, b, r) == -1:
		return -1
	if b > a and r - b >= x:
		return 2
	if b > a and a - l >= x:
		return 2
	if b > a and b - l >= x and (r - a >= x):
		return 3
	if a > b and b - l >= x:
		return 2
	if a > b and r - a >= x:
		return 2
	if a > b and r - b >= x and (a - l >= x):
		return 3
	return -1
for _ in range(int(input())):
	x = solve()
	if x is not None:
		print(x)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test_cases = inp()
inp_arr = []
for i in range(test_cases):
	l1 = inlt()
	l2 = inlt()
	inp_arr.append((l1[0], l1[1], l1[2], l2[0], l2[1]))

def findResult(l, r, x, a, b):
	if a == b:
		return 0
	if abs(a - b) >= x:
		return 1
	if abs(l - b) >= x and abs(l - a) >= x:
		return 2
	if abs(r - b) >= x and abs(r - a) >= x:
		return 2
	if abs(l - b) >= x and abs(r - a) >= x:
		return 3
	if abs(r - b) >= x and abs(l - a) >= x:
		return 3
	return -1
result = [findResult(l, r, x, a, b) for (l, r, x, a, b) in inp_arr]
for m in result:
	print(m)


import sys
from bisect import bisect_left, bisect_right
from heapq import heapify, heappush, heappop
from collections import deque
from math import gcd, sqrt, log10, log2, floor, ceil, sqrt
from collections import deque, defaultdict
input = sys.stdin.readline

def il():
	return [int(a) for a in input().strip().split()]

def ip():
	return input().strip()

def ii():
	return int(input())
mod = 1000000000 + 7
dx = [-1, -2, 1, 2, 2, -2, -1, 1]
dy = [2, 1, 2, 1, -1, -1, -2, -2]

def ans(a, b, l, r, x):
	if a == b:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif abs(l - b) < x and abs(r - b) < x:
		print(-1)
	else:
		left = False
		if abs(l - a) >= x:
			left = True
		right = False
		if abs(r - a) >= x:
			right = True
		if left and right:
			print(2)
		elif abs(l - a) < x and abs(r - a) < x:
			print(-1)
		elif abs(l - a) >= x and abs(l - b) >= x or (abs(r - a) >= x and abs(r - b) >= x):
			print(2)
		else:
			print(3)
for _ in range(ii()):
	(l, r, x) = il()
	(a, b) = il()
	ans(a, b, l, r, x)


import sys
readline = sys.stdin.readline
T = int(readline())
for _ in range(T):
	(l, r, x) = map(int, readline().split())
	(a, b) = map(int, readline().split())
	if a == b:
		ans = 0
	elif abs(a - b) >= x:
		ans = 1
	elif a < b:
		if b + x <= r and abs(b + x - a) >= x:
			ans = 2
		elif l <= a - x:
			ans = 2
		elif a + x <= r and abs(b - l) >= x:
			ans = 3
		else:
			ans = -1
	elif b - x >= l and abs(b - x - a) >= x:
		ans = 2
	elif a + x <= r:
		ans = 2
	elif l <= a - x and abs(r - b) >= x:
		ans = 3
	else:
		ans = -1
	print(ans)


import heapq
import itertools
import heapq as hq
import math
import bisect as bs
from collections import deque
from queue import PriorityQueue as pq
from collections import defaultdict
from collections import Counter
import sys
input = lambda : sys.stdin.readline().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
inf = 2 ** 63 - 1
for _ in range(ii()):
	(l, r, x) = mi()
	(a, b) = mi()
	if a == b:
		print(0)
		continue
	d1 = abs(a - l)
	d2 = abs(r - a)
	d3 = abs(b - l)
	d4 = abs(r - b)
	if abs(a - b) >= x:
		print(1)
		continue
	elif d1 < x and d2 < x or (d3 < x and d4 < x):
		print(-1)
	elif d1 < x:
		if d4 >= x:
			print(2)
		else:
			print(3)
	elif d2 < x:
		if d3 >= x:
			print(2)
		else:
			print(3)
	else:
		print(2)


import sys

def is_changeable(l, r, x, a, b):
	if a == b:
		return 0
	if abs(b - a) >= x:
		return 1
	if a - l >= x and b - l >= x or (r - a >= x and r - b >= x):
		return 2
	if a - l >= x and r - l >= x and (r - b >= x):
		return 3
	if r - a >= x and r - l >= x and (b - l >= x):
		return 3
	else:
		return -1
j = -1
for line in sys.stdin:
	line = line.rstrip()
	if j == -1:
		j = 0
	elif j == 0:
		y = line.split(' ')
		(l, r, x) = (int(y[0]), int(y[1]), int(y[2]))
		j = 1
	elif j == 1:
		z = line.split(' ')
		(a, b) = (int(z[0]), int(z[1]))
		print(is_changeable(l, r, x, a, b))
		j = 0


def solve():
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		return 0
	if abs(a - b) >= x:
		return 1
	(d1, d2, d3, d4) = (abs(a - l), abs(a - r), abs(b - l), abs(b - r))
	if d1 < x and d2 < x or (d3 < x and d4 < x):
		return -1
	if d1 < x and d4 < x or (d2 < x and d3 < x):
		return 3
	return 2
t = int(input())
res = []
for _ in range(t):
	res.append(solve())
print(*res, sep='\n')


t = int(input())
answers = []
for _ in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a == b:
		answer = 0
	elif b - a >= x:
		answer = 1
	elif a - l >= x or r - b >= x:
		answer = 2
	elif b - l >= x and r - a >= x:
		answer = 3
	else:
		answer = -1
	answers.append(answer)
for answer in answers:
	print(answer)


import sys
input = sys.stdin.readline
t = int(input().rstrip())
for _ in range(t):
	(l, r, x) = map(int, input().rstrip().split())
	(a, b) = map(int, input().rstrip().split())
	big = max(a, b)
	small = min(a, b)
	if big == small:
		print(0)
	elif big - small >= x:
		print(1)
	elif small - x >= l or big + x <= r:
		print(2)
	elif small + x <= r and big - x >= l:
		print(3)
	else:
		print(-1)


from collections import Counter, defaultdict
import sys
import math

def sol(a, b, l, r, x):
	if a == b:
		return 0
	if a + x > r and a - x < l or a < l or b > r or (b + x > r and b - x < l):
		return -1
	elif abs(b - a) >= x:
		return 1
	elif b > a and (a - x >= l or b + x <= r):
		return 2
	elif b < a and (a + x <= r or b - x >= l):
		return 2
	return 3
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return str(input())

def invr():
	return map(int, input().split())
T = inp()
for i in range(T):
	arr = inlt()
	l = arr[0]
	r = arr[1]
	x = arr[2]
	arr = inlt()
	a = arr[0]
	b = arr[1]
	print(sol(a, b, l, r, x))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s.strip())

def invr():
	return map(int, input().split())
for _ in range(inp()):
	(l, r, x) = invr()
	(a, b) = invr()
	if abs(a - b) == 0:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif abs(l - b) >= x and abs(l - a) >= x or (abs(r - b) >= x and abs(r - a) >= x):
		print(2)
	elif (abs(l - b) >= x or abs(r - b) >= x) and (abs(l - a) >= x or abs(r - a) >= x):
		print(3)
	else:
		print(-1)


t = int(input())
out = []
for i in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		out.append(0)
		continue
	if a + x > r and a - x < l:
		out.append(-1)
	elif b + x > r and b - x < l:
		out.append(-1)
	elif abs(b - a) >= x:
		out.append(1)
	elif a + x > r and b - x < l:
		out.append(3)
	elif a - x < l and b + x > r:
		out.append(3)
	else:
		out.append(2)
for i in out:
	print(i)


import sys
import math
import heapq
from functools import lru_cache
from collections import Counter
from collections import defaultdict
from collections import deque
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	(left, right, jump) = inlt()
	(initial, destination) = inlt()
	count = 0
	visited = set()
	while initial != destination:
		if abs(destination - initial) >= jump:
			count += 1
			initial = destination
		elif abs(left - destination) >= abs(right - destination) and abs(left - initial) >= jump:
			count += 1
			initial = left
		elif abs(left - destination) < abs(right - destination) and abs(right - initial) >= jump:
			count += 1
			initial = right
		elif abs(left - initial) >= jump:
			count += 1
			initial = left
		elif abs(right - initial) >= jump:
			count += 1
			initial = right
		else:
			break
		if initial in visited:
			break
		visited.add(initial)
	if initial != destination:
		return -1
	return count
t = inp()
for _ in range(t):
	answer = main()
	print(answer)


def temp(l, r, x, a, b):
	if a == b:
		return 0
	if abs(a - b) >= x:
		return 1
	if a < b:
		if a - l >= x:
			return 2
		if r - a >= x and r - b >= x:
			return 2
		if r - a >= x and r - l >= x and (b - l >= x):
			return 3
		return -1
	if a > b:
		if r - a >= x:
			return 2
		if a - l >= x and b - l >= x:
			return 2
		if a - l >= x and r - l >= x and (r - b >= x):
			return 3
		return -1
t = int(input())
ans = []
for i in range(t):
	(ll, rr, xx) = [int(x) for x in input().split()]
	(aa, bb) = [int(x) for x in input().split()]
	ans.append(temp(ll, rr, xx, aa, bb))
for i in ans:
	print(i)


resultados = []
t = int(input())
for i in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		resultados.append(0)
	elif abs(a - b) >= x:
		resultados.append(1)
	elif r - max(a, b) >= x or min(a, b) - l >= x:
		resultados.append(2)
	elif r - b >= x and a - l >= x or (r - a >= x and b - l >= x):
		resultados.append(3)
	else:
		resultados.append(-1)
for elem in resultados:
	print(elem)


buf = list()
t = int(input())
for i in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		buf.append(0)
	elif x <= abs(a - b):
		buf.append(1)
	elif b > a and (b + x <= r or a - x >= l) or (b < a and (b - x >= l or a + x <= r)):
		buf.append(2)
	elif b > a and (a + x <= r and b - x >= l) or (b < a and (a - x >= l and b + x <= r)):
		buf.append(3)
	else:
		buf.append(-1)
for b in buf:
	print(b)


t = int(input())
result = ''
while t:
	t -= 1
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		result += '0'
	elif abs(a - b) >= x:
		result += '1'
	elif a < b and (r - b >= x or a - l >= x) or (a > b and (b - l >= x or r - a >= x)):
		result += '2'
	elif a < b and r - a >= x and (b - l >= x) or (a > b and r - b >= x and (a - l >= x)):
		result += '3'
	else:
		result += '-1'
	result += '\n'
print(result[:-1])


t = int(input())
results = []
for i in range(t):
	q = list(map(int, input().strip().split()))
	(l, r, x) = (q[0], q[1], q[2])
	w = list(map(int, input().strip().split()))
	(a, b) = (w[0], w[1])
	if b < l or b > r:
		results.append(-1)
	elif a == b:
		results.append(0)
	elif a + x > r and a - x < l:
		results.append(-1)
	elif b + x > r and b - x < l:
		results.append(-1)
	elif abs(a - b) >= x:
		results.append(1)
	elif a > b:
		if r - a >= x:
			results.append(2)
		elif b - l >= x:
			results.append(2)
		else:
			results.append(3)
	elif a - l >= x:
		results.append(2)
	elif r - b >= x:
		results.append(2)
	else:
		results.append(3)
for k in results:
	print(k)


import sys
input = sys.stdin.readline
t = int(input().rstrip())

def dist(a, b):
	if a > b:
		return a - b
	return b - a
for _ in range(t):
	(l, r, x) = map(int, input().rsplit())
	(a, b) = map(int, input().rsplit())
	if a == b:
		print(0)
	elif a < b:
		if dist(a, b) >= x:
			print(1)
		elif dist(l, a) >= x:
			print(2)
		elif dist(a, r) >= x:
			if dist(b, r) >= x:
				print(2)
			elif dist(l, r) >= x:
				if dist(l, b) >= x:
					print(3)
				else:
					print(-1)
			else:
				print(-1)
		else:
			print(-1)
	elif a > b:
		if dist(a, b) >= x:
			print(1)
		elif dist(a, r) >= x:
			print(2)
		elif dist(a, l) >= x:
			if dist(l, b) >= x:
				print(2)
			elif dist(l, r) >= x:
				if dist(r, b) >= x:
					print(3)
				else:
					print(-1)
			else:
				print(-1)
		else:
			print(-1)


n = int(input())
finalList = []
for i in range(n):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b < a:
		wr = a
		a = b
		b = wr
	flag = False
	w = a
	number = -1
	for j in range(1, 4):
		if w == b:
			number = 0
			flag = True
			break
		if b - w == x:
			number = j
			flag = True
			break
		if b - w > x:
			number = j
			flag = True
			break
		if abs(w - l) >= x:
			number = 2
			flag = True
			break
		if abs(r - b) >= x:
			number = 2
			flag = True
			break
		if abs(r - l) < x:
			number = -1
			break
		if w + x > r and w - x < l:
			number = -1
			break
		if b + x > r and b - x < l:
			number = -1
			break
		if abs(r - w) >= x:
			number = 3
			flag = True
			break
		if abs(b - l) >= x:
			number = 3
			flag = True
			break
	finalList.append(number)
for i in range(len(finalList)):
	print(finalList[i])


t = int(input(''))
C = [4] * t
for i in range(t):
	LRX = input('').split(' ')
	l = int(LRX[0])
	r = int(LRX[1])
	x = int(LRX[2])
	AB = input('').split(' ')
	a = int(AB[0])
	b = int(AB[1])
	if a == b:
		C[i] = 0
	elif abs(a - b) >= x:
		C[i] = 1
	elif abs(a - r) >= x and abs(b - r) >= x:
		C[i] = 2
	elif abs(a - l) >= x and abs(b - l) >= x:
		C[i] = 2
	elif abs(a - r) >= x and abs(b - l) >= x:
		C[i] = 3
	elif abs(a - l) >= x and abs(b - r) >= x:
		C[i] = 3
	else:
		C[i] = -1
for j in C:
	print(j)


t = int(input())
result = []
for i in range(t):
	(l, r, p) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	if a == b:
		result.append(0)
	elif a < b:
		if a + p <= b:
			result.append(1)
		elif (b + p <= r) | (a - p >= l):
			result.append(2)
		elif (a + p <= r) & (b - p >= l):
			result.append(3)
		else:
			result.append(-1)
	elif a > b:
		if a - p >= b:
			result.append(1)
		elif (b - p >= l) | (a + p <= r):
			result.append(2)
		elif (a - p >= l) & (b + p <= r):
			result.append(3)
		else:
			result.append(-1)
for i in result:
	print(i)


amount_v = int(input())
c = []
d = []
for i in range(amount_v * 2):
	if i % 2 == 0:
		c += [[int(x) for x in input().split()]]
	else:
		d += [[int(x) for x in input().split()]]
res = []
for (elem_c, elem_d) in zip(c, d):
	l = elem_c[0]
	r = elem_c[1]
	x = elem_c[2]
	a = elem_d[0]
	b = elem_d[1]
	if a == b:
		res += [0]
	elif abs(r - l) < x:
		res += [-1]
	elif a - x < l and a + x > r:
		res += [-1]
	elif b - x < l and b + x > r:
		res += [-1]
	elif abs(a - b) >= x:
		res += [1]
	elif a - x >= l and abs(b - l) >= x:
		res += [2]
	elif a + x <= r and abs(r - b) >= x:
		res += [2]
	else:
		res += [3]
for elem_r in res:
	print(elem_r)


t = int(input())
k = []
for i in range(t):
	(l, r, x) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	g = 0
	if a == b:
		k.append(0)
	elif a - x < l and a + x > r or (l + x > b and r - x < b) or (b + x > r and b - x < l):
		k.append(-1)
	elif abs(a - b) >= x:
		k.append(1)
	elif a + x <= r and abs(r - b) >= x or (a - x >= l and abs(l - b) >= x):
		k.append(2)
	else:
		k.append(3)
for i in k:
	print(i, end='\n')


n = eval(input())
while n > 0:
	string = input().split(' ')
	l = int(string[0])
	r = int(string[1])
	x = int(string[2])
	string = input().split(' ')
	a = int(string[0])
	b = int(string[1])
	if abs(a - b) >= x:
		print(1)
	elif a == b:
		print(0)
	elif abs(b - l) < x and abs(b - r) < x:
		print(-1)
	elif abs(a - l) < x and abs(a - r) < x:
		print(-1)
	elif abs(a - l) < x and abs(b - r) < x:
		print(3)
	elif abs(b - l) < x and abs(a - r) < x:
		print(3)
	else:
		print(2)
	n -= 1


t = int(input())
while t > 0:
	c = input()
	(l, r, x) = c.split(' ')
	d = input()
	(a, b) = d.split(' ')
	(l, r, x) = (int(l), int(r), int(x))
	(a, b) = (int(a), int(b))
	if a == b:
		print('0')
	elif a < b:
		cc = b - a
		if x < cc or x == cc:
			print('1')
		elif b + x < r or b + x == r:
			print('2')
		elif b - x > l or b - x == l:
			if a - x > l or a - x == l:
				print('2')
			elif a + x < r + 1 and a > l:
				print('3')
			else:
				print('-1')
		else:
			print('-1')
	else:
		(a, b) = (b, a)
		cc = b - a
		if x < cc or x == cc:
			print('1')
		elif b + x < r or b + x == r:
			print('2')
		elif b - x > l or b - x == l:
			if a - x > l or a - x == l:
				print('2')
			elif a + x < r + 1 and a > l:
				print('3')
			else:
				print('-1')
		else:
			print('-1')
	t = t - 1


def check(a1: int, a2: int) -> bool:
	return abs(a1 - a2) >= x
for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif check(a, b):
		print(1)
	elif check(a, l) and check(l, b) or (check(a, r) and check(r, b)):
		print(2)
	elif check(l, r) and (check(a, l) and check(r, b) or (check(a, r) and check(l, b))):
		print(3)
	else:
		print(-1)


for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	k = abs(a - b)
	if a == b:
		print('0')
		continue
	if k >= x:
		print('1')
		continue
	if abs(l - r) < x:
		print('-1')
		continue
	if abs(a - l) < x and abs(a - r) < x:
		print('-1')
		continue
	z1 = 10 ** 5
	z2 = 10 ** 5
	if abs(a - l) >= x:
		if abs(b - l) >= x:
			z1 = 2
		elif abs(b - r) >= x:
			z1 = 3
	if abs(a - r) >= x:
		if abs(b - r) >= x:
			z2 = 2
		elif abs(b - l) >= x:
			z2 = 3
	zz = min(z2, z1)
	if zz == 10 ** 5:
		print('-1')
	else:
		print(zz)


def main():
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		return
	if not l <= b <= r:
		print(-1)
		return
	if abs(b - a) >= x:
		print(1)
		return
	if abs(a - l) >= x and abs(b - l) >= x or (abs(a - r) >= x and abs(b - r) >= x):
		print(2)
		return
	if abs(a - r) >= x and abs(r - l) >= x and (abs(b - l) >= x) or (abs(a - l) >= x and abs(r - l) >= x and (abs(b - r) >= x)):
		print(3)
		return
	print(-1)
for tst in range(int(input())):
	main()


def is_possible(l, r, x, a, b):
	if a == b:
		return 0
	elif abs(a - b) >= x:
		return 1
	elif a - l >= x and b - l >= x:
		return 2
	elif r - a >= x and r - b >= x:
		return 2
	elif a - l >= x and r - b >= x:
		return 3
	elif r - a >= x and b - l >= x:
		return 3
	else:
		return -1

def main():
	t = int(input().strip())
	for i in range(t):
		(l, r, x) = [int(i) for i in input().strip().split()]
		(a, b) = [int(i) for i in input().strip().split()]
		print(is_possible(l, r, x, a, b))
main()


test_cases = int(input())
for i in range(test_cases):
	(min_temp, max_temp, min_change) = map(int, input().split())
	(initial_temp, final_temp) = map(int, input().split())
	if initial_temp == final_temp:
		print(0)
		continue
	if initial_temp + min_change == final_temp:
		print(1)
		continue
	if initial_temp - min_change == final_temp:
		print(1)
		continue
	if initial_temp + min_change > max_temp and initial_temp - min_change < min_temp:
		print(-1)
		continue
	if final_temp - min_change < min_temp and final_temp + min_change > max_temp:
		print(-1)
		continue
	if initial_temp > final_temp:
		if initial_temp - final_temp >= min_change:
			print(1)
			continue
		elif initial_temp + min_change <= max_temp:
			print(2)
			continue
		elif initial_temp - min_change - (initial_temp - final_temp) >= min_temp:
			print(2)
			continue
		print(3)
	if final_temp > initial_temp:
		if final_temp - initial_temp >= min_change:
			print(1)
			continue
		elif initial_temp + min_change + (final_temp - initial_temp) <= max_temp:
			print(2)
			continue
		elif initial_temp - min_change >= min_temp:
			print(2)
			continue
		print(3)


def solution():
	(l, r, x) = map(int, input().split())
	(a, b) = list(map(int, input().split()))
	if a == b:
		return 0
	elif abs(a - b) >= x:
		return 1
	elif a + x <= r and abs(r - b) >= x or (a - x >= l and abs(l - b) >= x):
		return 2
	elif a + x <= r and abs(l - b) >= x or (a - x >= l and abs(r - b) >= x):
		return 3
	else:
		return -1
for _ in range(int(input())):
	ans = solution()
	print(ans)


for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	d1 = abs(a - l)
	d2 = abs(r - a)
	d3 = abs(b - l)
	d4 = abs(r - b)
	if a == b:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif d1 < x and d2 < x or (d3 < x and d4 < x):
		print(-1)
	elif d1 < x:
		if d4 >= x:
			print(2)
		else:
			print(3)
	elif d2 < x:
		if d3 >= x:
			print(2)
		else:
			print(3)
	else:
		print(2)


t = int(input())
for i in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	ok = True
	if a == b:
		print(0)
		ok = False
	if a > b:
		(a, b) = (b, a)
	if ok:
		if b - a >= x:
			print(1)
		elif r - b >= x or (b - l >= x and a - l >= x):
			print(2)
		elif r - a >= x and r - l >= x and (b - l >= x):
			print(3)
		else:
			print(-1)


for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print('0')
	else:
		if a > b:
			temp = a
			a = b
			b = temp
		if b - a >= x:
			print('1')
		elif r - b >= x or (b - l >= x and a - l >= x):
			print('2')
		elif r - a >= x and r - l >= x and (b - l >= x):
			print('3')
		else:
			print('-1')


test = int(input())
while test:
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif b > a and (b + x <= r or a - x >= l) or (a > b and (a + x <= r or b - x >= l)):
		print(2)
	elif a > b and a - x >= l:
		a = a - x
		if b > a and (b + x <= r or a - x >= l) or (a > b and (a + x <= r or b - x >= l)):
			print(3)
		else:
			print(-1)
	elif a < b and a + x <= r:
		a = a + x
		if b > a and (b + x <= r or a - x >= l) or (a > b and (a + x <= r or b - x >= l)):
			print(3)
		else:
			print(-1)
	else:
		print(-1)
	test -= 1


def rasstoanie(tochka, x, a, b):
	f = abs(tochka - a) >= x
	j = abs(tochka - b) >= x
	if f and j:
		return True
	return False

def termostat(l, r, x, a, b):
	if a == b:
		return 0
	if abs(l - a) < x and abs(r - a) < x:
		return -1
	if abs(l - b) < x and abs(r - b) < x:
		return -1
	if abs(a - b) >= x:
		return 1
	ri = rasstoanie(r, x, a, b)
	le = rasstoanie(l, x, a, b)
	if ri or le:
		return 2
	return 3
t = int(input())
for i in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(termostat(l, r, x, a, b))


for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif r - l < x:
		print(-1)
	elif abs(a - b) >= x:
		print(1)
	elif a - x < l and a + x > r:
		print(-1)
	elif b - l < x and r - b < x:
		print(-1)
	elif a - x < l:
		a = r
		if a - b >= x:
			print(2)
		else:
			print(3)
	elif a + x > r:
		a = l
		if b - a >= x:
			print(2)
		else:
			print(3)
	else:
		res = 3
		a = r
		if a - b >= x:
			res = 2
		a = l
		if b - a >= x:
			res = 2
		print(res)


def solve(l, r, x, a, b):
	if a > b:
		(a, b) = (b, a)
	if a == b:
		return 0
	elif b - a >= x:
		return 1
	elif b - l >= x and a - l >= x:
		return 2
	elif r - a >= x and r - b >= x:
		return 2
	elif r - a >= x and r - l >= x and (b - l >= x):
		return 3
	else:
		return -1
n = int(input())
for i in range(n):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(l, r, x, a, b))


n = int(input())

def ops(l, r, x, a, b):
	if a == b:
		return 0
	elif abs(a - b) >= x and l <= b and (b <= r):
		return 1
	elif a < b:
		if a - x >= l:
			return 2
		elif b + x <= r:
			return 2
		elif a + x <= r:
			if b - x >= l:
				return 3
			else:
				return -1
		else:
			return -1
	elif a + x <= r:
		return 2
	elif b - x >= l:
		return 2
	elif a - x >= l:
		if b + x <= r:
			return 3
		else:
			return -1
	else:
		return -1
for i in range(n):
	line = input().strip().split(' ')
	l = int(line[0])
	r = int(line[1])
	x = int(line[2])
	line = input().strip().split(' ')
	a = int(line[0])
	b = int(line[1])
	print(ops(l, r, x, a, b))


for i in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = sorted(map(int, input().split()))
	if a == b:
		print(0)
	elif b - a >= x:
		print(1)
	elif b + x <= r or a - x >= l:
		print(2)
	elif a + x <= r and b - x >= l:
		print(3)
	else:
		print(-1)


t = int(input())
while t:
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
	elif a + x <= b:
		print(1)
	elif b - x < l and b + x > r:
		print(-1)
	elif b + x <= r or a - x >= l:
		print(2)
	else:
		f = False
		while b - x >= l:
			b -= x
			ans += 1
			if a > b:
				(a, b) = (b, a)
			if a + x <= b:
				print(ans + 1)
				f = True
				break
			if b - x < l and b + x > r:
				print(-1)
				f = True
				break
			if b + x <= r or a - x >= l:
				print(2 + ans)
				f = True
				break
		if not f:
			print(-1)
	t -= 1


def solve():
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		return 0
	elif b - a >= x or a - b >= x:
		return 1
	elif a + x > r and a - x < l:
		return -1
	elif b + x > r and b - x < l:
		return -1
	elif b > a:
		if b + x <= r or a - x >= l:
			return 2
	elif a > b:
		if a + x <= r or b - x >= l:
			return 2
	return 3
for _ in [0] * int(input()):
	print(solve())


t = int(input())
for i in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print('0')
		continue
	elif a - x >= b or a + x <= b:
		print('1')
		continue
	elif max(a, b) + x <= r or min(a, b) - x >= l:
		print('2')
		continue
	elif max(a, b) - x >= l and min(a, b) + x <= r:
		print('3')
		continue
	else:
		print('-1')


for t in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif r - a < x and a - l < x or (r - b < x and b - l < x):
		print(-1)
	else:
		al = a - l
		ar = r - a
		bl = b - l
		br = r - b
		if abs(a - b) >= x:
			print(1)
		elif al >= x and bl >= x or (ar >= x and br >= x):
			print(2)
		else:
			print(3)


def run_task():
	(l, r, x) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if a == b:
		return 0
	if abs(b - a) >= x:
		return 1
	if a - l < x and r - a < x:
		return -1
	if b - l < x and r - b < x:
		return -1
	if r - max(a, b) >= x or min(a, b) - l >= x:
		return 2
	return 3
t = int(input())
for _ in range(t):
	print(run_task())


def main():
	num_of_tests = int(input())
	for t in range(num_of_tests):
		(l, r, x) = [int(x) for x in input().split()]
		(a, b) = [int(x) for x in input().split()]
		if a == b:
			print(0)
			continue
		if b - l < x and r - b < x or (a - l < x and r - a < x):
			print(-1)
			continue
		if abs(b - a) >= x:
			print(1)
			continue
		left_steps = 2 if a - l >= x and b - l >= x else 3
		right_steps = 2 if r - a >= x and r - b >= x else 3
		steps = min(left_steps, right_steps)
		print(steps)
main()


def calc():
	(l, r, x) = [int(el) for el in input().split()]
	(a, b) = [int(el) for el in input().split()]
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
		return
	if b - a >= x:
		print(1)
		return
	if a - l >= x or r - b >= x:
		print(2)
		return
	if b - l >= x and r - a >= x:
		print(3)
		return
	print(-1)
for _ in range(int(input())):
	calc()


def counter(l, r, x, a, b, cnt):
	if a == b:
		return 0
	if abs(a - b) >= x:
		return 1
	if abs(a - l) >= x and abs(b - l) >= x or (abs(a - r) >= x and abs(b - r) >= x):
		return 2
	if abs(a - l) >= x and abs(l - r) >= x and (abs(b - r) >= x) or (abs(a - r) >= x and abs(r - l) >= x and (abs(l - b) >= x)):
		return 3
	else:
		return -1

def solution():
	T = int(input())
	for test in range(T):
		(l, r, x) = map(int, input().split())
		(a, b) = map(int, input().split())
		print(counter(l, r, x, a, b, 0))
solution()


t = int(input())
for t1 in range(t):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif r - l < x:
		print(-1)
	elif a < b:
		if a - l >= x:
			print(2)
		elif r - a >= x:
			if r - b >= x:
				print(2)
			elif b - l >= x:
				print(3)
			else:
				print(-1)
		else:
			print(-1)
	elif r - a >= x:
		print(2)
	elif a - l >= x:
		if b - l >= x:
			print(2)
		elif r - b >= x:
			print(3)
		else:
			print(-1)
	else:
		print(-1)


T = int(input())
for tc in range(T):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	cnt = 0
	if a != b:
		if abs(b - a) >= x:
			print(1)
		elif b - l >= x and r - b >= x:
			if a - l >= x or r - a >= x:
				print(2)
			else:
				print(-1)
		elif b - l >= x:
			if a - l >= x:
				print(2)
			elif r - a >= x:
				print(3)
			else:
				print(-1)
		elif r - b >= x:
			if r - a >= x:
				print(2)
			elif a - l >= x:
				print(3)
			else:
				print(-1)
		else:
			print(-1)
	else:
		print(0)


for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	else:
		if abs(b - a) >= x:
			print(1)
			continue
		if r - l < x:
			print(-1)
			continue
		if a - l < x and r - a < x or (b - l < x and r - b < x):
			print(-1)
			continue
		if a - l >= x and b - l >= x or (r - a >= x and r - b >= x):
			print(2)
			continue
		if a - l >= x and r - b >= x or (r - a >= x and b - l >= x):
			print(3)
			continue


for _ in range(0, int(input())):
	(l, r, x) = map(int, input().split())
	(n, m) = map(int, input().split())
	if n > m:
		(n, m) = [m, n]
	if n == m:
		print(0)
		continue
	if m - n >= x:
		print(1)
		continue
	if r - n >= x and r - m >= x or (n - l >= x and m - l >= x):
		print(2)
		continue
	if n - l >= x and r - l >= x and (r - m >= x) or (r - n >= x and r - l >= x and (m - l >= x)):
		print(3)
		continue
	print(-1)


t = int(input())
for tt in range(t):
	(l, r, x) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if a <= b:
		if a == b:
			print(0)
			continue
		if b - a >= x:
			print(1)
			continue
		if a - l >= x and b - l >= x or (r - a >= x and r - b >= x):
			print(2)
			continue
		if r - a >= x and b - l >= x:
			print(3)
			continue
	else:
		if a - b >= x:
			print(1)
			continue
		if a - l >= x and b - l >= x or (r - a >= x and r - b >= x):
			print(2)
			continue
		if a - l >= x and r - b >= x:
			print(3)
			continue
	print(-1)


def cal(l, r, x, a, b):
	if a == b:
		return 0
	if abs(a - b) >= x:
		return 1
	if a - x < l and a + x > r:
		return -1
	if b - x < l and b + x > r:
		return -1
	if a > b:
		(a, b) = (b, a)
	if a - x >= l:
		return 2
	elif b + x <= r:
		return 2
	else:
		return 3
for jj in range(int(input())):
	(l, r, x) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	print(cal(l, r, x, a, b))


t = int(input())
while t > 0:
	ip = [int(x) for x in input().split()]
	l = ip[0]
	r = ip[1]
	x = ip[2]
	(a, b) = [int(x) for x in input().split()]
	if a == b:
		print(0)
	elif abs(b - a) >= x:
		print(1)
	else:
		ans1 = -1
		ans2 = -1
		if abs(a - r) >= x:
			if abs(b - r) >= x:
				ans1 = 2
			elif abs(b - l) >= x:
				ans1 = 3
			else:
				ans1 = -1
		if abs(a - l) >= x:
			if abs(b - l) >= x:
				ans2 = 2
			elif abs(b - r) >= x:
				ans2 = 3
			else:
				ans2 = -1
		if ans1 == -1 and ans2 == -1:
			print(-1)
		elif ans1 == -1:
			print(ans2)
		elif ans2 == -1:
			print(ans1)
		else:
			print(min(ans1, ans2))
	t -= 1


t = int(input())
for _ in range(t):
	g = input().split()
	l = int(g[0])
	r = int(g[1])
	x = int(g[2])
	p = input().split()
	a = int(p[0])
	b = int(p[1])
	ab_min = min(a, b)
	ab_max = max(a, b)
	if a == b:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif ab_min - x >= l or ab_max + x <= r:
		print(2)
	elif ab_max - x >= l and ab_min + x <= r:
		print(3)
	else:
		print(-1)


nb_test_case = int(input())
for i in range(0, nb_test_case):
	lists = input().split()
	l = int(lists[0])
	r = int(lists[1])
	x = int(lists[2])
	lists = input().split()
	a = int(lists[0])
	b = int(lists[1])
	if a == b:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif abs(a - l) < x and abs(a - r) < x:
		print(-1)
	elif abs(b - l) < x and abs(b - r) < x:
		print(-1)
	elif abs(a - l) >= x and abs(a - r) >= x:
		print(2)
	elif abs(b - l) >= x and abs(b - r) >= x:
		print(2)
	elif abs(b - l) >= x and abs(a - l) >= x:
		print(2)
	elif abs(b - r) >= x and abs(a - r) >= x:
		print(2)
	else:
		print(3)


t = int(input())
for p in range(t):
	(l, r, x) = map(int, input().split())
	(start, finish) = map(int, input().split())
	minim = min(start, finish)
	maxim = max(start, finish)
	start = minim
	finish = maxim
	if start != finish:
		if finish - start >= x:
			print(1)
		elif start - x >= l:
			print(2)
		elif finish + x <= r:
			print(2)
		elif r - finish >= x:
			print(2)
		elif start - l >= x:
			print(2)
		elif r - start >= x and finish - l >= x:
			print(3)
		else:
			print(-1)
	else:
		print(0)


import math
t = int(input())

def solve():
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	(mi, ma) = (min(a, b), max(a, b))
	if a == b:
		return 0
	if ma - mi >= x:
		return 1
	if mi - x >= l or ma + x <= r:
		return 2
	if ma - x >= l and mi + x <= r:
		return 3
	return -1
for i in range(t):
	print(solve())


def solution():
	(l, r, x) = (int(num) for num in input().split())
	(a, b) = (int(num) for num in input().split())
	if a == b:
		print(0)
		return
	if r - a < x and a - l < x:
		print(-1)
		return
	if r - b < x and b - l < x:
		print(-1)
		return
	if abs(b - a) >= x:
		print(1)
		return
	if b < a:
		(a, b) = (b, a)
	if a - l >= x:
		print(2)
		return
	if r - b >= x:
		print(2)
		return
	print(3)
	return

def main():
	t = int(input())
	while t:
		solution()
		t -= 1
main()


def func(a, b, l, r, x):
	if a == b:
		return 0
	if b < l or b > r:
		return -1
	if abs(b - l) < x and abs(b - r) < x:
		return -1
	if a + x > r and a - x < l:
		return -1
	if abs(a - b) >= x:
		return 1
	if abs(b - l) >= abs(b - r):
		if abs(a - l) >= x:
			curr = l
		else:
			curr = r
	elif abs(a - r) >= x:
		curr = r
	else:
		curr = l
	if abs(curr - b) >= x:
		return 2
	else:
		return 3
T = int(input())
for _ in range(T):
	(l, r, x) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	print(func(a, b, l, r, x))


tt = int(input())
for _ in range(tt):
	(low, high, diff) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
	elif b - a >= diff:
		print(1)
	elif high - b >= diff or (b - low >= diff and a - low >= diff):
		print(2)
	elif high - a >= diff and high - low >= diff and (b - low >= diff):
		print(3)
	else:
		print(-1)


for _ in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = abs(b - a)
	if c == 0:
		print(0)
	elif c >= x:
		print(1)
	else:
		if b < a:
			(a, b) = (b, a)
		p = b + x
		q = a - x
		if r >= p or l <= q:
			print(2)
		elif a + x <= r and b - x >= l:
			print(3)
		else:
			print(-1)


for i in range(int(input())):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	(ans1, ans2, ans3, ans4) = (abs(a - l), abs(r - a), abs(b - l), abs(r - b))
	if a == b:
		print(0)
	elif abs(a - b) >= x:
		print(1)
	elif ans1 < x and ans2 < x or (ans3 < x and ans4 < x):
		print(-1)
	elif ans1 < x:
		if ans4 >= x:
			print(2)
		else:
			print(3)
	elif ans2 < x:
		if ans3 >= x:
			print(2)
		else:
			print(3)
	else:
		print(2)


from collections import defaultdict, deque
import heapq
import sys
import threading
from functools import lru_cache
import math

def solve():
	(l, r, x) = invr()
	(a, b) = invr()
	if not l <= b <= r or not l <= a <= r:
		return -1
	if a == b:
		return 0
	elif abs(b - a) >= x:
		return 1
	elif a + x <= r and abs(r - b) >= x:
		return 2
	elif abs(l - a) >= x and b - l >= x:
		return 2
	elif a + x <= r and abs(r - l) >= x and (abs(b - l) >= x):
		return 3
	elif abs(a - l) >= x and abs(r - l) >= x and (abs(r - b) >= x):
		return 3
	else:
		return -1
3
1
3
-1

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		print(solve())
threading.stack_size(1 << 27)
sys.setrecursionlimit(1 << 30)
main_thread = threading.Thread(target=main)
main_thread.start()
main_thread.join()


import os, sys, io, math
from array import array
from math import *
from bisect import *
from heapq import *
from functools import *
from itertools import *
from collections import Counter, defaultdict
I = lambda : [*map(int, sys.stdin.readline().split())]
IS = lambda : input()
IN = lambda : int(input())
IF = lambda : float(input())
for _ in range(IN()):
	(l, r, x) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif a - x < l and a + x > r:
		print(-1)
	elif b - l < x and r - b < x:
		print(-1)
	elif abs(a - b) >= x:
		print(1)
	elif abs(l - a) < x:
		if abs(r - b) >= x:
			print(2)
		else:
			print(3)
	elif abs(r - a) < x:
		if abs(l - b) >= x:
			print(2)
		else:
			print(3)
	else:
		print(2)