You are given two positive integers $a$ and $b$.

In one move, you can change $a$ in the following way:

  Choose any positive odd integer $x$ ($x > 0$) and replace $a$ with $a+x$;  choose any positive even integer $y$ ($y > 0$) and replace $a$ with $a-y$. 

You can perform as many such operations as you want. You can choose the same numbers $x$ and $y$ in different moves.

Your task is to find the minimum number of moves required to obtain $b$ from $a$. It is guaranteed that you can always obtain $b$ from $a$.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

Then $t$ test cases follow. Each test case is given as two space-separated integers $a$ and $b$ ($1 \le a, b \le 10^9$).


-----Output-----

For each test case, print the answer — the minimum number of moves required to obtain $b$ from $a$ if you can perform any number of moves described in the problem statement. It is guaranteed that you can always obtain $b$ from $a$.


-----Example-----
Input
5
2 3
10 10
2 4
7 4
9 3

Output
1
0
2
2
1



-----Note-----

In the first test case, you can just add $1$.

In the second test case, you don't need to do anything.

In the third test case, you can add $1$ two times.

In the fourth test case, you can subtract $4$ and add $1$.

In the fifth test case, you can just subtract $6$.

Difficulty: EASY
Tags: Mathematics

Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def A1311(a, b):
	if a == b:
		return 0
	elif b > a:
		if (a - b) % 2 == 1:
			return 1
		else:
			return 2
	elif (a - b) % 2 == 0:
		return 1
	else:
		return 2
t = int(input())
L = [[0, 0]] * t
for i in range(0, t):
	L[i] = [int(k) for k in input().split()]
for i in range(0, t):
	print(A1311(L[i][0], L[i][1]))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b == a:
		print(0)
	elif b % 2 == a % 2:
		if b < a:
			print(1)
		else:
			print(2)
	elif b < a:
		print(2)
	else:
		print(1)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif a < b and (b - a) % 2 == 1:
		print(1)
	elif a < b and (b - a) % 2 == 0:
		print(2)
	elif a > b and (a - b) % 2 == 1:
		print(2)
	else:
		print(1)


t = int(input())
res = []
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		res.append(0)
	elif a < b:
		if (b - a) % 2 == 0:
			res.append(2)
		else:
			res.append(1)
	elif (a - b) % 2 == 0:
		res.append(1)
	else:
		res.append(2)
for r in res:
	print(r)


def calc(a, b):
	delta = b - a
	cnt = 0
	while delta:
		cnt += 1
		if delta > 0:
			delta = delta if delta % 2 else delta - 1
		else:
			delta = delta - 1 if delta % 2 else delta
		a += delta
		delta = b - a
	return cnt
for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(calc(a, b))


t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	moves = 0
	while a != b:
		if a > b:
			difference = abs(a - b)
			if difference % 2 == 0:
				a -= difference
				moves += 1
			else:
				a -= difference + 1
				moves += 1
		elif a < b:
			difference = abs(a - b)
			if difference % 2 == 1:
				a += difference
				moves += 1
			else:
				a += 1
				moves += 1
	print(moves)


t = int(input())
lst = []
for i in range(t):
	str = input().split(' ')
	a = int(str[0])
	b = int(str[1])
	if a == b:
		lst.append(0)
	elif a > b and (a - b) % 2 == 0:
		lst.append(1)
	elif a < b and (b - a) % 2 == 1:
		lst.append(1)
	else:
		lst.append(2)
for i in lst:
	print(i)


def isEven(num: int):
	return not num % 2

def main():
	test_cases = int(input())
	outputs = []
	for each_case in range(test_cases):
		(a, b) = [int(x) for x in input().split()]
		if b - a == 0:
			outputs.append(0)
		else:
			res = a - b
			if res > 0:
				if isEven(res):
					outputs.append(1)
				else:
					outputs.append(2)
			elif isEven(res):
				outputs.append(2)
			else:
				outputs.append(1)
	for each_output in outputs:
		print(each_output)
main()


t = int(input())
a = []
b = []
for i in range(t):
	xx = input().split()
	a.append(int(xx[0]))
	b.append(int(xx[1]))
for i in range(t):
	dif = a[i] - b[i]
	if dif == 0:
		print(0)
	elif dif > 0:
		if dif % 2 == 1:
			print(2)
		else:
			print(1)
	elif dif % 2 == 1:
		print(1)
	else:
		print(2)


q = int(input())
for _ in range(q):
	(a, b) = map(int, input().split())
	print(2 if a - b & 1 else 1) if a > b else print(0) if not b - a else print(1 if b - a & 1 else 2)


def reach(a, b):
	changes = 0
	if a == b:
		changes = 0
	if a > b:
		if a % 2 == b % 2:
			changes = 1
		else:
			changes = 2
	if a < b:
		if a % 2 == b % 2:
			changes = 2
		else:
			changes = 1
	return changes
testCase = int(input())
CHANGES = []
for i in range(testCase):
	(a, b) = input().split()
	CHANGES.append(reach(int(a), int(b)))
for i in CHANGES:
	print(i)


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


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n == m:
		print(0)
	elif n < m:
		a = m - n
		if a % 2 != 0:
			print(1)
		else:
			print(2)
	elif n > m:
		a = n - m
		if a % 2 == 0:
			print(1)
		else:
			print(2)


t = int(input())
m = 1
while m <= t:
	m += 1
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif a < b:
		if (a + b) % 2 == 0:
			print(2)
		else:
			print(1)
	elif (a + b) % 2 == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if abs(b - a) % 2 == 0:
		print(min(abs(b - a), 1 + (b - a > 0)))
	else:
		print(1 + (a - b > 0))


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(A, B) = [int(x) for x in input().split()]
		if A == B:
			print(0)
		elif A > B:
			if A - B & 1:
				print(2)
			else:
				print(1)
		elif B - A & 1:
			print(1)
		else:
			print(2)
main()


for _ in range(int(input())):
	(a, b) = [int(h) for h in input().split(' ')]
	if a == b:
		print(0)
	elif a < b and (b - a) % 2 == 1 or (a > b and (a - b) % 2 == 0):
		print(1)
	else:
		print(2)


T = int(input())
list1 = [0] * T
for x in range(T):
	(n, p) = map(int, input().split(' '))
	k = p - n
	if n == p:
		list1[x] = 0
	elif k < 0 and k % 2 == 0 or (k > 0 and k % 2 != 0):
		list1[x] = 1
	else:
		list1[x] = 2
for c in range(T):
	print(list1[c])


t = int(input())
for iii in range(t):
	(a, b) = list(map(int, input().split()))
	tmp = b - a
	if tmp == 0:
		print(0)
	elif a < b and tmp % 2 == 1 or (a > b and tmp % 2 == 0):
		print(1)
	else:
		print(2)


num_lines = int(input())
results = []
i = 0
while i < num_lines:
	(a, b) = tuple(input().split(' '))
	a = int(a)
	b = int(b)
	if b < a:
		if (a - b) % 2 != 0:
			results.append(2)
		else:
			results.append(1)
	elif b > a:
		if (a - b) % 2 != 0:
			results.append(1)
		else:
			results.append(2)
	else:
		results.append(0)
	i += 1
i = 0
while i < len(results):
	print(results[i])
	i += 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	while a != b:
		temp = b - a
		if temp > 0 and temp % 2 == 1:
			a += temp
			c += 1
		if temp > 0 and temp % 2 == 0:
			a += temp - 1
			c += 1
		if temp < 0 and temp % 2 == 0:
			a += temp
			c += 1
		if temp < 0 and temp % 2 == 1:
			a += temp - 1
			c += 1
	print(c)


N = int(input())
new = []
for _ in range(N):
	new.append(list(map(int, input().split())))
for i in new:
	t = i[1] - i[0]
	if t == 0:
		print(0)
	elif t > 0:
		if t % 2 == 0:
			print(2)
		else:
			print(1)
	elif t % 2 == 0:
		print(1)
	else:
		print(2)


result = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	move = 0
	if a == b:
		move = 0
	elif a > b:
		if diff % 2 == 0:
			move = 1
		else:
			move = 2
	elif diff % 2 == 1:
		move = 1
	else:
		move = 2
	result.append(move)
print(*result, sep='\n')


import os, sys
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(0)
	elif x < y:
		if x % 2 == 0 and y % 2 == 0:
			print(2)
		elif x % 2 == 0 and y % 2 != 0:
			print(1)
		elif x % 2 != 0 and y % 2 == 0:
			print(1)
		else:
			print(2)
	elif x % 2 == 0 and y % 2 == 0:
		print(1)
	elif x % 2 == 0 and y % 2 != 0:
		print(2)
	elif x % 2 != 0 and y % 2 == 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	c = 0
	if b > a:
		if (b - a) % 2 == 0:
			c = 2
		if (b - a) % 2 == 1:
			c = 1
	else:
		if (b - a) % 2 == 0:
			c = 1
		if (b - a) % 2 == 1:
			c = 2
	if b == a:
		c = 0
	print(c)


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	diff = b - a
	if diff == 0:
		print(0)
	elif diff > 0:
		if diff % 2 != 0:
			print(1)
		else:
			print(2)
	elif diff % 2 != 0:
		print(2)
	else:
		print(1)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
