The National Championships are starting soon. There are 4 race categories, numbered from 1 to 4, that Chef is interested in. Chef is participating in exactly 2 of these categories. 

Chef has an arch-rival who is, unfortunately, the only person participating who is better than Chef, i.e, Chef can't defeat the arch-rival in any of the four race categories but can defeat anyone else. Chef's arch-rival is also participating in exactly 2 of the four categories.
 
Chef hopes to not fall into the same categories as that of the arch-rival.

Given X, Y, A, B where X, Y are the races that Chef participates in, and A, B are the races that Chef's arch-rival participates in, find the maximum number of gold medals (first place) that Chef can win.

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

- The first line of input contains an integer T, denoting the number of testcases. The description of T testcases follows.
- Each testcase consists of a single line containing four space-separated integers — the values of X, Y, A, and B respectively.

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

- For each testcase, print a single line containing one integer — the maximum number of gold medals that Chef can win.

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

$1 ≤ T ≤ 144$
$1 ≤ X, Y, A, B ≤ 4$
$X \neq Y$
$A \neq B$

------ subtasks ------ 

Subtask #1 (100 points): Original constraints

----- Sample Input 1 ------ 
3
4 3 1 2
4 2 1 2
2 1 1 2
----- Sample Output 1 ------ 
2
1
0
----- explanation 1 ------ 
Test case $1$: Chef participates in the races $4, 3$, whereas Chef's rival participates in $1, 2$. As Chef's only rival does not participate in any of the races that Chef takes part in, Chef can win the gold medal in both of the races, thus the answer is $2$.

Test case $2$: Chef participates in the races $4, 2$, whereas Chef's rival participates in $1, 2$. Chef cannot win race $2$ as Chef will be beaten by the arch-rival, however Chef can win the gold medal for race $4$. Thus the answer is $1$.

Test case $3$: Chef participates in the races $2, 1$, whereas Chef's rival participates in $1, 2$. Chef will be beaten by the arch-rival in both races, thus the answer is $0$.

Difficulty: EASY

Solutions:
for i in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	if x <= 4 and b <= 4 and (a <= 4) and (y <= 4):
		if x != b and x != a and (y != a) and (y != b):
			print(2)
		elif x != b and x != a or (y != a and y != b):
			print(1)
		else:
			print(0)


for i in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	if len(set([x, y, a, b])) == len([x, y, a, b]):
		print(2)
	elif len(set([x, y, a, b])) == 3:
		print(1)
	else:
		print(0)


for i in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	cnt = 0
	if a != x and a != y:
		cnt = cnt + 1
	if b != x and b != y:
		cnt = cnt + 1
	print(cnt)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if len(set([a, b, c, d])) == len([a, b, c, d]):
		print(2)
	elif len(set([a, b, c, d])) == 3:
		print(1)
	else:
		print(0)


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


for i in range(int(input())):
	X = set(map(int, input().split()))
	print(len(X) - 2)


def gold_medals(xy, ab):
	if sorted(xy) == sorted(ab):
		return 0
	xy = sorted(xy)
	ab = sorted(ab)
	res = 0
	for i in range(len(xy)):
		if xy[i] not in ab:
			res += 1
	return res
n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	xy = l[:2]
	ab = l[2:5]
	print(gold_medals(xy, ab))


t = int(input())
for i in range(t):
	(x, y, a, b) = map(int, input().split())
	lst = [x, y, a, b]
	n = 2
	j = 0
	if lst[j] == lst[j + 2] or lst[j] == lst[j + 3]:
		n = n - 1
	j = 1
	if lst[j] == lst[j + 1] or lst[j] == lst[j + 2]:
		n = n - 1
	print(n)


for i in range(int(input())):
	(x, y, a, b) = map(int, input().split())
	count = 0
	arr1 = [x, y]
	arr2 = [a, b]
	count1 = arr2.count(x)
	count2 = arr2.count(y)
	count = count1 + count2
	max_medal = 2 - count
	print(max_medal)


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	count = 0
	if a != c and a != d and (b != c) and (b != d):
		count = 2
	elif a != c and a != d:
		count = 1
	elif b != c and b != d:
		count = 1
	print(count)


