“I am not in danger, Skyler. I am the danger. A guy opens his door and gets shot, and you think that of me? No! I am the one who knocks!”
Skyler fears Walter and ponders escaping to Colorado. Walter wants to clean his lab as soon as possible and then go back home to his wife. 
In order clean his lab, he has to achieve cleaning level of lab as $Y$. The current cleaning level of the lab is $X$. 
He must choose one positive odd integer $a$ and one positive even integer $b$. Note that, he cannot change $a$ or $b$ once he starts cleaning.
He can perform any one of the following operations for one round of cleaning:  
- Replace $X$ with $X+a$.  
- Replace $X$ with $X-b$.
Find minimum number of rounds (possibly zero) to make lab clean.

-----Input:-----
- First line will contain $T$, number of test cases. $T$ testcases follow :  
- Each test case contains two space separated integers $X, Y$. 

-----Output:-----
For each test case, output an integer denoting minimum number of rounds to clean the lab.

-----Constraints-----
- $1 \leq T \leq 10^5$
- $ |X|,|Y| \leq 10^9$

-----Sample Input:-----
3
0 5
4 -5
0 10000001

-----Sample Output:-----
1
2
1

-----EXPLANATION:-----
- 
For the first testcase, you can convert $X$ to $Y$  by choosing $a=5$ and $b=2$.

It will cost minimum of $1$ cleaning round. You can select any other combination of $a, b$ satisfying above condition but will take minimum of $1$ cleaning round in any case.
- 
For the second testcase, you can convert $X$ to $Y$ by choosing $a=1$ and $b=10$. In first round they will replace $X$ to $X+a$ and then in second round replace to $X-b$. You can perform only one operation in one round.

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Constructive algorithms

Ad-hoc


Solutions:
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	if y > x:
		if (y - x) % 2 != 0:
			print(1)
		elif (y - x) // 2 % 2 != 0:
			print(2)
		else:
			print(3)
	elif x == y:
		print(0)
	elif (x - y) % 2 == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	if y - x == 0:
		print(0)
		continue
	if y - x > 0:
		if (y - x) % 2:
			print(1)
			continue
		if not (y - x) % 2 and (y - x) % 4:
			print(2)
			continue
		else:
			print(3)
			continue
	if y - x < 0:
		if (y - x) % 2:
			print(2)
			continue
		else:
			print(1)
			continue


test_case = int(input())
while test_case > 0:
	(x, y) = list(map(int, input().split(' ')))
	difference = abs(x - y)
	ans = 0
	if x > y:
		if difference % 2 == 0:
			ans = 1
		else:
			ans = 2
	elif x < y:
		if difference % 2 == 0 and difference % 4 != 0:
			ans = 2
		elif difference % 2 == 1:
			ans = 1
		else:
			ans = 3
	elif x == y:
		ans = 0
	print(ans)
	test_case -= 1


try:
	t = int(input())
	while t:
		(x, y) = input().split()
		x = int(x)
		y = int(y)
		if x == y:
			print(0)
		elif x < y and (y - x) % 2 == 1 or (x > y and (x - y) % 2 == 0):
			print(1)
		elif x < y and (y - x) % 4 == 0:
			print(3)
		elif x > y and (x - y) % 2 == 1 or (x < y and (y - x) % 2 == 0):
			print(2)
		t -= 1
except:
	pass


t = int(input())
for i in range(t):
	(w, m) = list(map(int, input().split()))
	d = w - m
	if w > m:
		if d % 2 == 0:
			print(1)
		else:
			print(2)
	elif w < m:
		if d % 2 != 0:
			print(1)
		elif d % 4 == 0:
			print(3)
		else:
			print(2)
	else:
		print(0)


T = int(input())
while T:
	T = T - 1
	(x, y) = map(int, input().split())
	counter = 0
	if x == y:
		print('0')
	if x > y:
		n = abs(x - y)
		if n % 2 == 0:
			print('1')
		else:
			print('2')
	if x < y:
		p = y - x
		if p % 2 != 0:
			print('1')
		if p % 2 == 0:
			s = p / 2
			if s % 2 == 0:
				print('3')
			else:
				print('2')