t = getInt()
for i in range(t):
	(a, b) = getVars()
	if a == b:
		print(0)
	elif a > b:
		if a % 2 == b % 2:
			print(1)
		else:
			print(2)
	elif a % 2 == b % 2:
		print(2)
	else:
		print(1)


count = int(input())
counto = 0
while counto < count:
	hamle = 0
	xxxx = input().split()
	first = int(xxxx[0])
	sec = int(xxxx[1])
	if first < sec:
		fark = sec - first
		if fark % 2 != 0:
			hamle += 1
		else:
			hamle += 2
	if first > sec:
		farky = first - sec
		if farky % 2 == 0:
			hamle += 1
		else:
			hamle += 2
	counto += 1
	print(hamle)


def main():
	from sys import stdin, stdout
	for _ in range(int(stdin.readline())):
		(a, b) = map(int, stdin.readline().split())
		if b == a:
			stdout.write('0\n')
		elif b > a:
			if b & 1:
				if a & 1:
					stdout.write('2\n')
				else:
					stdout.write('1\n')
			elif a & 1:
				stdout.write('1\n')
			else:
				stdout.write('2\n')
		elif b & 1:
			if a & 1:
				stdout.write('1\n')
			else:
				stdout.write('2\n')
		elif a & 1:
			stdout.write('2\n')
		else:
			stdout.write('1\n')
main()


n = int(input())
for i in range(n):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	if a == b:
		print('0')
	elif a < b:
		m = b - a
		if m % 2 == 0:
			print('2')
		else:
			print('1')
	else:
		p = a - b
		if p % 2 == 0:
			print('1')
		else:
			print('2')


hold = []
for ___ in range(int(input())):
	moves = 0
	(a, b) = [int(a) for a in input().split()]
	if a == b:
		hold.append(moves)
	if b > a:
		if (b - a) % 2 != 0:
			a += b - a
			moves += 1
			hold.append(moves)
		else:
			moves += 2
			hold.append(moves)
	elif a > b:
		if (a - b) % 2 == 0:
			b -= a
			moves += 1
			hold.append(moves)
		else:
			moves += 2
			hold.append(moves)
for thing in hold:
	print(thing)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	if a > b:
		if a % 2 == 0 and b % 2 == 0:
			print(1)
		if a % 2 == 0 and b % 2 == 1:
			print(2)
		if a % 2 == 1 and b % 2 == 0:
			print(2)
		if a % 2 == 1 and b % 2 == 1:
			print(1)
	if a < b:
		if a % 2 == 0 and b % 2 == 0:
			print(2)
		if a % 2 == 0 and b % 2 == 1:
			print(1)
		if a % 2 == 1 and b % 2 == 0:
			print(1)
		if a % 2 == 1 and b % 2 == 1:
			print(2)


n = int(input())
ans = []
perm = []
for i in range(n):
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	if a == b:
		ans.append(0)
	elif a > b:
		if a % 2 == b % 2:
			ans.append(1)
		else:
			ans.append(2)
	elif a % 2 == b % 2:
		ans.append(2)
	else:
		ans.append(1)
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	ans = 0
	x = [int(i) for i in input().split()]
	a = x[0]
	b = x[1]
	if a == b:
		ans = 0
	p = abs(b - a)
	if b > a:
		if p % 2 != 0:
			ans = 1
		if p % 2 == 0:
			ans = 2
	if a > b:
		if p % 2 == 0:
			ans = 1
		if p % 2 != 0:
			ans = 2
	print(ans)


number = int(input())
i = 0
arr = []
while i < number:
	arr.append(input())
	i += 1
count = 0
for item in arr:
	res = item.split(' ')
	a = int(res[0])
	b = int(res[1])
	if a > b:
		if (a - b) % 2 == 0:
			count = 1
		else:
			count = 2
	elif a == b:
		count = 0
	elif a < b:
		if (b - a) % 2 == 1:
			count = 1
		else:
			count = 2
	print(count)


c = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		if a % 2 == 0 and b % 2 == 0 or (a % 2 == 1 and b % 2 == 1):
			c.append('2')
		if a % 2 == 1 and b % 2 == 0 or (a % 2 == 0 and b % 2 == 1):
			c.append('1')
	if a > b:
		if a % 2 == 0 and b % 2 == 0 or (a % 2 == 1 and b % 2 == 1):
			c.append('1')
		if a % 2 == 1 and b % 2 == 0 or (a % 2 == 0 and b % 2 == 1):
			c.append('2')
	if a == b:
		c.append('0')
for i in c:
	print(i)


t = int(input())
counter = 0
for l in range(t):
	(x, y) = input().split()
	a = int(x)
	b = int(y)
	counter = 0
	even_difference = abs(b - a) % 2 == 0
	odd_difference = abs(b - a) % 2 != 0
	if b == a:
		counter = 0
	elif odd_difference and b > a:
		counter += 1
	elif even_difference and b > a:
		counter += 2
	elif odd_difference and b < a:
		counter += 2
	elif even_difference and b < a:
		counter += 1
	print(counter)


I = input
t = int(I())
y = 0

def solved(a, b):
	if a == b:
		return 0
	m = 0
	while 1:
		m += 1
		if b > a:
			if (b - a) % 2 != 0:
				xy = b - a
				a = a + xy
			else:
				xy = 1
				a = a + xy
		elif (a - b) % 2 == 0:
			xy = a - b
			a = a - xy
		else:
			xy = 1
			a = a + xy
		if a == b:
			return m
sol = []
for i in range(t):
	tx = I().split(' ')
	a = tx[0]
	b = tx[1]
	sol.append(solved(int(a), int(b)))
for s in sol:
	print(s)


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

def si():
	return input()

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

def msi():
	return map(str, input().split())

def li():
	return list(mi())
t = ii()
for _ in range(t):
	(a, b) = mi()
	if b == a:
		print(0)
	elif a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	elif (b - a) % 2 == 1:
		print(1)
	else:
		print(min(2, b - a))


i = int(input())
final = 0
list = []
for i in range(i):
	(num1, num2) = input().split()
	num1 = int(num1)
	num2 = int(num2)
	r = num1 - num2
	if r % 2 == 0:
		if r > 0:
			final = 1
		elif r < 0:
			final = 2
		else:
			final = 0
	elif r > 0:
		final = 2
	elif r < 0:
		final = 1
	list.append(final)
for i in list:
	print(i)


def solve(a, b):
	if a == b:
		return 0
	if b < a:
		if (a - b) % 2 == 0:
			return 1
		else:
			return 2
	elif (b - a) % 2 == 0:
		return 2
	else:
		return 1
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	result = solve(a, b)
	print(result)


n = int(input())
for _ in range(n):
	count = 0
	(a, b) = [int(x) for x in input().split()]
	while a != b:
		if a == b:
			break
		elif a < b:
			c = b - a
			if c % 2 == 1:
				a = a + c
			else:
				a = a + (c - 1)
			count += 1
		else:
			count += 1
			c = a - b
			if c % 2 == 0:
				a = a - c
			else:
				a = a - (c + 1)
	print(count)


test_case = int(input())
for i in range(test_case):
	values = list(map(int, input().split(' ')))
	if values[0] == values[1]:
		print(0)
	elif values[0] < values[1]:
		if abs(values[0] - values[1]) % 2 == 1:
			print(1)
		else:
			print(2)
	elif abs(values[0] - values[1]) % 2 == 1:
		print(2)
	else:
		print(1)


n = int(input())
answers = []
for i in range(n):
	moves = 0
	t = input().split()
	t = [int(j) for j in t]
	(a, b) = (t[0], t[1])
	if a == b:
		moves = 0
	elif a < b:
		if (b - a) % 2 == 1:
			moves += 1
		else:
			moves += 2
	elif (b - a) % 2 == 0:
		moves += 1
	else:
		moves += 2
	answers.insert(i, moves)
for i in answers:
	print(i)


cases = int(input())
case = []
for i in range(cases):
	case.append(input())
for i in case:
	things = [int(x) for x in i.split(' ')]
	the_difference = things[1] - things[0]
	if the_difference < 0:
		if abs(the_difference) % 2 == 0:
			print(1)
		else:
			print(2)
	elif the_difference > 0:
		if abs(the_difference) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		print(0)


import sys, math
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
T = int(wtf[0])
assert T >= 1 and T <= int(10000.0), 'Precondition failure'
for t in wtf[1:]:
	(a, b) = map(int, t.split())
	ans = 0
	c = b - a
	if c > 0:
		if c % 2 > 0:
			ans += 1
		else:
			ans += 2
	elif c < 0:
		if c % 2 == 0:
			ans += 1
		else:
			ans += 2
	print(ans)


from sys import stdin
N = int(stdin.readline().rstrip())
for i in range(N):
	(a, b) = [int(x) for x in stdin.readline().rstrip().split()]
	if b - a == 0:
		print(0)
	elif b - a < 0:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	elif (b - a) % 2 == 0:
		print(2)
	else:
		print(1)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 5)

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

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def solve():
	(a, b) = MI()
	if a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	elif a == b:
		print(0)
	elif (b - a) % 2 == 0:
		print(2)
	else:
		print(1)
