Chef and Chefina are residing in a hotel.

There are 10 floors in the hotel and each floor consists of 10 rooms.

Floor 1 consists of room numbers 1 to 10.
Floor 2 consists of room numbers 11 to 20.  
\ldots
Floor i consists of room numbers 10 \cdot (i-1) + 1 to 10 \cdot i.

You know that Chef's room number is X while Chefina's Room number is Y.  
If Chef starts from his room, find the number of floors he needs to travel to reach Chefina's room.

------ Input Format ------ 

- First line will contain T, number of test cases. Then the test cases follow.
- Each test case contains of a single line of input, two integers X, Y, the room numbers of Chef and Chefina respectively.

------ Output Format ------ 

For each test case, output the number of floors Chef needs to travel to reach Chefina's room.

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$1 ≤ X, Y ≤ 100$
$X \neq Y$

----- Sample Input 1 ------ 
4
1 100
42 50
53 30
81 80

----- Sample Output 1 ------ 
9
0
3
1

----- explanation 1 ------ 
Test Case $1$: Since Room $1$ is on $1^{st}$ floor and Room $100$ is on $10^{th}$ floor, Chef needs to climb $9$ floors to reach Chefina's Room.

Test Case $2$: Since Room $42$ is on $5^{th}$ floor and Room $50$ is also on $5^{th}$ floor, Chef does not need to climb any floor.

Test Case $3$: Since Room $53$ is on $6^{th}$ floor and Room $30$ is on $3^{rd}$ floor, Chef needs to go down $3$ floors to reach Chefina's Room.

Test Case $4$: Since Room $81$ is on $9^{th}$ floor and Room $80$ is on $8^{th}$ floor, Chef needs to go down $1$ floors to reach Chefina's Room.

Source: codechef | Difficulty: EASY
Tags: Mathematics


Solutions:
import math
for i in range(int(input())):
	(x, y) = map(int, input().split())
	a = math.ceil(x / 10)
	b = math.ceil(y / 10)
	print(abs(a - b))


import math
for t in range(int(input())):
	(x, y) = map(int, input().split())
	f1 = math.ceil(x / 10)
	f2 = math.ceil(y / 10)
	print(abs(f1 - f2))


a = int(input())
for i in range(a):
	(x, y) = [int(m) for m in input().split()]
	for i in range(1, 11):
		for j in range(10 * i - 9, 10 * i + 1):
			if x == j:
				z = i
	for i in range(1, 11):
		for j in range(10 * i - 9, 10 * i + 1):
			if y == j:
				m = i
	print(abs(z - m))


import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	print(abs(math.ceil(y / 10) - math.ceil(x / 10)))


import math as m
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	f1 = m.ceil(a / 10)
	f2 = m.ceil(b / 10)
	print(abs(f1 - f2))


x = int(input(''))
for l in range(x):
	(x, y) = map(int, input().split())
	if x % 10 == 0:
		x = int(x / 10)
	else:
		x = int(x / 10) + 1
	if y % 10 == 0:
		y = int(y / 10)
	else:
		y = int(y / 10) + 1
	print(abs(x - y))


x = int(input(''))
for l in range(x):
	(x, y) = map(int, input().split())
	if x in range(1, 11):
		x = 1
	elif x in range(11, 21):
		x = 2
	elif x in range(21, 31):
		x = 3
	elif x in range(31, 41):
		x = 4
	elif x in range(41, 51):
		x = 5
	elif x in range(51, 61):
		x = 6
	elif x in range(61, 71):
		x = 7
	elif x in range(71, 81):
		x = 8
	elif x in range(81, 91):
		x = 9
	elif x in range(91, 101):
		x = 10
	if y in range(1, 11):
		y = 1
	elif y in range(11, 21):
		y = 2
	elif y in range(21, 31):
		y = 3
	elif y in range(31, 41):
		y = 4
	elif y in range(41, 51):
		y = 5
	elif y in range(51, 61):
		y = 6
	elif y in range(61, 71):
		y = 7
	elif y in range(71, 81):
		y = 8
	elif y in range(81, 91):
		y = 9
	elif y in range(91, 101):
		y = 10
	print(abs(x - y))


t = int(input())
for i in range(t):
	(X, Y) = map(int, input().split())
	x = (X - 1) // 10 + 1
	y = (Y - 1) // 10 + 1
	print(abs(x - y))


t = int(input())
while t > 0:
	(x, y) = input().split()
	(x, y) = [int(x), int(y)]
	a = b = flag = 0
	for i in range(1, 11):
		if 10 * (i - 1) + 1 <= x <= 10 * i and 10 * (i - 1) + 1 <= y <= 10 * i:
			print(0)
			flag = 1
	for j in range(1, 11):
		if 10 * (j - 1) + 1 <= x <= 10 * j:
			a = j
	for k in range(1, 11):
		if 10 * (k - 1) + 1 <= y <= 10 * k:
			b = k
	if flag == 0:
		if a > b:
			print(a - b)
		else:
			print(b - a)
	t = t - 1