T = int(input())
for _ in range(T):
	(X, Y) = map(int, input().split())
	diff = abs(X - Y)
	ans = 0
	if X > Y:
		if diff % 2 == 0:
			ans = 1
		else:
			ans = 2
	elif X < Y:
		if diff / 2 % 2 == 0:
			ans = 3
		elif diff % 2 != 0:
			ans = 1
		else:
			ans = 2
	print(ans)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	ans = 0
	if x > y:
		if (x - y) % 2 == 0:
			ans = 1
		else:
			ans = 2
	elif x < y:
		if (y - x) % 2 == 1:
			ans = 1
		elif (y - x) % 4 == 0:
			ans = 3
		else:
			ans = 2
	print(ans)


import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print('0')
	elif x > y:
		if abs(x - y) % 2 == 0:
			print('1')
		else:
			print('2')
	elif y > x:
		if abs(x - y) % 2 != 0:
			print('1')
		elif abs(x - y) / 2 % 2 == 0:
			print('3')
		else:
			print('2')


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	d = abs(X - Y)
	if X > Y:
		if d % 2 == 0:
			ans = 1
		else:
			ans = 2
	elif X < Y:
		if d % 2 != 0:
			ans = 1
		elif d % 4 == 0:
			ans = 3
		else:
			ans = 2
	else:
		ans = 0
	print(ans)


t = int(input())
for i in range(t):
	ans = 0
	(x, y) = map(int, input().split())
	if y > x:
		if (y - x) % 4 == 0:
			ans = 3
		elif (y - x) % 2 == 0:
			ans = 2
		else:
			ans = 1
	if y < x:
		if (y - x) % 2 == 0:
			ans = 1
		else:
			ans = 2
	print(ans)


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	if a == b:
		print(0)
	elif b > a:
		c = b - a
		if c % 2 != 0:
			print(1)
		else:
			c = c // 2
			if c % 2 == 0:
				print(3)
			else:
				print(2)
	else:
		c = a - b
		if c % 2 != 0:
			print(2)
		else:
			print(1)


n = int(input())
for i in range(0, n):
	j = input()
	k = j.split()
	(x, y) = (int(k[0]), int(k[1]))
	if x == y:
		print(0)
	elif x < y:
		if (y - x) % 2 == 0:
			if (y - x) % 4 == 0:
				print(3)
			else:
				print(2)
		else:
			print(1)
	elif (x - y) % 2 == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	diff = abs(x - y)
	ans = 0
	if x > y:
		if diff % 2 == 0:
			ans = 1
		else:
			ans = 2
	if x < y:
		if diff % 2 != 0:
			ans = 1
		elif diff / 2 % 2 == 0:
			ans = 3
		else:
			ans = 2
	print(ans)


try:
	a = int(input())
	result = []
	for i in range(a):
		b = input().split()
		dif = int(b[1]) - int(b[0])
		if dif < 0:
			if dif % 2 == 0:
				result += [1]
			else:
				result += [2]
		elif dif > 0:
			if dif % 4 == 0:
				result += [3]
			elif dif % 2 == 0:
				result += [2]
			elif dif % 2 == 1:
				result += [1]
		elif dif == 0:
			result += [0]
	for i in result:
		print(i)
except:
	print()


list = []
for i in range(int(input())):
	(X, Y) = map(int, input().split())
	x = Y - X
	op = 0
	if x == 0:
		op = 0
	elif x > 0:
		if x % 2 != 0:
			op = 1
		elif x % 4 == 0:
			op = 3
		else:
			op = 2
	elif x < 0:
		if x % 2 != 0:
			op = 2
		else:
			op = 1
	list.append(op)
for l in list:
	print(l)