for _ in range(II()):
	solve()


t = int(input())
if 1 <= t <= 10 ** 4:
	for i in range(t):
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		if a == b:
			print(0)
		elif b > a:
			c = b - a
			c = int(c)
			if c % 2 != 0:
				print(1)
			else:
				print(2)
		elif a > b:
			c = a - b
			c = int(c)
			if c % 2 == 0:
				print(1)
			else:
				print(2)


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	result = b - a
	mod = result % 2
	if result > 0:
		if mod == 0:
			print(2)
		else:
			print(1)
	elif result < 0:
		if mod == 0:
			print(1)
		else:
			print(2)
	else:
		print(0)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(a, b) = MAP()
	if a == b:
		print(0)
	elif a < b:
		if abs(a - b) % 2 == 0:
			print(2)
		else:
			print(1)
	elif abs(a - b) % 2 == 0:
		print(1)
	else:
		print(2)


for _ in [0] * int(input()):
	(a, b) = map(int, input().split())
	b -= a
	print(b and ((b < 0) & b | (b > 0) & ~b) + 1)


try:
	t = int(input())
	for i in range(t):
		x = list(map(int, input().split()))
		a = x[0]
		b = x[1]
		c = 0
		if a == b:
			print(0)
		if a < b:
			c = b - a
			if (b - a) % 2 == 0:
				print(2)
			else:
				print(1)
		if a > b:
			c = a - b
			if (a - b) % 2 == 0:
				print(1)
			else:
				print(2)
except:
	pass


t = int(input(''))
count = 0
while count < t:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if b > a:
		if (b - a) % 2 != 0:
			print('1\n')
		else:
			print('2\n')
	elif b < a:
		if (b - a) % 2 != 0:
			print('2\n')
		else:
			print('1\n')
	else:
		print('0')
	count = count + 1


c = int(input())
for x in range(c):
	(a, b) = map(int, input().split())
	if b > a:
		if (b - a) % 2 == 0:
			print(2)
		else:
			print(1)
	if a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	if a == b:
		print(0)


t = int(input())
for i in range(t):
	line = input()
	[a, b] = [int(x) for x in line.split(' ')]
	if a == b:
		print(0)
	if a > b:
		if a % 2 == b % 2:
			print(1)
		else:
			print(2)
	elif a < b:
		if a % 2 == b % 2:
			print(2)
		else:
			print(1)


def solve(a, b):
	if a == b:
		return 0
	if a % 2 == b % 2 and a > b:
		return 1
	if a % 2 != b % 2 and a < b:
		return 1
	return 2
t = int(input())
for tt in range(t):
	(a, b) = list(map(int, input().split()))
	print(solve(a, b))


ans = []
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = abs(a - b)
	if x:
		add_odd = a < b and x % 2
		subeven = a > b and x % 2 == 0
		if add_odd or subeven:
			ans += ['1']
		else:
			ans += ['2']
	else:
		ans += ['0']
print('\n'.join(ans))


t = int(input())
answers = []
for ti in range(t):
	(a, b) = list(map(int, input().split()))
	if a == b:
		answers.append(0)
	elif a < b:
		if (b - a) % 2 == 1:
			answers.append(1)
		else:
			answers.append(2)
	elif (a - b) % 2 == 0:
		answers.append(1)
	else:
		answers.append(2)
for a in answers:
	print(a)


def check(a, b):
	if b > a:
		if (b - a) % 2 == 0:
			return 2
		else:
			return 1
	if a > b:
		if (a - b) % 2 == 0:
			return 1
		else:
			return 2
	if a == b:
		return 0
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(check(a, b))


import sys
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		if a == b:
			print(0)
			continue
		if a < b:
			if a % 2 == b % 2:
				print(2)
			else:
				print(1)
		elif a % 2 == b % 2:
			print(1)
		else:
			print(2)
main()


p = []
n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	(a, b) = (l[0], l[1])
	k = a - b
	k1 = k % 2
	if k == 0:
		p.append(0)
	elif k > 0:
		if k1 == 1:
			p.append(2)
		else:
			p.append(1)
	elif k1 == 0:
		p.append(2)
	else:
		p.append(1)
for j in p:
	print(j)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(a, b) = map(int, sys.stdin.readline().split(' '))
	if a == b:
		print(0)
	elif a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	elif (a - b) % 2:
		print(1)
	else:
		print(2)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


(a, d) = (int(input()), [])
for i in range(0, a):
	b = [int(i) for i in input().split(' ')]
	k = b[0] - b[1]
	d.append((k < 0 and k % 2 == 1) + (k < 0 and k % 2 == 0) * 2 + (k > 0 and k % 2 == 1) * 2 + (k > 0 and k % 2 == 0))
print(*d, sep='\n')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	moves = 0
	while a != b:
		if a > b:
			x = a - b
			if x % 2 == 0:
				moves = 1
				a = b
			else:
				moves = 2
				a = b
		else:
			x = b - a
			if x % 2 != 0:
				moves = 1
				a = b
			else:
				moves = 2
				a = b
	print(moves)


cases = int(input())
for number in range(cases):
	case = list(map(int, input().strip().split()))
	(a, b) = case
	flag = 2
	temp = 0
	if a < b:
		flag = 0
	if a > b:
		flag = 1
	if flag == 1:
		d = a - b
		if d % 2 == 0:
			temp = 1
		else:
			temp = 2
	elif flag == 0:
		d = b - a
		if d % 2 == 0:
			temp = 2
		else:
			temp = 1
	print(temp)


n = int(input())
for i in range(n):
	(m, k) = map(int, input().split())
	t = abs(m - k)
	if m < k:
		if t % 2 == 0:
			print(2)
		else:
			print(1)
	elif m > k:
		if t % 2 == 0:
			print(1)
		else:
			print(2)
	else:
		print(0)


t = int(input())
k = 0
j = 0
for i in range(t):
	c = 0
	(m, n) = [int(elem) for elem in input().split()]
	while n != m:
		d = n - m
		if d > 0:
			if d % 2 == 0:
				k = d - 1
			else:
				k = d
			m += k
			c += 1
		else:
			if d % 2 != 0:
				j = d - 1
			else:
				j = d
			m += j
			c += 1
	print(c)


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

def solve():
	(a, b) = getarr()
	if a == b:
		print(0)
	if a < b:
		diff = abs(a - b)
		if diff % 2 == 1:
			print(1)
		else:
			print(2)
	if a > b:
		diff = abs(a - b)
		if diff % 2 == 0:
			print(1)
		else:
			print(2)
for t in range(int(input())):
	solve()


n = int(input())
no_of_lines = n
lines = ''
for i in range(no_of_lines):
	lines += input() + '\n'
templines = lines.split('\n')
temparr = [list(map(int, templines[i].split(' '))) for i in range(n)]
for i in range(no_of_lines):
	x = temparr[i][0]
	y = temparr[i][1]
	if x == y:
		print('0')
	if y - x > 0:
		if (y - x) % 2 == 0:
			print('2')
		else:
			print('1')
	if y - x < 0:
		if (y - x) % 2 == 0:
			print('1')
		else:
			print('2')


def solve():
	(a, b) = list(map(int, input().strip().split()))
	if a == b:
		print(0)
	elif a > b:
		if (a - b) % 2 == 1:
			print(2)
			pass
		else:
			print(1)
			pass
		pass
	else:
		if (b - a) % 2 == 1:
			print(1)
			pass
		else:
			print(2)
			pass
		pass

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


number = int(input())
c = 0
for i in range(number):
	(a, b) = [int(i) for i in input().split()]
	if a == b:
		print(0)
	elif a > b:
		c = a - b
		if c % 2 == 1:
			print(2)
		else:
			print(1)
	else:
		c = b - a
		if c % 2 == 1:
			print(1)
		else:
			print(2)


def checker(a, b):
	d = abs(a - b)
	if d == 0:
		return 0
	elif b - a > 0:
		if d % 2 != 0:
			return 1
		else:
			return 2
	elif b - a < 0:
		if d % 2 != 0:
			return 2
		else:
			return 1
for _ in range(int(input())):
	(A, B) = [int(i) for i in input().split()]
	print(checker(A, B))


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	(a, b) = read_int_line()
	if a == b:
		print(0)
	elif a < b:
		if a % 2 == 0 and b % 2 == 0:
			print(2)
		elif a % 2 == 0 and b % 2 != 0:
			print(1)
		elif a % 2 != 0 and b % 2 == 0:
			print(1)
		elif a % 2 != 0 and b % 2 != 0:
			print(2)
	elif a % 2 == 0 and b % 2 == 0:
		print(1)
	elif a % 2 == 0 and b % 2 != 0:
		print(2)
	elif a % 2 != 0 and b % 2 == 0:
		print(2)
	elif a % 2 != 0 and b % 2 != 0:
		print(1)


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	for i in range(int(_input())):
		(a, b) = [int(i) for i in _input().split()]
		if a == b:
			print(0)
		elif a % 2 == 0:
			if b % 2 == 0 and a > b:
				print(1)
			elif b % 2 == 1 and a < b:
				print(1)
			else:
				print(2)
		elif b % 2 == 1 and a > b:
			print(1)
		elif b % 2 == 0 and a < b:
			print(1)
		else:
			print(2)