import math
t = int(input())
for i in range(t):
	(X, Y) = map(int, input().split())
	f1 = math.ceil(X / 10)
	f2 = math.ceil(Y / 10)
	print(abs(f1 - f2))


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (math.ceil(a / 10), math.ceil(b / 10))
	if a > b:
		print(a - b, end='\n')
	else:
		print(b - a, end='\n')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if x in range(1, 11) and y in range(1, 11):
		print(0)
	elif x in range(1, 11) and y in range(11, 21):
		print(1)
	elif x in range(1, 11) and y in range(21, 31):
		print(2)
	elif x in range(1, 11) and y in range(31, 41):
		print(3)
	elif x in range(1, 11) and y in range(41, 51):
		print(4)
	elif x in range(1, 11) and y in range(51, 61):
		print(5)
	elif x in range(1, 11) and y in range(61, 71):
		print(6)
	elif x in range(1, 11) and y in range(71, 81):
		print(7)
	elif x in range(1, 11) and y in range(81, 91):
		print(8)
	elif x in range(1, 11) and y in range(91, 101):
		print(9)
	if x in range(11, 21) and y in range(1, 11):
		print(1)
	elif x in range(11, 21) and y in range(11, 21):
		print(0)
	elif x in range(11, 21) and y in range(21, 31):
		print(1)
	elif x in range(11, 21) and y in range(31, 41):
		print(2)
	elif x in range(11, 21) and y in range(41, 51):
		print(3)
	elif x in range(11, 21) and y in range(51, 61):
		print(4)
	elif x in range(11, 21) and y in range(61, 71):
		print(5)
	elif x in range(11, 21) and y in range(71, 81):
		print(6)
	elif x in range(11, 21) and y in range(81, 91):
		print(7)
	elif x in range(11, 21) and y in range(91, 101):
		print(8)
	if x in range(21, 31) and y in range(1, 11):
		print(2)
	elif x in range(21, 31) and y in range(11, 21):
		print(1)
	elif x in range(21, 31) and y in range(21, 31):
		print(0)
	elif x in range(21, 31) and y in range(31, 41):
		print(1)
	elif x in range(21, 31) and y in range(41, 51):
		print(2)
	elif x in range(21, 31) and y in range(51, 61):
		print(3)
	elif x in range(21, 31) and y in range(61, 71):
		print(4)
	elif x in range(21, 31) and y in range(71, 81):
		print(5)
	elif x in range(21, 31) and y in range(81, 91):
		print(6)
	elif x in range(21, 31) and y in range(91, 101):
		print(7)
	if x in range(31, 41) and y in range(1, 11):
		print(3)
	elif x in range(31, 41) and y in range(11, 21):
		print(2)
	elif x in range(31, 41) and y in range(21, 31):
		print(1)
	elif x in range(31, 41) and y in range(31, 41):
		print(0)
	elif x in range(31, 41) and y in range(41, 51):
		print(1)
	elif x in range(31, 41) and y in range(51, 61):
		print(2)
	elif x in range(31, 41) and y in range(61, 71):
		print(3)
	elif x in range(31, 41) and y in range(71, 81):
		print(4)
	elif x in range(31, 41) and y in range(81, 91):
		print(5)
	elif x in range(31, 41) and y in range(91, 101):
		print(6)
	if x in range(41, 51) and y in range(1, 11):
		print(4)
	elif x in range(41, 51) and y in range(11, 21):
		print(3)
	elif x in range(41, 51) and y in range(21, 31):
		print(2)
	elif x in range(41, 51) and y in range(31, 41):
		print(1)
	elif x in range(41, 51) and y in range(41, 51):
		print(0)
	elif x in range(41, 51) and y in range(51, 61):
		print(1)
	elif x in range(41, 51) and y in range(61, 71):
		print(2)
	elif x in range(41, 51) and y in range(71, 81):
		print(3)
	elif x in range(41, 51) and y in range(81, 91):
		print(4)
	elif x in range(41, 51) and y in range(91, 101):
		print(5)
	if x in range(51, 61) and y in range(1, 11):
		print(5)
	elif x in range(51, 61) and y in range(11, 21):
		print(4)
	elif x in range(51, 61) and y in range(21, 31):
		print(3)
	elif x in range(51, 61) and y in range(31, 41):
		print(2)
	elif x in range(51, 61) and y in range(41, 51):
		print(1)
	elif x in range(51, 61) and y in range(51, 61):
		print(0)
	elif x in range(51, 61) and y in range(61, 71):
		print(1)
	elif x in range(51, 61) and y in range(71, 81):
		print(2)
	elif x in range(51, 61) and y in range(81, 91):
		print(3)
	elif x in range(51, 61) and y in range(91, 101):
		print(4)
	if x in range(61, 71) and y in range(1, 11):
		print(6)
	elif x in range(61, 71) and y in range(11, 21):
		print(5)
	elif x in range(61, 71) and y in range(21, 31):
		print(4)
	elif x in range(61, 71) and y in range(31, 41):
		print(3)
	elif x in range(61, 71) and y in range(41, 51):
		print(2)
	elif x in range(61, 71) and y in range(51, 61):
		print(1)
	elif x in range(61, 71) and y in range(61, 71):
		print(0)
	elif x in range(61, 71) and y in range(71, 81):
		print(1)
	elif x in range(61, 71) and y in range(81, 91):
		print(2)
	elif x in range(61, 71) and y in range(91, 101):
		print(3)
	if x in range(71, 81) and y in range(1, 11):
		print(7)
	elif x in range(71, 81) and y in range(11, 21):
		print(6)
	elif x in range(71, 81) and y in range(21, 31):
		print(5)
	elif x in range(71, 81) and y in range(31, 41):
		print(4)
	elif x in range(71, 81) and y in range(41, 51):
		print(3)
	elif x in range(71, 81) and y in range(51, 61):
		print(2)
	elif x in range(71, 81) and y in range(61, 71):
		print(1)
	elif x in range(71, 81) and y in range(71, 81):
		print(0)
	elif x in range(71, 81) and y in range(81, 91):
		print(1)
	elif x in range(71, 81) and y in range(91, 101):
		print(2)
	if x in range(81, 91) and y in range(1, 11):
		print(8)
	elif x in range(81, 91) and y in range(11, 21):
		print(7)
	elif x in range(81, 91) and y in range(21, 31):
		print(6)
	elif x in range(81, 91) and y in range(31, 41):
		print(5)
	elif x in range(81, 91) and y in range(41, 51):
		print(4)
	elif x in range(81, 91) and y in range(51, 61):
		print(3)
	elif x in range(81, 91) and y in range(61, 71):
		print(2)
	elif x in range(81, 91) and y in range(71, 81):
		print(1)
	elif x in range(81, 91) and y in range(81, 91):
		print(0)
	elif x in range(81, 91) and y in range(91, 101):
		print(1)
	if x in range(91, 101) and y in range(1, 11):
		print(9)
	elif x in range(91, 101) and y in range(11, 21):
		print(8)
	elif x in range(91, 101) and y in range(21, 31):
		print(7)
	elif x in range(91, 101) and y in range(31, 41):
		print(6)
	elif x in range(91, 101) and y in range(41, 51):
		print(5)
	elif x in range(91, 101) and y in range(51, 61):
		print(4)
	elif x in range(91, 101) and y in range(61, 71):
		print(3)
	elif x in range(91, 101) and y in range(71, 81):
		print(2)
	elif x in range(91, 101) and y in range(81, 91):
		print(1)
	elif x in range(91, 101) and y in range(91, 101):
		print(0)