for i in range(int(input())):
	(x1, y1, a, b) = map(int, input().split())
	if len(set([x1, y1, a, b])) == len([x1, y1, a, b]):
		print(2)
	elif len(set([x1, y1, a, b])) == 3:
		print(1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(x, y, z, a) = map(int, input().split(' '))
	m = 2
	l1 = [x, y]
	l2 = [z, a]
	if x in l2:
		m -= 1
	if y in l2:
		m -= 1
	print(m)


t = int(input())
for i in range(t):
	(x, y, a, b) = [int(e) for e in input().split()]
	count = 2
	if x == a or x == b:
		count -= 1
	if y == a or y == b:
		count -= 1
	print(count)


for _ in range(int(input())):
	(chefA, chefB, rivalA, rivalB) = map(int, input().split())
	possible_wins = 2
	if chefA in [rivalA, rivalB]:
		possible_wins -= 1
	if chefB in [rivalA, rivalB]:
		possible_wins -= 1
	print(possible_wins)


tc = int(input())
for _ in range(tc):
	(c1, c2, d1, d2) = map(int, input().split())
	if c1 == d1 and c2 == d2 or (c1 == d2 and c2 == d1):
		print('0')
	elif c1 != d1 and c2 != d2 and (c1 != d2) and (c2 != d1):
		print('2')
	else:
		print('1')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	c = len(a)
	d = len(set(a))
	if c == d:
		print('2')
	elif d == 3:
		print('1')
	else:
		print('0')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	if a == c or a == d:
		if b == c or b == d:
			print('0')
		else:
			print('1')
	elif b == c or b == d:
		if a == c or a == d:
			print('0')
		else:
			print('1')
	else:
		print('2')


t = int(input())
for _ in range(t):
	races = list(map(int, input().split(' ')))
	result = 4 - sum(list(map(lambda x: x in races[2:], races)))
	print(result)


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


for i in range(int(input())):
	(w, x, y, z) = map(int, input().split())
	if w == y and x == z or (w == z and x == y):
		print(0)
	elif w != y and x != z and (w != z) and (x != y):
		print(2)
	else:
		print(1)


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


T = int(input())
for i in range(T):
	(A, B, X, Y) = map(int, input().split())
	c = 0
	if A != X and A != Y:
		c += 1
	if B != X and B != Y:
		c += 1
	print(c)


T = int(input())
for i in range(T):
	(x, y, a, b) = map(int, input().split(' '))
	if x in (a, b) and y in (a, b):
		print(0)
	elif x not in (a, b) and y not in (a, b):
		print(2)
	elif x in (a, b) or y in (a, b):
		print(1)


for _ in range(int(input())):
	s = set(map(int, input().split()))
	print(len(s) - 2)


a = 0
for i in range(int(input())):
	lst = set(map(int, input().split()))
	print(len(lst) - 2)


t = int(input())
for i in range(0, t):
	x = set(map(int, input().split()))
	print(len(x) - 2)


t = int(input())
for i in range(t):
	lis = list(map(int, input().split()))
	a = len(set(lis))
	if a == 4:
		print(2)
	elif a == 3:
		print(1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(x, y, a, b) = map(int, input().split())
	if x == a:
		if y == b:
			print(0)
		else:
			print(1)
	elif x == b:
		if y == a:
			print(0)
		else:
			print(1)
	elif y == a:
		if x == b:
			print(0)
		else:
			print(1)
	elif y == b:
		if x == a:
			print(0)
		else:
			print(1)
	else:
		print(2)


def chef(a, b, x, y):
	if (a == x or a == y) and (b == y or b == x):
		return 0
	elif (a != x or a != y) and (b == x or b == y):
		return 1
	elif (a == x or a == y) and (b != x or b != y):
		return 1
	else:
		return 2
t = int(input())
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	v = chef(a, b, x, y)
	print(v)


h = int(input())
for i in range(h):
	(a, b, c, d) = map(int, input().split())
	x = [a, b]
	y = [c, d]
	if c in x and d in x:
		print(0)
	elif c in x or d in x:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	wins = 2
	if a == c or a == d:
		wins = wins - 1
	if b == c or b == d:
		wins = wins - 1
	print(wins)


T = int(input())
for i in range(T):
	(A, B, X, Y) = map(int, input().split())
	l1 = [A, B]
	l2 = [X, Y]
	c = 0
	for j in l1:
		if j not in l2:
			c += 1
	print(c)


for t in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	gold = 0
	if a != x and a != y:
		gold += 1
	if b != x and b != y:
		gold += 1
	print(gold)


t = int(input())
for i in range(t):
	(a, b, p, q) = map(int, input().split())
	if (a == p or a == q) and (b == p or b == q):
		print(0)
	elif (a == p or a == q) or (b == p or b == q):
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	if len(l) == len(set(l)):
		print(2)
	elif len(l) - len(set(l)) == 1:
		print(1)
	else:
		print(0)


n = int(input())
for i in range(n):
	(a, b, c, d) = list(map(int, input().split()))
	list1 = [a, b]
	list2 = [c, d]
	c = 0
	for i in list1:
		if i not in list2:
			c = c + 1
	print(c)


T = int(input())
for _ in range(T):
	(X, Y, A, B) = map(int, input().split())
	if (X == A or X == B) and (Y == A or Y == B):
		print(0)
	elif X == A or X == B or Y == A or (Y == B):
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(x, y, a, b) = list(map(int, input().split()))
	total = 2
	if x in [a, b]:
		total -= 1
	if y in [a, b]:
		total -= 1
	print(total)


t = int(input())
for i in range(t):
	(x, y, a, b) = map(int, input().split())
	c = 0
	lst = [x, y]
	for i in lst:
		if i in [a, b]:
			c += 1
	print(2 - c)


import math
n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	if (a == c or a == d) and (b == c or b == d):
		print(0)
	elif (a == c or a == d) or (b == c or b == d):
		print(1)
	else:
		print(2)