solution()


import sys
import math
import bisect

def solve(a, b):
	if b == a:
		return 0
	if b > a:
		if (b - a) % 2 == 1:
			return 1
		else:
			return 2
	elif (a - b) % 2 == 0:
		return 1
	else:
		return 2

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		print(solve(a, b))
main()


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


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	diff = b - a
	if diff == 0:
		print('0')
	elif diff > 0:
		r = int(diff % 2)
		if r != 0:
			print('1')
		else:
			print('2')
	else:
		r = int(abs(diff) % 2)
		if r == 0:
			print('1')
		else:
			print('2')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput

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

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(a, b) = mi()
	if a == b:
		print(0)
	elif a < b and (b - a) % 2 == 0 or (a > b and (a - b) % 2):
		print(2)
	else:
		print(1)


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


import sys

def fast_input():
	return sys.stdin.readline().strip()

def data_input():
	return [int(x) for x in fast_input().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def solve_of_problem():
	(a, b) = data_input()
	if (b - a) % 2 == 1 and a < b:
		print(1)
	elif (b - a) % 2 == 0 and b < a:
		print(1)
	elif a == b:
		print(0)
	else:
		print(2)
	return
for ______ in range(int(fast_input())):
	solve_of_problem()


def moves(a, b):
	if a == b:
		return 0
	if b - a > 0:
		if (b - a) % 2 == 0:
			return 2
		else:
			return 1
	elif abs(b - a) % 2 == 0:
		return 1
	else:
		return 2
testcases = int(input())
for i in range(1, testcases + 1):
	data = tuple(map(int, input().split()))
	print(moves(data[0], data[1]))


for ttt in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif a < b:
		if a % 2 != b % 2:
			print(1)
		elif a % 2 == 0 and b % 2 == 0:
			print(2)
		elif a % 2 != 0 and b % 2 != 0:
			print(2)
	elif a % 2 != 0 and b % 2 != 0:
		print(1)
	elif a % 2 != b % 2:
		print(2)
	elif a % 2 == 0 and b % 2 == 0:
		print(1)


tst = int(input())
vals = []
for i in range(0, tst):
	arr = (a, b) = [int(x) for x in input().split()]
	vals.append(arr)
for lst in vals:
	a = lst[0]
	b = lst[1]
	if a == b:
		print(0)
	elif a > b and (a - b) % 2 == 0:
		print(1)
	elif a < b and (b - a) % 2 != 0:
		print(1)
	else:
		print(2)


for i in [*open(0)][1:]:
	(a, b) = map(int, i.split())
	c = abs(a - b)
	if c == 0:
		print(0)
	elif a > b:
		print(1 * (c & 1 == 0) or 2)
	elif c & 1 > 0:
		print(1)
	else:
		print(2)


n = int(input())
for i in range(n):
	(a, b) = [int(j) for j in input().split()]
	if a == b:
		print(0)
	elif a < b and (a - b) % 2 == 0:
		print(2)
	elif a > b and (b - a) % 2 == 1:
		print(2)
	else:
		print(1)


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


n = int(input())
c = []
for i in range(n):
	(a, b) = map(int, input().split())
	if b > a:
		if (b - a) % 2 == 0:
			c.append(2)
		else:
			c.append(1)
	elif b == a:
		c.append(0)
	elif (a - b) % 2 == 0:
		c.append(1)
	else:
		c.append(2)
for i in range(n):
	print(c[i])


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 998244353
for _ in range(int(ri())):
	(a, b) = Ri()
	if a == b:
		print(0)
	elif a < b:
		if (b - a) % 2 == 0:
			print(2)
		else:
			print(1)
	elif (b - a) % 2 == 1:
		print(2)
	else:
		print(1)


for i in range(int(input())):
	a = list(map(int, input().split()))
	if a[0] - a[1] == 0:
		print('0')
	elif a[0] > a[1]:
		if (a[0] - a[1]) % 2 == 0:
			print('1')
		elif (a[0] - a[1]) % 2 != 0:
			print('2')
	elif a[1] > a[0]:
		if (a[1] - a[0]) % 2 == 0:
			print('2')
		elif (a[1] - a[0]) % 2 != 0:
			print('1')


import math
n = int(input())
for t in range(n):
	a = list(map(int, input().split()))
	if a[0] == a[1]:
		print(0)
	elif a[0] <= a[1]:
		aux = abs(a[0] - a[1])
		if aux % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		aux = abs(a[0] - a[1])
		if aux % 2 == 0:
			print(1)
		else:
			print(2)


import sys
t = int(sys.stdin.readline())
for i in range(t):
	line = sys.stdin.readline().split()
	(a, b) = (int(line[0]), int(line[1]))
	if a == b:
		print(0)
	elif a < b:
		if (b - a) % 2 == 0:
			print(2)
		else:
			print(1)
	elif (a - b) % 2 == 0:
		print(1)
	else:
		print(2)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def DFS(root, g, vis, ans):
	vis[root] = 1
	for c in g[root]:
		if vis[c] == 0:
			ans.append(c)
			DFS(c, g, vis, ans)
MOD = 1000000007
PMOD = 998244353
T = 1
T = int(stdin.readline())
for _ in range(T):
	(a, b) = list(map(int, stdin.readline().rstrip().split()))
	if a == b:
		print(0)
		continue
	if a > b and (a - b) % 2 == 0 or (a < b and (b - a) % 2 == 1):
		print(1)
	else:
		print(2)


def solve():
	(a, b) = map(int, input().split())
	if a == b:
		return 0
	if a < b and (b - a) % 2 == 1:
		return 1
	if a > b and (a - b) % 2 == 0:
		return 1
	return 2

def main():
	t = int(input())
	for _ in range(t):
		print(solve())
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	aEven = a % 2 == 0
	bEven = b % 2 == 0
	if a < b:
		if aEven and bEven or (not aEven and (not bEven)):
			print(2)
		else:
			print(1)
	elif aEven and bEven or (not aEven and (not bEven)):
		print(1)
	else:
		print(2)


t = int(input())
out = []
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	count = 0
	while a != b:
		if b > a and (b - a) % 2 != 0:
			count += 1
			break
		elif b > a and (b - a) % 2 == 0:
			count += 1
			a += b - a - 1
		elif b < a and (a - b) % 2 == 0:
			count += 1
			break
		else:
			count += 1
			a -= a - b + 1
	out.append(count)
for i in out:
	print(i)


import sys
for _ in range(int(sys.stdin.readline().rstrip())):
	(a, b) = list(map(int, sys.stdin.readline().rstrip().split()))
	if a == b:
		print('0')
	elif a < b:
		if (b - a) % 2 == 1:
			print('1')
		else:
			print('2')
	elif (a - b) % 2 == 1:
		print('2')
	else:
		print('1')


t = int(input())
for _ in range(t):
	ans = 0
	(a, b) = map(int, input().split())
	if a == b:
		ans = 0
	elif a < b:
		if a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0):
			ans = 2
		elif a % 2 != 0 and b % 2 == 0 or (a % 2 == 0 and b % 2 != 0):
			ans = 1
	elif a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0):
		ans = 1
	elif a % 2 != 0 and b % 2 == 0 or (a % 2 == 0 and b % 2 != 0):
		ans = 2
	print(ans)


n = int(input())
a = []
for i in range(n):
	a.append(list(input().split()))
for i in range(n):
	m = 0
	x = int(a[i][0]) - int(a[i][1])
	if x > 0:
		if x % 2 == 0:
			print('1')
		else:
			print('2')
	elif x < 0:
		if x % 2 == 0:
			print('2')
		else:
			print('1')
	else:
		print('0')


t = int(input())
for case in range(t):
	(a, b) = list(map(int, input().split()))
	if b == a:
		print(0)
	elif b > a:
		if b % 2 == a % 2:
			print(2)
		else:
			print(1)
	elif b % 2 == a % 2:
		print(1)
	else:
		print(2)


test = int(input())
while test != 0:
	test -= 1
	(a, b) = map(int, input().split())
	if a < b:
		summ = b - a
		if summ % 2 == 0:
			print(2)
		else:
			print(1)
	elif a > b:
		summ = a - b
		if summ % 2 == 0:
			print(1)
		else:
			print(2)
	else:
		print(0)


n = int(input())
for i in range(n):
	m = list(map(int, input().split()))
	x = m[0] - m[1]
	if x > 0:
		if x % 2 == 0:
			print(1)
		else:
			print(2)
	if x < 0:
		if x % 2 == 0:
			print(2)
		else:
			print(1)
	if x == 0:
		print(0)


t = int(input())
for p in range(0, t):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif a < b:
		if (b - a) % 2 != 0:
			print(1)
		else:
			print(2)
	else:
		m = a - b
		if m % 2 == 0:
			print(1)
		else:
			print(2)