T = int(input())
while T:
	T = T - 1
	(X, Y) = map(int, input().split())
	if Y - X > 0:
		if (Y - X) % 2 == 0:
			if (Y - X) % 4 == 2:
				print('2')
			else:
				print('3')
		else:
			print('1')
	elif Y - X < 0:
		if abs(Y - X) % 2 == 0:
			print('1')
		else:
			print('2')
	else:
		print('0')


N = int(input(''))
for i in range(N):
	str_in = input('')
	a = [int(b) for b in str_in.split(' ')]
	if a[0] == a[1]:
		print('0')
	elif a[1] > a[0]:
		if (a[1] - a[0]) % 2 == 1:
			print('1')
		elif (a[1] - a[0]) / 2 % 2 == 1:
			print('2')
		else:
			print('3')
	elif (a[0] - a[1]) % 2 == 0:
		print('1')
	else:
		print('2')


try:
	from debug import debug, timer
except ImportError:
	pass
from sys import stdin
input = stdin.readline

def rii():
	return range(int(input().strip()))

def ii():
	return int(input().strip())

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())

def getvals():
	while True:
		yield from input().split()

def tri(n):
	return n * (n + 1) // 2

def smallest_first(m, n):
	return (min(m, n), max(m, n))
for _ in rii():
	(x, y) = mii()
	if x == y:
		print(0)
	else:
		(odd, even) = (2, 1)
		if x < y:
			(odd, even) = (even, odd)
			if (y - x) % 4 == 0:
				even += 1
		print(odd if abs(x - y) & 1 else even)


def main():
	cases = int(input())
	for _ in range(cases):
		line = input().split(' ')
		(x, y) = [int(n) for n in line]
		print(solve(x, y))

def solve(x, y):
	if y == x:
		return 0
	if y > x:
		if y % 2 != x % 2:
			return 1
		if (y - x) % 4 != 0:
			return 2
		return 3
	if y % 2 == x % 2:
		return 1
	return 2
main()


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
for _ in range(RI()):
	(x, y) = RMI()
	diff = abs(x - y)
	if x > y:
		if not diff % 2:
			ans = 1
		else:
			ans = 2
	elif x < y:
		if diff % 2:
			ans = 1
		elif not diff % 4:
			ans = 3
		else:
			ans = 2
	else:
		ans = 0
	print(ans)


T = int(input())
for i in range(T):
	a = input()
	b = a.split()
	(X, Y) = (int(b[0]), int(b[1]))
	if X == Y:
		print(0)
	elif X < Y:
		if Y - X & 1 == 0:
			if (Y - X) % 4 == 0:
				print(3)
			else:
				print(2)
		else:
			print(1)
	elif X - Y & 1 == 0:
		print(1)
	else:
		print(2)


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	if y > x:
		if (y - x) % 2 != 0:
			print(1)
		elif (y - x) // 2 % 2 != 0:
			print(2)
		else:
			print(3)
	elif x == y:
		print(0)
	elif (x - y) % 2 == 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(x, y) = [int(i) for i in input().split()]
	diff = abs(x - y)
	if x < y:
		if diff % 2 == 1:
			print(1)
		elif diff % 2 == 0 and diff % 4 == 0:
			print(3)
		else:
			print(2)
	elif x > y:
		if diff % 2 == 0:
			print(1)
		else:
			print(2)
	else:
		print(0)


def solve(x, y):
	if y - x > 0:
		diff = y - x
		if diff % 4 == 0:
			print(3)
			return
		if diff % 2 == 0:
			print(2)
		else:
			print(1)
	elif y - x < 0:
		diff = x - y
		if diff % 2 == 0:
			print(1)
		else:
			print(2)
	else:
		print(0)
t = int(input())
while t:
	(x, y) = map(int, input().split())
	solve(x, y)
	t -= 1


