Alice is playing Air Hockey with Bob. The first person to earn seven points wins the match. Currently, Alice's score is A and Bob's score is B.

Charlie is eagerly waiting for his turn. Help Charlie by calculating the minimum number of points that will be further scored in the match before it ends. 

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

- The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains two space-separated integers A and B, as described in the problem statement. 

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

For each test case, output on a new line the minimum number of points that will be further scored in the match before it ends.

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

$1 ≤ T ≤ 50$
$0 ≤ A, B ≤ 6$

----- Sample Input 1 ------ 
4
0 0
2 5
5 2
4 3
----- Sample Output 1 ------ 
7
2
2
3

----- explanation 1 ------ 
Test case $1$: The current score is $0-0$. If either Alice or Bob scores $7$ consecutive points, then the score will become $7-0$ or $0-7$ respectively, and the game will end. It can be proven that at least $7$ points will be further scored in the match before it ends.

Test case $2$: The current score is $2-5$. If Bob scores $2$ consecutive points, then the score will become $2-7$ and the game will end. It can be proven that at least $2$ points will be further scored in the match before it ends.

Test case $3$: The current score is $5-2$. If Alice scores $2$ consecutive points, then the score will become $7-2$ and the game will end. It can be proven that at least $2$ points will be further scored in the match before it ends.

Test case $4$: The current score is $4-3$. If Alice scores $3$ consecutive points, then the score will become $7-3$ and the game will end. It can be proven that at least $3$ points will be further scored in the match before it ends.

Difficulty: EASY

Solutions:
t = int(input())
for i in range(t):
	l = list(map(int, input().split(' ')))
	m = max(l)
	print(7 - m)


for i in range(int(input())):
	(x, y) = map(int, input().split(' '))
	print(7 - max(x, y))


p = int(input())
for i in range(p):
	(a, z) = map(int, input().split())
	if a >= z:
		print(7 - a)
	else:
		print(7 - z)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		print(7 - a)
	else:
		print(7 - b)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	print(min(7 - x, 7 - y))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	c = max(a, b)
	res = 7 - c
	print(res)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = max(a, b)
	rest = 7 - c
	print(rest)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	m = max(a, b)
	print(7 - m)


T = int(input())
for i in range(T):
	(A, B) = map(int, input().split(' '))
	print(7 - max(A, B))


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	x = max(A, B)
	print(7 - x)


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if a > b:
		print(7 - a)
	else:
		print(7 - b)


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	if x > y:
		print(7 - x)
	elif y > x:
		print(7 - y)
	else:
		print(7 - x)


T = int(input())
for i in range(T):
	(N, M) = map(int, input().split())
	a = max(N, M)
	c = 7 - a
	print(c)


T = int(input())
for t in range(T):
	(A, B) = map(int, input().split())
	if A == B:
		q = 7 - A
		print(q)
	elif A > B:
		w = 7 - A
		print(w)
	elif B > A:
		e = 7 - B
		print(e)
	else:
		print('invalid')


s = int(input())
for i in range(s):
	(a, b) = map(int, input().split())
	print(abs(max(a, b) - 7))


t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	print(7 - max(a, b))


a = int(input())
for i in range(a):
	x = list(map(int, input().split()))
	print(7 - max(x))


n = int(input())
for i in range(n):
	l = []
	m = input().split()
	for j in m:
		l.append(int(j))
	k = max(l)
	if l[0] == l[1]:
		print(abs(7 - l[0]))
	else:
		print(abs(k - 7))


for _ in range(int(input())):
	a = list(map(int, input().split()))
	print(7 - max(a))


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	a1 = 7 - a
	b1 = 7 - b
	print(min(a1, b1))


T = int(input())
for i in range(T):
	x = [int(i) for i in input().split()]
	y = max(x)
	total = 7 - y
	print(total)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = 7 - a
	y = 7 - b
	print(min(x, y))


T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	print(7 - max(a, b))


n = int(input())
for i in range(0, n):
	(a, b) = map(int, input().split(' '))
	if 7 - a < 7 - b:
		print(7 - a)
	else:
		print(7 - b)


t = int(input())
while t:
	(a, b) = map(int, input().split())
	c = a if a > b else b
	print(7 - c)
	t -= 1


n = int(input())
while n > 0:
	(a, b) = map(int, input().split())
	c = max(a, b)
	print(7 - c)
	n -= 1


for i in range(int(input())):
	(a, b) = map(int, input().split())
	x = a - 7
	y = b - 7
	print(abs(max(x, y)))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	c = abs(a - 7)
	d = abs(7 - b)
	mini = min(c, d)
	print(mini)


T = int(input())
for i in range(0, T):
	(A, B) = input().split()
	a = int(A)
	b = int(B)
	alice = 7 - a
	bob = 7 - b
	if alice <= bob:
		print(alice)
	else:
		print(bob)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = max(a, b)
	d = 7 - c
	print(d)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = max(a, b)
	a = x - 7
	if a < 0:
		print(-a)
	else:
		print(a)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(min(7 - a, 7 - b))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x > y:
		print(7 - x)
	else:
		print(7 - y)


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	print(7 - max(a, b))


n = int(input())
l = []
for i in range(n):
	(j, k) = map(int, input().split())
	if j > k or j == k:
		print(7 - j)
	else:
		print(7 - k)


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


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	print(7 - max(x, y))


for i in range(int(input())):
	(A, B) = map(int, input().split())
	max1 = max(A, B)
	min_points = 7 - max1
	print(min_points)


T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	a = 7 - A
	b = 7 - B
	if a > b:
		print(b)
	elif a == b:
		print(a)
	else:
		print(a)