T = int(input())
for _ in range(T):
	(a, b) = [int(x) for x in input().split()]
	if a == b:
		print(0)
	elif a > b and (a + b) % 2 == 0:
		print(1)
	elif a < b and (a + b) % 2 == 1:
		print(1)
	else:
		print(2)


n = int(input())
for x in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	elif b > a and a % 2 == 0 and (b % 2 == 0):
		print(2)
	elif b > a and a % 2 == 0 and (b % 2 == 1):
		print(1)
	elif b > a and a % 2 == 1 and (b % 2 == 1):
		print(2)
	elif b > a and a % 2 == 1 and (b % 2 == 0):
		print(1)
	elif a > b and a % 2 == 0 and (b % 2 == 0):
		print(1)
	elif a > b and a % 2 == 1 and (b % 2 == 0):
		print(2)
	elif a > b and a % 2 == 1 and (b % 2 == 1):
		print(1)
	elif a > b and a % 2 == 0 and (b % 2 == 1):
		print(2)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	ans = 0
	d = b - a
	rem = d % 2
	if d > 0:
		ans += 1
		if not rem:
			ans += 1
	elif d < 0:
		ans += 1
		if rem:
			ans += 1
	print(ans)


t = int(input())
while t > 0:
	(a, b) = [int(x) for x in input().split()]
	if a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	elif a < b:
		if (b - a) % 2 == 1:
			print(1)
		else:
			print(2)
	else:
		print(0)
	t -= 1


import sys
s = int(sys.stdin.readline().split()[0])
for i in range(s):
	num = [int(i) for i in sys.stdin.readline().split()]
	(a, b) = (num[0], num[1])
	if a == b:
		print(0)
	elif a > b and (a - b) % 2 == 0:
		print(1)
	elif b > a and (b - a) % 2 != 0:
		print(1)
	else:
		print(2)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	if a > b:
		d = a - b
		if d % 2 == 0:
			print(1)
		else:
			print(2)
	if a < b:
		d = b - a
		if d % 2 == 0:
			print(2)
		else:
			print(1)


sol = []
n = int(input())

def solve(m, n):
	if m == n:
		return 0
	elif m % 2 == n % 2 and m > n or (m % 2 != n % 2 and m < n):
		return 1
	else:
		return 2
for i in range(n):
	l = list(map(int, input().split()))
	(m, n) = (l[0], l[1])
	sol.append(solve(m, n))
for i in sol:
	print(i)


t = int(input())
for i in range(t):
	ab = tuple(map(int, input().split()))
	if ab[0] == ab[1]:
		print(0)
	else:
		diff = ab[0] - ab[1]
		if diff < 0 and diff % 2 != 0 or (diff > 0 and diff % 2 == 0):
			print(1)
		else:
			print(2)


n = int(input())
while n:
	(a, b) = map(int, input().split())
	dif = int(b - a)
	if dif == 0:
		print('0')
	elif dif > 0 and dif % 2 != 0:
		print('1\n')
	elif dif < 0 and -1 * dif % 2 == 0:
		print('1\n')
	else:
		print('2')
	n = n - 1


move = 0
arr = []
t = int(input())
for t in range(0, t):
	(a, b) = map(int, input().split())
	arr.append(a)
	arr.append(b)
for i in range(0, t + 1):
	a = arr[2 * i]
	b = arr[2 * i + 1]
	if a == b:
		print(0)
	elif a < b:
		if (b - a) % 2 == 0:
			move = 2
			print(move)
		else:
			move = 1
			print(move)
	elif a > b:
		if (a - b) % 2 == 0:
			move = 1
			print(move)
		else:
			move = 2
			print(move)


def f(x, y):
	if x == y:
		return 0
	if x > y:
		if (x - y) % 2 == 0:
			return 1
		else:
			return 2
	elif (y - x) % 2 == 1:
		return 1
	else:
		return 2
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	print(f(n, k))


for _ in [*open(0)][1:]:
	(a, b) = map(int, _.split())
	if a == b:
		print(0)
	elif a < b:
		print(2 - (a - b) % 2)
	else:
		print(1 + (a - b) % 2)


numbertests = int(input())
l = []
for i in range(numbertests):
	temp = []
	temp = [int(i) for i in input().split()]
	l = l + temp
itr = int(len(l) / 2)
for i in range(itr):
	if l[2 * i + 1] == l[2 * i]:
		print(0)
	elif l[2 * i + 1] > l[2 * i]:
		diff = l[2 * i + 1] - l[2 * i]
		if diff % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		diff = l[2 * i] - l[2 * i + 1]
		if diff % 2 == 0:
			print(1)
		else:
			print(2)
	print()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	m = 0
	if a > b:
		x = abs(a - b)
		if x % 2 != 0:
			m += 2
		else:
			m += 1
	elif a < b:
		x = abs(a - b)
		if x % 2 == 0:
			m += 2
		else:
			m += 1
	print(m)


def addOrSub(a, b):
	return 1 + ((a < b) ^ (a + b) % 2) if a != b else 0
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(addOrSub(n, k))


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


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	h = -1
	while a != b:
		if a > b:
			d = a - b
			if d % 2 == 0:
				print('1')
				h = 1
				break
			else:
				print('2')
				h = 1
				break
		else:
			d = b - a
			if d % 2 != 0:
				print('1')
				h = 1
				break
			else:
				print('2')
				h = 1
				break
	if h == -1:
		print('0')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	k = 0
	if a == b:
		k = 0
	elif a - b > 0 and (a - b) % 2 == 1 or (b - a > 0 and (a - b) % 2 == 0):
		k = 2
	else:
		k = 1
	print(k)


def main():
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(0)
	elif a > b:
		if (b - a) % 2 == 0:
			print(1)
		else:
			print(2)
	elif (b - a) % 2 == 0:
		print(2)
	else:
		print(1)

def __starting_point():
	t = int(input())
	for i in range(t):
		main()
__starting_point()


a = int(input())
for i in range(0, a):
	(n, m) = map(int, input().split())
	if n < m and int(m - n) % 2 == 1:
		print(1)
	elif n > m and int(n - m) % 2 == 1:
		print(2)
	elif n > m and int(n - m) % 2 == 0:
		print(1)
	elif int(m - n) % 2 == 0 and (not m == n):
		print(2)
	elif m == n:
		print(0)


n = int(input())
cases = [map(int, input().split()) for _ in range(n)]

def even(n):
	if n % 2 == 0:
		return True
	return False
for case in cases:
	(a, b) = case
	dif = abs(a - b)
	if a == b:
		print(0)
	elif even(dif):
		if a > b:
			print(1)
		else:
			print(2)
	elif a > b:
		print(2)
	else:
		print(1)


x = int(input())
list_2 = []
for i in range(0, x):
	l = input()
	list_1 = list(map(int, l.split(' ')))
	a = list_1[0]
	b = list_1[1]
	if a < b and a % 2 == 0 and (b % 2 == 0):
		list_2.append(2)
	elif a < b and a % 2 == 1 and (b % 2 == 1):
		list_2.append(2)
	elif a < b and a % 2 == 0 and (b % 2 == 1):
		list_2.append(1)
	elif a < b and a % 2 == 1 and (b % 2 == 0):
		list_2.append(1)
	elif a > b and a % 2 == 0 and (b % 2 == 0):
		list_2.append(1)
	elif a > b and a % 2 == 1 and (b % 2 == 0):
		list_2.append(2)
	elif a > b and a % 2 == 0 and (b % 2 == 1):
		list_2.append(2)
	elif a > b and a % 2 == 1 and (b % 2 == 1):
		list_2.append(1)
	elif a == b:
		list_2.append(0)
for i in list_2:
	print(i)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	diff = abs(a - b)
	if a < b:
		if diff % 2 == 0:
			print(2)
		elif diff % 2 == 1:
			print(1)
	elif a > b:
		if diff % 2 == 0:
			print(1)
		if diff % 2 == 1:
			print(2)


li = []
test = int(input())
for i in range(test):
	li = list(map(int, input().split()))
	if li[0] > li[1]:
		if (li[0] - li[1]) % 2 == 0:
			print('1')
		else:
			print('2')
	elif li[0] < li[1]:
		if (li[1] - li[0]) % 2 == 1:
			print('1')
		else:
			print('2')
	else:
		print('0')


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		(A, B) = map(int, input().split())
		if A < B:
			if (B - A) % 2:
				ans = 1
			else:
				ans = 2
		elif A > B:
			if (A - B) % 2:
				ans = 2
			else:
				ans = 1
		else:
			ans = 0
		print(ans)
main()


def solve():
	(a, b) = [int(i) for i in input().split()]
	if a == b:
		return 0
	if a > b:
		if a % 2 == b % 2:
			return 1
		return 2
	else:
		if a % 2 == b % 2:
			return 2
		return 1
t = int(input())
ans = []
while t:
	ans.append(str(solve()))
	t -= 1
print('\n'.join(ans))


t = int(input())
for i in range(0, t, 1):
	(a, b) = tuple(map(int, input().split()))
	if a < b:
		c = b - a
		if c % 2 == 1:
			v = 1
		else:
			v = 2
	elif a > b:
		c = a - b
		if c % 2 == 0:
			v = 1
		else:
			v = 2
	elif a == b:
		v = 0
	print(v)