import math
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	i = math.ceil(x / 10)
	j = math.ceil(y / 10)
	p = abs(i - j)
	print(p)


T = int(input())
for i in range(0, T):
	(x, y) = map(int, input().split())
	if x % 10 != 0 and y % 10 != 0:
		temp = x // 10 - y // 10
		temp2 = abs(temp)
		print(temp2)
	elif x % 10 == 0 and y % 10 != 0:
		temp = (x - 1) // 10 - y // 10
		temp2 = abs(temp)
		print(temp2)
	elif x % 10 != 0 and y % 10 == 0:
		temp = x // 10 - (y - 1) // 10
		temp2 = abs(temp)
		print(temp2)
	else:
		temp = (x - 1) // 10 - (y - 1) // 10
		temp2 = abs(temp)
		print(temp2)


import math
for i in range(int(input())):
	(x, y) = map(int, input().split())
	z = math.ceil(x / 10)
	w = math.ceil(y / 10)
	print(abs(w - z))


def get_floor(x):
	if x % 10:
		return x // 10 + 1
	return x // 10
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split(' '))
	x_floor = get_floor(x)
	y_floor = get_floor(y)
	print(abs(x_floor - y_floor))


from math import *

def floor_no(x):
	if x % 10 == 0:
		return x / 10
	else:
		return x // 10 + 1
test_case = int(input())
for i in range(0, test_case):
	(x, y) = map(int, input().split())
	print(abs(int(floor_no(x) - floor_no(y))))


def floor_no(x):
	if x % 10 == 0:
		return x / 10
	else:
		return x // 10 + 1