import numpy as np
t = int(input())
for i in range(0, t):
	b = list(map(int, input().split()))
	a = np.array(b)
	x = a[0]
	y = a[1]
	if x == y:
		print(0)
	elif x < y:
		if (y - x) % 2 != 0:
			print(1)
		elif (y - x) % 2 == 0 and (y - x) % 4 == 0:
			print(3)
		else:
			print(2)
	elif x > y:
		if (x - y) % 2 == 0:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	(X, Y) = map(int, input().split())
	if X == Y:
		print(0)
	elif X < Y:
		if (Y - X) % 2 != 0:
			print(1)
		elif (Y - X) % 4 == 0:
			print(3)
		else:
			print(2)
	else:
		print(1 if (X - Y) % 2 == 0 else 2)


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)
for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	if x == y:
		print(0)
	elif x < y:
		if (x - y) % 4 == 0:
			print(3)
		elif x % 2 == y % 2:
			print(2)
		else:
			print(1)
	elif x % 2 == y % 2:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	z = abs(x - y)
	if x > y:
		if z % 2 == 0:
			print(1)
		else:
			print(2)
	elif x < y:
		if z % 2 != 0:
			print(1)
		elif z % 4 == 0:
			print(3)
		else:
			print(2)
	elif x == y:
		print(0)


for testcases in range(int(input())):
	(x, y) = map(int, input('').split())
	z = y - x
	if z == 0:
		print(0)
	elif z > 0:
		if z % 2 == 0:
			z /= 2
			if z % 2 == 0:
				print(3)
			else:
				print(2)
		else:
			print(1)
	elif z % 2 == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if y == x:
		print(0)
	elif y > x and (y - x) % 2 == 1:
		print(1)
	elif y > x and (y - x) % 4 == 0:
		print(3)
	elif y > x and (y - x) % 2 == 0:
		print(2)
	elif y < x and (x - y) % 2 == 0:
		print(1)
	elif y < x and (x - y) % 2 == 1:
		print(2)


n = int(input())
while n:
	(x, y) = map(int, input().split())
	if x == y:
		print(0)
	if y > x:
		if (y - x) % 2 != 0:
			print(1)
		elif (y - x) % 4 == 0:
			print(3)
		else:
			print(2)
	if y < x:
		if (x - y) % 2 != 0:
			print(2)
		else:
			print(1)
	n -= 1


try:
	for t in range(int(input())):
		(x, u) = list(map(int, input().split()))
		if x == u:
			print(0)
		elif u > x:
			if abs(u - x) % 2 == 0:
				if abs(u - x) % 4 == 0:
					print(3)
				else:
					print(2)
			else:
				print(1)
		elif abs(x - u) % 2 != 0:
			print(2)
		else:
			print(1)
except EOFError as e:
	pass


n = int(input())
while n > 0:
	(a, b) = list(map(int, input().split()))
	if b - a == 0:
		print(0)
	elif b - a > 0:
		if (b - a) % 2:
			print(1)
		elif (b - a) % 2 == 0 and (b - a) % 4:
			print(2)
		else:
			print(3)
	elif (b - a) % 2:
		print(2)
	else:
		print(1)
	n -= 1


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	if x > y:
		if abs(x - y) % 2 == 0:
			print(1)
		else:
			print(2)
	elif x < y:
		if abs(x - y) % 2 != 0:
			print(1)
		elif abs(x - y) % 2 == 0 and abs(x - y) % 4 != 0:
			print(2)
		else:
			print(3)
	else:
		print(0)


try:
	test = int(input())
	for i in range(test):
		(x, y) = map(int, input().split())
		z = abs(x - y)
		if x > y:
			if z % 2 == 0:
				print(1)
			else:
				print(2)
		elif x < y:
			if z % 2 != 0:
				print(1)
			elif z % 4 == 0:
				print(3)
			else:
				print(2)
		elif x == y:
			print(0)
except EOFError as e:
	print(e)