t = int(input())

def solve(a, b):
	if b == a:
		return 0
	if b > a:
		if (b - a) % 2 == 1:
			return 1
		else:
			return 2
	if b < a:
		if (a - b) % 2 == 1:
			return 2
		else:
			return 1
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	print(solve(a, b))


case = int(input())
resposta = []
for l in range(case):
	(a, b) = map(int, input().split())
	if a > b:
		sub = a - b
		if sub % 2 == 1:
			resposta.append(2)
		else:
			resposta.append(1)
	elif a < b:
		sub = b - a
		if sub % 2 == 1:
			resposta.append(1)
		else:
			resposta.append(2)
	else:
		resposta.append(0)
for i in resposta:
	print(i)


for i in range(int(input())):
	ls = list(map(int, input().split()))
	a = ls[0]
	b = ls[1]
	res = abs(a - b)
	if a - b == 0:
		print('0')
	elif a > b and res % 2 == 0:
		print('1')
	elif b > a and res % 2 == 1:
		print('1')
	else:
		print('2')


for nt in range(int(input())):
	(a, b) = map(int, input().split())
	if b == a:
		print(0)
		continue
	if b > a:
		if (b - a) % 2 == 1:
			print(1)
			continue
		else:
			print(2)
			continue
	elif (a - b) % 2 == 0:
		print(1)
		continue
	else:
		print(2)


t = int(input())
arr = []
for i in range(t):
	arr.append(list(map(int, input().split())))

def solve(i):
	(a, b) = (i[0], i[1])
	if a > b:
		if (a - b) % 2 == 0:
			return 1
		else:
			return 2
	elif a < b:
		if (b - a) % 2 != 0:
			return 1
		else:
			return 2
	return 0
for i in arr:
	print(solve(i))


t = int(input())
s = ''
for i in range(t):
	c = 0
	(a, b) = map(int, input().split())
	if a < b:
		if (b - a) % 2 == 0:
			c = 2
		else:
			c = 1
	if a > b:
		if (a - b) % 2 != 0:
			c = 2
		else:
			c = 1
	s += str(c) + ' '
print(s.replace(' ', '\n'))


from sys import stdin, stdout
for jkl in range(int(stdin.readline())):
	num = [int(x) for x in stdin.readline().split()]
	if num[0] == num[1]:
		print(0)
	elif num[1] > num[0]:
		if (num[1] - num[0]) % 2 == 1:
			print(1)
		else:
			print(2)
	elif num[1] < num[0]:
		if (num[1] - num[0]) % 2 == 0:
			print(1)
		else:
			print(2)


def main():
	t = int(input())
	cases = []
	for i in range(t):
		cases.append(map(int, input().split()))
	for case in cases:
		(a, b) = case
		if a == b:
			print(0)
		elif a > b and (a - b) % 2 == 0 or (a < b and (b - a) % 2 != 0):
			print(1)
		else:
			print(2)
main()


q = int(input())
for wrere in range(q):
	(a, b) = map(int, input().split())
	if a < b:
		if (a - b) % 2 == 1:
			print(1)
		else:
			print(2)
	elif a == b:
		print(0)
	elif (a - b) % 2 == 0:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	result = b - a
	answer = 2
	if result > 0 and result % 2 != 0:
		answer = 1
	elif result < 0 and result % 2 == 0:
		answer = 1
	elif result == 0:
		answer = 0
	print(answer)


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


n = int(input())
while n > 0:
	(a, b) = map(int, input().split())
	if a == b:
		g = 0
		print(g)
	if a < b:
		s = b - a
		if s % 2 == 1:
			print('1')
		else:
			print('2')
	if a > b:
		s = a - b
		if s % 2 == 0:
			print('1')
		else:
			print('2')
	n = n - 1


def main():
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		val = b - a
		if val == 0:
			print(0)
		elif val > 0:
			if val % 2 != 0:
				print(1)
			else:
				print(2)
		elif val % 2 == 0:
			print(1)
		else:
			print(2)
main()


def function():
	n = int(input())
	res = []
	for _ in range(n):
		(a, b) = map(int, input().split())
		if a == b:
			res.append(0)
			continue
		diff = a - b
		if diff > 0 and diff % 2 != 0 and (a < b):
			res.append(1)
		elif diff < 0 and diff * -1 % 2 != 0:
			res.append(1)
		elif diff > 0 and diff % 2 == 0:
			res.append(1)
		else:
			res.append(2)
	return res
for e in function():
	print(e)


t = int(input().strip())
result = []
for i in range(t):
	x = input().strip().split()
	a = int(x[0])
	b = int(x[1])
	if a == b:
		result.append(0)
	elif a < b:
		if (b - a) % 2 == 1:
			result.append(1)
		else:
			result.append(2)
	elif (a - b) % 2 == 0:
		result.append(1)
	else:
		result.append(2)
for i in result:
	print(i)


def solve(a, b):
	diff = abs(a - b)
	if a > b:
		return 1 if diff % 2 == 0 else 2
	elif a < b:
		return 2 if diff % 2 == 0 else 1
	return 0
t = int(input())
for x in range(t):
	(a, b) = map(int, input().split(' '))
	print(solve(a, b))


m = int(input())
for i in range(0, m):
	(a, b) = map(int, input().split())
	if a == b:
		print('0')
	c = abs(a - b)
	if a < b:
		if c % 2 != 0:
			print('1')
		else:
			print('2')
	if a > b:
		if c % 2 == 0:
			print('1')
		else:
			print('2')


def solve(a, b, ans):
	if a == b:
		ans.append(0)
	elif a < b:
		diff = b - a
		if diff % 2 == 0:
			ans.append(2)
		else:
			ans.append(1)
	else:
		diff = a - b
		if diff % 2 != 0:
			ans.append(2)
		else:
			ans.append(1)

def main():
	ans = []
	t = int(input())
	for i in range(t):
		(a, b) = map(int, input().split())
		solve(a, b, ans)
	for i in ans:
		print(i)
main()


def func(n):
	for _ in range(n):
		(a, b) = map(int, input().split())
		k = 0
		if a != b:
			if a > b:
				c = a - b
				if c % 2 == 0:
					k += 1
					k_list.append(k)
				else:
					k += 2
					k_list.append(k)
			elif a < b:
				c = b - a
				if c % 2 == 0:
					k += 2
					k_list.append(k)
				else:
					k += 1
					k_list.append(k)
		else:
			k += 0
			k_list.append(k)
	[print(i) for i in k_list]
k_list = []
func(int(input()))


import math
import sys
from sys import *
from bisect import insort
import heapq
import collections
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_list.append(i)
	return final_list % mod

def solve():
	(a, b) = map(int, input().split())
	if a == b:
		return 0
	if a < b:
		if (b - a) % 2 == 1:
			return 1
		return 2
	else:
		if (a - b) % 2 == 0:
			return 1
		return 2
t = int(stdin.readline())
for i in range(t):
	result = solve()
	stdout.write(str(result) + '\n')


import sys
N = int(sys.stdin.readline())
for _ in range(N):
	l = sys.stdin.readline().split()
	a = int(l[0])
	b = int(l[1])
	if a == b:
		print(0)
		continue
	if a > b:
		reste = a - b
		if reste % 2 == 0:
			print(1)
			continue
		else:
			print(2)
			continue
	if a < b:
		reste = b - a
		if reste % 2 == 0:
			print(2)
		else:
			print(1)


R = lambda : map(int, input().split())
for t in range(int(input())):
	(a, b) = R()
	if a <= b:
		print(1 if (a - b) % 2 else min(2, b - a))
	else:
		print(2 if (a - b) % 2 else 1)


import sys
f_in = sys.stdin
f_out = sys.stdout
t = int(f_in.readline())
for i in range(0, t):
	numpair = f_in.readline().split()
	a = int(numpair[0])
	b = int(numpair[1])
	if a > b and (a - b) % 2 == 1:
		f_out.write('2\n')
	elif a > b and (a - b) % 2 == 0:
		f_out.write('1\n')
	elif a < b and (b - a) % 2 == 1:
		f_out.write('1\n')
	elif a < b and (b - a) % 2 == 0:
		f_out.write('2\n')
	else:
		f_out.write('0\n')


t = int(input())
y = []
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		y.append(0)
	elif a % 2 == 0 and b % 2 == 0 and (a > b):
		y.append(1)
	elif a % 2 == 0 and b % 2 == 0 and (a < b):
		y.append(2)
	elif a % 2 != 0 and b % 2 != 0 and (a > b):
		y.append(1)
	elif a % 2 != 0 and b % 2 != 0 and (a < b):
		y.append(2)
	elif a % 2 == 0 and b % 2 != 0 and (a < b):
		y.append(1)
	elif a % 2 == 0 and b % 2 != 0 and (a > b):
		y.append(2)
	elif a % 2 != 0 and b % 2 == 0 and (a < b):
		y.append(1)
	elif a % 2 != 0 and b % 2 == 0 and (a > b):
		y.append(2)
for i in range(len(y)):
	print(y[i])


from math import ceil as cc

def mi():
	return map(int, input().split())