test_case = int(input())
for i in range(0, test_case):
	(x, y) = map(int, input().split())
	if x > y:
		print(int(floor_no(x) - floor_no(y)))
	else:
		print(int(floor_no(y) - floor_no(x)))


import math
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	d1 = math.ceil(x / 10)
	d2 = math.ceil(y / 10)
	print(abs(d1 - d2))


for _ in range(int(input())):
	(room1, room2) = map(int, input().split())
	floor1 = 0
	for f1 in range(1, 10 + 1):
		if room1 >= 10 * (f1 - 1) + 1 and room1 <= 10 * f1:
			floor1 = f1
			break
	floor2 = 0
	for f2 in range(1, 10 + 1):
		if room2 >= 10 * (f2 - 1) + 1 and room2 <= 10 * f2:
			floor2 = f2
			break
	print(abs(floor1 - floor2))


import math
for t in range(int(input())):
	(x, y) = map(int, input().split())
	p1 = math.ceil(x / 10)
	p2 = math.ceil(y / 10)
	print(abs(p1 - p2))


t = int(input())
for i in range(t):
	(s, d) = map(int, input().split())
	a = s // 10
	b = d // 10
	if s % 10 != 0:
		a += 1
	elif s % 10 == 0:
		a = a
	if d % 10 != 0:
		b += 1
	elif d % 10 == 0:
		b = b
	print(abs(a - b))


from math import *
for t in range(int(input())):
	(a, b) = map(int, input().split())
	print(abs(ceil(a / 10) - ceil(b / 10)))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x % 10 == 0 and y % 10 == 0:
		print(abs(x // 10 - y // 10))
	elif x % 10 != 0 and y % 10 == 0:
		print(abs(x // 10 + 1 - y // 10))
	elif y % 10 != 0 and x % 10 == 0:
		print(abs(x // 10 - 1 - y // 10))
	elif y % 10 != 0 and x % 10 != 0:
		print(abs(x // 10 - y // 10))


t = int(input())
for i in range(t):
	(r1, r2) = map(int, input().split())
	f1 = (r1 - 1) // 10 + 1
	f2 = (r2 - 1) // 10 + 1
	print(abs(f2 - f1))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if x % 10 == 0 and y % 10 == 0:
		print(max(x // 10, y // 10) - min(x // 10, y // 10))
	elif x % 10 != 0 and y % 10 != 0:
		print(max(x // 10 + 1, y // 10 + 1) - min(x // 10 + 1, y // 10 + 1))
	elif x % 10 != 0 and y % 10 == 0:
		print(max(x // 10 + 1, y // 10) - min(x // 10 + 1, y // 10))
	else:
		print(max(x // 10, y // 10 + 1) - min(x // 10, y // 10 + 1))


import math

def floor(x, y):
	p = math.ceil(x / 10)
	q = math.ceil(y / 10)
	return abs(p - q)
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	v = floor(x, y)
	print(v)


import math
for i in range(int(input())):
	(x, y) = map(int, input().split())
	diff = abs(math.ceil(x / 10) - math.ceil(y / 10))
	print(int(diff))


import math
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	s = math.ceil(x / 10)
	d = math.ceil(y / 10)
	print(abs(s - d))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = a // 10
	if a % 10 != 0:
		x += 1
	y = b // 10
	if b % 10 != 0:
		y += 1
	print(abs(x - y))


t = int(input())
for _ in range(t):
	c = 0
	(x, y) = map(int, input().split())
	x = (x - 1) // 10
	y = (y - 1) // 10
	print(abs(x - y))


import math
for i in range(int(input())):
	(x, y) = map(float, input().split())
	s = math.ceil(x / 10)
	r = math.ceil(y / 10)
	print(abs(r - s))


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	lst = []
	for j in range(len(l)):
		if len(str(l[j])) >= 2:
			new = int(str(l[j])[:-1])
			if l[j] % 10 == 0:
				pass
			else:
				new += 1
		else:
			new = 1
		lst.append(new)
	dif = abs(lst[0] - lst[1])
	print(dif)


import math
for i in range(int(input())):
	(x, y) = map(int, input().split())
	c = math.ceil(x / 10)
	ch = math.ceil(y / 10)
	print(abs(c - ch))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	print(abs((l[0] - 1) // 10 - (l[1] - 1) // 10))


import math
t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	m1 = math.ceil(m / 10)
	n1 = math.ceil(n / 10)
	maxi = max(m1, n1)
	mini = min(m1, n1)
	print(maxi - mini)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	fx = (x - 1) // 10
	fy = (y - 1) // 10
	print(abs(fx - fy))


for i in range(int(input())):
	(X, Y) = [int(x) for x in input().split()]
	X = (X - 1) // 10
	Y = (Y - 1) // 10
	floors = abs(X - Y)
	print(floors)