import math
for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x > y:
		c = math.fabs(y - x)
		if c % 2 == 1:
			print(2)
		else:
			print(1)
	elif x < y:
		c = math.fabs(y - x)
		if c % 2 == 0 and c % 4 != 0:
			print(2)
		elif c % 2 == 1:
			print(1)
		else:
			print(3)
	else:
		print(0)


import sys
from collections import Counter, defaultdict, deque
from math import gcd, sqrt, ceil

def li():
	return [int(i) for i in sys.stdin.readline().split()]

def si():
	return sys.stdin.readline().split()

def ii():
	return int(sys.stdin.readline())

def ip():
	return input()
for tastcas in range(int(input())):
	(x, y) = li()
	if x == y:
		print(0)
	elif x < y:
		if (y - x) % 2:
			print(1)
		elif (y - x) % 4 == 0:
			print(3)
		else:
			print(2)
	elif (x - y) % 2:
		print(2)
	else:
		print(1)


t = int(input())
for each in range(t):
	(x, y) = map(int, input().split())
	if x > y:
		if (x - y) % 2 == 0:
			print('1')
		else:
			print('2')
	elif x < y:
		if (y - x) % 2 != 0:
			print('1')
		elif (y - x) % 2 == 0 and (y - x) % 4 != 0:
			print('2')
		else:
			print('3')
	else:
		print('0')


def check(x, y, count):
	if x == y:
		print(count)
for i in range(int(input())):
	count = 0
	(x, y) = list(map(int, input().split()))
	diff = x - y
	if diff > 0:
		if diff % 2 == 0:
			x = x - diff
			count += 1
			check(x, y, count)
		else:
			x = x - (diff + 1)
			count += 1
			x = x + 1
			count += 1
			check(x, y, count)
	elif diff == 0:
		print('0')
	else:
		diff = abs(diff)
		if diff % 2 != 0:
			x = x + diff
			count += 1
			check(x, y, count)
		elif diff % 4 == 0:
			x = x + (diff + 1)
			count += 1
			x = x - (diff + 2)
			count += 1
			x = x + (diff + 1)
			count += 1
			check(x, y, count)
		else:
			a = diff / 2
			x = x + a
			count += 1
			x = x + a
			count += 1
			check(x, y, count)


T = int(input(''))
for i in range(T):
	str_in = input('')
	l1 = [int(c) for c in str_in.split(' ')]
	if l1[0] == l1[1]:
		print('0')
	elif l1[1] > l1[0]:
		if (l1[1] - l1[0]) % 2 == 1:
			print('1')
		elif (l1[1] - l1[0]) / 2 % 2 == 1:
			print('2')
		else:
			print('3')
	elif (l1[0] - l1[1]) % 2 == 0:
		print('1')
	else:
		print('2')


t = int(input())
while t:
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]
	if x == y:
		print(0)
		t -= 1
	elif y > x:
		if (y - x) % 2 != 0:
			print(1)
			t -= 1
		elif (y - x) % 2 == 0 and (y - x) % 4 != 0:
			print(2)
			t -= 1
		else:
			print(3)
			t -= 1
	elif (x - y) % 2 == 0:
		print(1)
		t -= 1
	else:
		print(2)
		t -= 1


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	if X == Y:
		print(0)
	elif X > Y:
		if (X - Y) % 2 == 0:
			print(1)
		else:
			print(2)
	elif Y > X:
		if (Y - X) % 2 == 1:
			print(1)
		elif (Y - X) % 2 == 0 and (Y - X) % 4 != 0:
			print(2)
		else:
			print(3)


from sys import stdin, stdout
input = stdin.readline
t = int(input().strip())
for _ in range(t):
	(x, y) = list(map(int, input().strip().split()))
	if y == x:
		print(0)
		continue
	diff = abs(x - y)
	if x < y:
		if diff % 2 != 0:
			ans = 1
		elif diff % 4 != 0:
			ans = 2
		else:
			ans = 3
	elif x > y:
		if diff % 2 != 0:
			ans = 2
		else:
			ans = 1
	print(ans)