n = int(input())
for i in range(n):
	(a, b) = mi()
	if a == b:
		print(0)
	elif (b - a) % 2 == 0 and b > a:
		print(2)
	elif (b - a) % 2 and b > a:
		print(1)
	elif (b - a) % 2 == 0 and b < a:
		print(1)
	else:
		print(2)


a = []
b = []
for i in range(int(input())):
	a = input().split()
	if int(a[0]) == int(a[1]):
		b.append(0)
	elif int(a[0]) % 2 == int(a[1]) % 2:
		if int(a[0]) > int(a[1]):
			b.append(1)
		elif int(a[0]) < int(a[1]):
			b.append(2)
	elif int(a[0]) > int(a[1]):
		b.append(2)
	elif int(a[0]) < int(a[1]):
		b.append(1)
print(*b, sep='\n')


t = int(input())
ans = []
for i in range(t):
	ab = input().split(' ')
	a = int(ab[0])
	b = int(ab[1])
	if a > b:
		if (a - b) % 2 == 0 and a - (a - b) == b:
			ans.append(1)
		else:
			ans.append(2)
	elif a < b:
		if (a - b) % 2 > 0 and a + (b - a) == b:
			ans.append(1)
		else:
			ans.append(2)
	else:
		ans.append(0)
for o in range(len(ans)):
	print(ans[o])


t = int(input())
while t > 0:
	t -= 1
	(a, b) = list(map(int, input().split(' ')))
	if a == b:
		print(0)
	elif a < b and (a % 2 != 0 and b % 2 == 0 or (a % 2 == 0 and b % 2 != 0)):
		print(1)
	elif a < b and (a % 2 != 0 and b % 2 != 0 or (a % 2 == 0 and b % 2 == 0)):
		print(2)
	elif a > b and (a % 2 != 0 and b % 2 == 0 or (a % 2 == 0 and b % 2 != 0)):
		print(2)
	elif a > b and (a % 2 != 0 and b % 2 != 0 or (a % 2 == 0 and b % 2 == 0)):
		print(1)


t = int(input())
for z in range(t):
	(a, b) = map(int, input().split())
	ans = 0
	if a > b:
		if (a - b) % 2 == 0:
			ans = 1
		else:
			ans = 2
	elif a < b:
		if (b - a) % 2 == 0:
			ans = 2
		else:
			ans = 1
	print(ans)


def go():
	(a, b) = map(int, input().split())
	s = 0
	if b > a:
		if (b - a) % 2 != 0:
			print(1)
		else:
			print(2)
	if a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	if a == b:
		print(0)
t = int(input())
while t != 0:
	go()
	t = t - 1


def main():
	num_of_tests = int(input())
	for i in range(num_of_tests):
		(a, b) = map(int, input().split())
		solution = solver(a, b)
		sw_sol(solution)

def solver(a: int, b: int) -> int:
	if b == a:
		result = 0
	elif a < b and (b - a) % 2 == 0:
		result = 2
	elif a < b and (b - a) % 2 != 0:
		result = 1
	elif (a - b) % 2 == 0:
		result = 1
	else:
		result = 2
	return result

def sw_sol(sol: int):
	print(sol)
main()


t = int(input())
for t_case in range(t):
	(a, b) = map(int, input().split())
	if b == a:
		print(0)
	if b > a:
		if (b - a) % 2 == 0:
			print(2)
		elif (b - a) % 2 != 0:
			print(1)
	elif a > b:
		if (b - a) % 2 != 0:
			print(2)
		elif (b - a) % 2 == 0:
			print(1)


n = int(input())
ar = []
for i in range(n):
	s = input()
	a = s.split(' ')
	x = int(a[0])
	y = int(a[1])
	if x == y:
		print(0)
	if x > y and (x - y) % 2 == 1:
		print(2)
	if x > y and (x - y) % 2 == 0:
		print(1)
	if x < y and (y - x) % 2 == 0:
		print(2)
	if x < y and (y - x) % 2 == 1:
		print(1)


t = int(input())
for i in range(t):
	ab = list(map(int, input().split()))
	if ab[0] == ab[1]:
		print(0)
	elif ab[0] % 2 == 0:
		if ab[1] % 2 == 0:
			if ab[0] > ab[1]:
				print(1)
			else:
				print(2)
		elif ab[0] > ab[1]:
			print(2)
		else:
			print(1)
	elif ab[1] % 2 == 0:
		if ab[0] > ab[1]:
			print(2)
		else:
			print(1)
	elif ab[0] > ab[1]:
		print(1)
	else:
		print(2)


c = int(input())
out = []
for i in range(c):
	t = list(map(int, input().split()))
	n = int(t[0])
	m = int(t[1])
	p = min(n, m)
	if n == m:
		out.append('0')
	elif n == p:
		x = m - n
		if x % 2 == 0:
			out.append('2')
		else:
			out.append('1')
	else:
		x = n - m
		if x % 2 == 1:
			out.append('2')
		else:
			out.append('1')
for j in range(len(out)):
	print(out[j])


testCases = int(input())
differenceBetweenNumbers = 0
sumOfTwoNumbers = 0
MinNumberOfMoves = 0
for i in range(0, testCases):
	differenceBetweenNumbers = 0
	MinNumberOfMoves = 0
	(numberOne, numberTwo) = input().split()
	numberOne = int(numberOne)
	numberTwo = int(numberTwo)
	if numberOne == numberTwo:
		MinNumberOfMoves = 0
	elif numberOne > numberTwo:
		differenceBetweenNumbers = numberOne - numberTwo
		if differenceBetweenNumbers % 2 != 0:
			MinNumberOfMoves = 2
		else:
			MinNumberOfMoves = 1
	else:
		differenceBetweenNumbers = numberTwo - numberOne
		if differenceBetweenNumbers % 2 != 0:
			MinNumberOfMoves = 1
		else:
			MinNumberOfMoves = 2
	print(MinNumberOfMoves)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	z = a - b
	c = z % 2 == 0 and z < 0 or (z % 2 == 1 and z > 0)
	c1 = z % 2 == 1 and z < 0 or (z > 0 and z % 2 == 0)
	if c:
		print(2)
	elif c1:
		print(1)
	else:
		print(0)


from sys import stdin

def solve():
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(0)
	elif (b - a) % 2 and a < b:
		print(1)
	elif (a - b) % 2 == 0 and a > b:
		print(1)
	else:
		print(2)
for i in range(int(input())):
	solve()


numCases = int(input())
for i in range(numCases):
	(a, b) = map(int, input().split(' '))
	dif = a - b
	if a % 2 == 1:
		isAodd = True
	if b % 2 == 1:
		isBodd = True
	if dif > 0:
		if dif % 2 == 0:
			print(1)
		else:
			print(2)
	elif dif < 0:
		if dif % 2 == 1:
			print(1)
		else:
			print(2)
	else:
		print(0)


from math import *
from collections import *
t = int(input())
for y in range(t):
	(n, m) = map(int, input().split())
	if n == m:
		print(0)
	elif n > m:
		if n - m & 1:
			print(2)
		else:
			print(1)
	elif m - n & 1:
		print(1)
	else:
		print(2)


brTestova = input()
izlaz = []
for i in range(int(brTestova)):
	user_input = input()
	numberList = user_input.split()
	numberList = [int(x) for x in numberList]
	a = numberList[0]
	b = numberList[1]
	if a == b:
		moves = 0
	elif a < b:
		if a % 2 == b % 2:
			moves = 2
		else:
			moves = 1
	elif a % 2 == b % 2:
		moves = 1
	else:
		moves = 2
	izlaz.append(moves)
for case in izlaz:
	print(case)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	is_odd = abs(b - a) & 1
	if b - a > 0 and is_odd or (b - a < 0 and (not is_odd)):
		print(1)
	else:
		print(2)


def even(a):
	if a % 2 == 0:
		return True
	else:
		return False
list = []
t = int(input())
for i in range(t):
	s = input()
	a = int(s.split(' ')[0])
	b = int(s.split(' ')[1])
	if even(a) != even(b):
		if a < b:
			list.append(1)
		else:
			list.append(2)
	elif even(a) == even(b):
		if a < b:
			list.append(2)
		elif a > b:
			list.append(1)
		else:
			list.append(0)
for i in list:
	print(i)


def func(n):
	for i in range(n):
		k = list(map(int, input().split()))
		a = k[0]
		b = k[1]
		if a == b:
			print(0)
		elif a > b and (a - b) % 2 == 0:
			print(1)
		elif a < b and (b - a) % 2 != 0:
			print(1)
		else:
			print(2)
n = int(input())
func(n)


def main():
	t = int(input())
	for _ in range(t):
		(a, b) = (int(x) for x in input().split())
		print(solver(a, b))

def solver(a, b):
	if a == b:
		return 0
	elif a < b:
		if (b - a) % 2 == 0:
			return 2
		else:
			return 1
	elif (a - b) % 2 == 0:
		return 1
	else:
		return 2
main()


import sys
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input().rstrip())
	for i in range(tests):
		(a, b) = map(int, input().rstrip().split())
		cond1 = a % 2 == 1 and b % 2 == 1
		cond2 = a % 2 == 0 and b % 2 == 0
		res = 1
		if a == b:
			output('0')
			output('\n')
			continue
		elif a < b:
			if cond1 is True or cond2 is True:
				res += 1
		elif (cond1 is True or cond2 is True) is False:
			res += 1
		output(str(res))
		output('\n')
main()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if b > a:
		x = b - a
		if x % 2 != 0:
			print(1)
		if x % 2 == 0:
			print(2)
	if a > b:
		x = a - b
		if x % 2 == 0:
			print(1)
		if x % 2 != 0:
			print(2)
	if a == b:
		print(0)


from math import factorial
from collections import Counter
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')
import bisect

def main():
	N = int(input())
	for _ in range(N):
		(a, b) = RL()
		dif = b - a
		if dif == 0:
			print(0)
		elif dif > 0:
			if dif % 2 == 1:
				print(1)
			else:
				print(2)
		elif dif % 2 == 0:
			print(1)
		else:
			print(2)
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	oda = bool(a % 2)
	odb = bool(b % 2)
	ans = 1
	if a == b:
		ans = 0
	elif oda and odb:
		if a < b:
			ans = 2
		else:
			ans = 1
	elif not oda and (not odb):
		if a < b:
			ans = 2
		else:
			ans = 1
	elif oda and (not odb):
		if a < b:
			ans = 1
		else:
			ans = 2
	elif not oda and odb:
		if a > b:
			ans = 2
		else:
			ans = 1
	print(ans)


n = int(input())
l = []
for i in range(0, n):
	s = [int(x) for x in input().split()]
	l.append(s)
for j in range(0, n):
	if l[j][0] > l[j][1]:
		p = l[j][0] - l[j][1]
		if p % 2 == 0:
			print(1)
		else:
			print(2)
	elif l[j][0] < l[j][1]:
		p1 = l[j][1] - l[j][0]
		if p1 % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		print(0)


t = int(input())
num_list = []
for i in range(t):
	s = input()
	num_list.append(s)
for i in num_list:
	(a, b) = map(int, i.split())
	if a == b:
		print('0')
	elif a > b:
		c = a - b
		if c % 2 == 0:
			print('1')
		else:
			print('2')
	elif a < b:
		c = b - a
		if c % 2 == 0:
			print('2')
		else:
			print('1')


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007
for _ in range(int(input())):
	(a, b) = get_int()
	if a == b:
		print(0)
	elif a > b:
		if a % 2 == b % 2:
			print(1)
		else:
			print(2)
	else:
		c = b - a
		if c % 2 == 0:
			print(2)
		else:
			print(1)


def check(a, b):
	if a == b:
		return 0
	elif a > b:
		r = a - b
		if r % 2 == 0:
			return 1
		else:
			return 2
	else:
		r = b - a
		if r % 2 == 0:
			return 2
		else:
			return 1
listf = []
t = int(input())
for x in range(t):
	i = input().split()
	a = int(i[0])
	b = int(i[1])
	listf.append(check(a, b))
for g in listf:
	print(g)


import math
import string
a = int(input())
for i in range(a):
	b = input().split(' ')
	c = int(b[0])
	d = int(b[1])
	counter = 0
	if c != d:
		if c > d:
			if (c + d) % 2 == 0:
				counter = 1
			else:
				counter = 2
		elif (c + d) % 2 == 0:
			counter = 2
		else:
			counter = 1
	print(counter)


a1 = int(input())
for i1 in range(a1):
	arr = [int(x) for x in input().split()]
	(a, b) = (arr[0], arr[1])
	if a == b:
		print(0)
	elif a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	elif (b - a) % 2 == 1:
		print(1)
	else:
		print(2)


def oddeven(nums):
	if nums[0] < nums[1] and sum(nums) % 2 == 1 or (nums[0] > nums[1] and sum(nums) % 2 == 0):
		return 1
	elif nums[0] < nums[1] and sum(nums) % 2 == 0 or (nums[0] > nums[1] and sum(nums) % 2 == 1):
		return 2
	else:
		return 0
for i in range(int(input())):
	x = list(map(int, input().split()))
	print(oddeven(x))


n = int(input())
l = []
for _ in range(n):
	count = 0
	t = input().split(' ')
	a = int(t[0])
	b = int(t[1])
	if a > b:
		t = a - b
		if t % 2 == 0:
			count = 1
			l.append(count)
		else:
			count = 2
			l.append(count)
	elif b > a:
		t = a - b
		if t % 2 != 0:
			count = 1
			l.append(count)
		else:
			count = 2
			l.append(count)
	else:
		l.append(count)
for i in l:
	print(i)


t = int(input())
i = 0
A = []
while 0 <= i < t:
	i = i + 1
	(a, b) = map(int, input().split())
	if a == b:
		A.append('0')
	if a < b:
		if (b - a) % 2 == 0:
			A.append('2')
		else:
			A.append('1')
	elif a > b:
		if (a - b) % 2 == 0:
			A.append('1')
		else:
			A.append('2')
k = -1
while -1 <= k < t - 1:
	k = k + 1
	print(A[k])


number_of_tests = int(input())
for i in range(number_of_tests):
	two_numbers = input()
	l = two_numbers.split(' ')
	if len(l) > 2:
		exit(0)
	for j in range(len(l)):
		l[j] = int(l[j])
	if l[0] < l[1]:
		if (l[1] - l[0]) % 2 == 0:
			print(2)
		else:
			print(1)
	elif l[0] > l[1]:
		if (l[0] - l[1]) % 2 == 0:
			print(1)
		else:
			print(2)
	else:
		print(0)


no = int(input())
main = []
for i in range(no):
	(a, b) = map(int, input().split())
	sub = a - b
	if sub == 0:
		main.append(0)
	elif sub % 2 != 0:
		if sub < 0:
			main.append(1)
		else:
			main.append(2)
	elif sub < 0:
		main.append(2)
	else:
		main.append(1)
for i in main:
	print(i)


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(a, b) = Read.list_int()
	if a == b:
		print(0)
	elif a > b:
		if (a - b) % 2 == 0:
			print(1)
		else:
			print(2)
	elif (b - a) % 2 == 1:
		print(1)
	else:
		print(2)
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


def reminder(i: int):
	return i % 2

def calc(a: int, b: int):
	if a == b:
		return 0
	if a < b:
		if reminder(a) == 0 and reminder(b) == 0:
			return 2
		elif reminder(a) == 1 and reminder(b) == 1:
			return 2
		elif reminder(a) == 0 and reminder(b) == 1:
			return 1
		elif reminder(a) == 1 and reminder(b) == 0:
			return 1
	elif a > b:
		if reminder(a) == 0 and reminder(b) == 0:
			return 1
		elif reminder(a) == 1 and reminder(b) == 1:
			return 1
		elif reminder(a) == 0 and reminder(b) == 1:
			return 2
		elif reminder(a) == 1 and reminder(b) == 0:
			return 2

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		print(calc(a, b))
main()


def solve(a, b):
	if a == b:
		return 0
	d = abs(a - b)
	if a < b:
		if d % 2:
			return 1
		else:
			return 2
	elif d % 2:
		return 2
	else:
		return 1
N = int(input())
for _ in range(N):
	(a, b) = map(int, input().split())
	print(solve(a, b))


t = int(input())
result = []
for i in range(t):
	(x, y) = input().split(' ')
	difference = int(y) - int(x)
	if difference == 0:
		result.append(0)
	elif difference > 0:
		if difference % 2 == 0:
			result.append(2)
		else:
			result.append(1)
	elif difference % 2 == 0:
		result.append(1)
	else:
		result.append(2)
for item in result:
	print(item)


n = int(input())
l = []
for i in range(0, n):
	m = [int(x) for x in input().split()]
	l.append(m)
for j in range(0, n):
	a = l[j][0]
	b = l[j][1]
	if a > b:
		k = a - b
		if k % 2 == 0:
			print(1)
		else:
			print(2)
	elif b > a:
		k = b - a
		if k % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		print(0)


test_cases = int(input())
test = test_cases
data = []
while test_cases > 0:
	data.append(input().split())
	test_cases -= 1
for i in range(0, test):
	if int(data[i][0]) > int(data[i][1]):
		if (int(data[i][0]) - int(data[i][1])) % 2 == 0:
			print(1)
		else:
			print(2)
	elif int(data[i][0]) < int(data[i][1]):
		if (int(data[i][0]) - int(data[i][1])) % 2 == 1:
			print(1)
		else:
			print(2)
	else:
		print(0)


t = int(input())
results = []
for i in range(t):
	nk = list(map(int, input().split()))
	a = nk[0]
	b = nk[-1]
	if a > b:
		if a % 2 == 0:
			if b % 2 == 0:
				results.append(1)
			else:
				results.append(2)
		elif b % 2 == 0:
			results.append(2)
		else:
			results.append(1)
	elif a < b:
		if a % 2 == 0:
			if b % 2 == 0:
				results.append(2)
			else:
				results.append(1)
		elif b % 2 == 0:
			results.append(1)
		else:
			results.append(2)
	else:
		results.append(0)
for i in results:
	print(i)