Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

You have prepared four problems. The difficulty levels of the problems are A_{1}, A_{2}, A_{3}, A_{4} respectively. A problem set comprises at least two problems and no two problems in a problem set should have the same difficulty level. A problem can belong to at most one problem set. Find the maximum number of problem sets you can create using the four problems. 

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

- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains four space-separated integers A_{1}, A_{2}, A_{3}, A_{4},  denoting the difficulty level of four problems.

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

For each test case, print a single line containing one integer - the maximum number of problem sets you can create using the four problems.

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

$1 ≤ T ≤ 1000$
$1 ≤ A_{1}, A_{2}, A_{3}, A_{4} ≤ 10$

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

Subtask #1 (100 points): Original constraints

----- Sample Input 1 ------ 
3
1 4 3 2
4 5 5 5
2 2 2 2
----- Sample Output 1 ------ 
2
1
0
----- explanation 1 ------ 
Test case $1$: You can prepare the first problem set using the first two problems and the second problem set using the next two problems. So the problem sets will be $[1, 4]$ and $[3, 2]$.

Test case $2$: You can prepare one problem set using one problem having a difficulty level of $4$ and the other having a difficulty level of $5$. There is no way to prepare more than one problem set.

Test case $3$: There is no way to prepare a problem set.

Difficulty: EASY
Tags: Sorting

Constructive algorithms

Data structures

Ad-hoc
Skill types: Sorting

Data structures

Starter code:

Solutions:
T = int(input())
for i in range(T):
	l = list(map(int, input().split()))
	a = set(l)
	if len(a) == 4:
		print(2)
	elif len(a) == 3:
		print(2)
	elif len(a) == 2:
		l.sort()
		b = l[0]
		if l.count(b) == 2:
			print(2)
		else:
			print(1)
	else:
		print(0)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	b = set(a)
	l = len(b)
	print(0 if l == 1 else 2 if l > 2 else 2 if a.count(a[0]) == 2 else 1)


h = int(input())
for i in range(h):
	l = list(map(int, input().split()))
	P = len(set(l))
	print(0 if P == 1 else 2 if P > 2 else 2 if l.count(l[0]) == 2 else 1)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	x = len(set(l))
	print(0 if x == 1 else 2 if x > 2 else 2 if l.count(l[0]) == 2 else 1)


for i in range(int(input())):
	n = sorted(list(map(int, input().split())))
	if n[1] != n[2] or (n[1] == n[2] and n[2] != n[3] and (n[0] != n[1])):
		print('2')
	elif n[0] == n[3]:
		print('0')
	else:
		print('1')


test_cases = int(input())
for _ in range(test_cases):
	n = list(map(int, input().split()))
	n.sort()
	if n[1] != n[2] or (n[1] == n[2] and n[2] != n[3] and (n[0] != n[1])):
		print('2')
	elif n[0] == n[3]:
		print('0')
	else:
		print('1')


from collections import Counter
for _ in range(int(input())):
	l = list(map(int, input().split()))
	C = dict(Counter(l))
	m = max(C.values())
	if m < 3:
		print(2)
	elif m == 3:
		print(1)
	else:
		print(0)


from collections import Counter
t = int(input())
for ni in range(t):
	l = [int(i) for i in input().split()]
	a = list(set(l))
	if len(a) == 1:
		print(0)
	elif len(a) == 3 or len(a) == 4:
		print(2)
	elif l.count(a[0]) == 2:
		print(2)
	else:
		print(1)


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	c = 1
	for k in range(0, 3, 1):
		for j in range(k + 1, 4, 1):
			if a[k] == a[j]:
				c += 1
		if c > 1:
			break
	if c == 1 or c == 2:
		print('2')
	elif c == 3:
		print('1')
	elif c == 4:
		print('0')


from collections import Counter
for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	a = dict(Counter(a))
	a = max(a.values())
	if a == 4:
		print(0)
	elif a == 3:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	x = len(set(l))
	if x == 4 or x == 3:
		print(2)
	elif x == 2:
		l.sort()
		if l.count(l[0]) == 2:
			print(2)
		else:
			print(1)
	else:
		print(0)


t = int(input())
while t > 0:
	l = list(map(int, input().split()))
	k = set(l)
	if len(k) == 4 or len(k) == 3:
		print(2)
	elif len(k) == 2:
		l.sort()
		if l.count(l[0]) == 2:
			print(2)
		else:
			print(1)
	else:
		print(0)
	t = t - 1


for _ in range(int(input())):
	l = list(map(int, input().split()))
	s = set(l)
	if len(s) == 4 or len(s) == 3:
		print(2)
	elif len(s) == 2:
		l.sort()
		p = l[0]
		if l.count(p) == 2:
			print(2)
		else:
			print(1)
	else:
		print(0)


t = int(input())
while t:
	a = sorted([int(i) for i in input().split()])
	if a[1] != a[2]:
		print(2)
	elif a[1] == a[2] and a[2] != a[3] and (a[0] != a[1]):
		print(2)
	elif a[0] == a[3]:
		print(0)
	else:
		print(1)
	t -= 1


for tc in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	if a[1] != a[2]:
		print(2)
	elif a[1] == a[2] and a[2] != a[3] and (a[0] != a[1]):
		print(2)
	elif a[0] == a[3]:
		print(0)
	else:
		print(1)


t = int(input())
for t in range(t):
	arr = [int(i) for i in input().split()]
	d = {}
	for a in arr:
		if a in d:
			d[a] += 1
		else:
			d[a] = 1
	s = set(arr)
	if len(s) == 1:
		print(0)
	elif len(s) == 2:
		flag = 1
		for key in d:
			if d[key] == 3:
				flag = 0
		if flag == 0:
			print(1)
		else:
			print(2)
	elif len(s) >= 3:
		print(2)


from math import sqrt, ceil, floor, gcd, log2
import sys
from sys import stdin, stdout
from collections import Counter, defaultdict, OrderedDict, deque
from itertools import combinations, groupby
from time import time
from heapq import heappop, heappush, heapify
for t in range(int(input())):
	ai = input().split()
	setai = set(ai)
	print(0 if len(setai) == 1 else 2 if len(setai) > 2 else 2 if ai.count(ai[0]) == 2 else 1)


t = int(input())
from collections import Counter
for _ in range(t):
	srt = sorted(list(map(int, input().split())))
	st = Counter(srt)
	ln = len(st)
	if ln == 1:
		print(0)
	elif ln == 2:
		if st[srt[0]] == 2:
			print(2)
		else:
			print(1)
	else:
		print(2)


for t in range(int(input())):
	ai = input().split()
	setai = set(ai)
	print(0 if len(setai) == 1 else 2 if len(setai) > 2 else 2 if ai.count(ai[0]) == 2 else 1)


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


for i in range(int(input())):
	l = list(map(int, input().split()))
	arr = set(l)
	if len(arr) == 4:
		print(len(arr) // 2)
	elif len(arr) == 3:
		print(2)
	elif len(arr) == 2:
		m = min(l)
		if l.count(m) == 2:
			print(2)
		else:
			print(1)
	else:
		print(0)


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


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


import math
for i in range(int(input())):
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(0)
	elif len(set(a)) == 2 and a.count(a[0]) == 2:
		print(2)
	elif len(set(a)) == 2 and a.count(a[0]) != 2:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	count = 0
	d = {}
	for e in a:
		d[e] = d.get(e, 0) + 1
	t = []
	for e in d:
		t.append(d[e])
	if len(d) == 1:
		print(0)
	else:
		while 1:
			t.sort()
			if t[-1] == 0 or t[-2] == 0:
				break
			n = min(t[-1], t[-2])
			count += n
			t[-1] -= n
			t[-2] -= n
		print(count)


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = [a, b, c, d]
	t = []
	for item in l:
		z = l.count(item)
		t.append(z)
		t.sort()
	if t.count(1) == 4:
		print('2')
	else:
		print(4 - t[3])


for _ in range(int(input())):
	(a1, a2, a3, a4) = map(int, input().split())
	l = [a1, a2, a3, a4]
	s = set(l)
	if len(s) == 4 or len(s) == 3:
		print(2)
	elif len(s) == 2:
		y = min(l)
		if l.count(y) == 2:
			print(2)
		else:
			print(1)
	else:
		print(0)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	d = {}
	for i in arr:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	if len(d) == 4:
		print(2)
	else:
		print(4 - max(d.values()))


from collections import Counter, UserString
from math import log2
mod = lambda n: int(n % (10 ** 9 + 7))
_fc = [1]
for i in range(1, 1000001):
	_fc.append(i * _fc[i - 1])
	_fc[i] = mod(_fc[i])

def fact(n):
	if -1000001 < n < 1000001:
		if n > -1:
			return _fc[n]
		else:
			return int('-' + str(_fc[abs(n)]))
	else:
		raise ValueError('values only from 1000000 to -1000000 can be factorialized\n')

def yn(b, caps=False, y='Yes', n='No'):
	if b:
		returning = y
	else:
		returning = n
	if caps == 2:
		return returning.lower()
	elif caps == 3:
		return ''.join([returning[i].lower() if i % 2 == 0 else returning[i].upper() for i in range(len(returning))])
	elif caps:
		return returning.upper()
	return returning

def prob(l, n):
	return l.count(n) / len(l)

def isSubseq(s1, s2):
	(n, m) = (len(s1), len(s2))
	(i, j) = (0, 0)
	while i < n and j < m:
		if s1[i] == s2[j]:
			i += 1
		j += 1
	return i == n

def isPrime(n):
	if n > 1:
		for i in range(2, int(n ** 0.5) + 1):
			if not n % i:
				return False
		else:
			return True
	return True

def percentDiff(n, diff):
	return n + n * (diff / 100)

def prodLst(l1, nl):
	if isinstance(nl, int):
		return [i * nl for i in l1]
	else:
		return [i * j for (i, j) in zip(l1, nl)]

def divLst(l1, nl, mxMn=False):
	if isinstance(nl, int):
		return [i // nl for i in l1]
	elif mxMn:
		return [max(i, j) // min(i, j) for (i, j) in zip(l1, nl)]
	else:
		return [i // j for (i, j) in zip(l1, nl)]

def modLst(l, n):
	return [i % n for i in l]

def sumLst(l1, nl):
	if isinstance(nl, int):
		return [i + nl for i in l1]
	else:
		return [i + j for (i, j) in zip(l1, nl)]

def absLst(l):
	return [abs(i) for i in l]

def diffLst(l1, nl, isAbs=False):
	if isinstance(nl, int):
		returning = [i - nl for i in l1]
	else:
		returning = [i - j for (i, j) in zip(l1, nl)]
	if isAbs:
		return absLst(returning)
	else:
		return returning

def remCommonOccurs(l, remLst):
	srl = set(remLst)
	returning = []
	for i in l:
		if i not in remLst:
			returning.append(i)
	return returning

def remPosNeg(l, posNeg=False):
	returning = []
	if not posNeg:
		for i in l:
			if i >= 0:
				returning.append(i)
	else:
		for i in l:
			if i < 0:
				returning.append(i)
	return returning

def flip(nl):
	if isinstance(nl, int):
		return -nl
	elif isinstance(nl, list):
		return [-i for i in nl]

def ev(n):
	return not n & 1

def decimal(n):
	returning = int(n)
	if list(set(str(n)[str(n).index('.') + 1:])) == ['0']:
		return returning
	else:
		return returning + 1

def printdeci(n):
	print(decimal(n))

def printabs(n):
	print(abs(n))

def printm(n):
	print(mod(n))

def printy(b, caps=False, y='Yes', n='No'):
	print(yn(b, caps, y, n))

class mutableStr(UserString):

	def ins(self, n, s):
		if n < 0:
			self.data = self.data = ''.join(list(self.data)[:n + 1]) + s + ''.join(list(self.data)[n + 1:])
		else:
			self.data = ''.join(list(self.data)[:n]) + s + ''.join(list(self.data)[n:])

	def rem(self, s):
		self.data = self.data.replace(s, '')
alphabetOrd = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]
alphabet = list('abcdefghijklmnopqrstuvwxyz')
bint = lambda b: int(str(b), 2)
r2 = lambda n: range(1, n + 1)
rl = lambda *l: range(len(l[0])) if len(l) == 1 else range(l[0], len(l[1]))
alph = lambda s: s.isalpha()
sl = lambda l: list(set(l))
inf = float('inf')
soi = lambda : sorted(input())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
si = lambda : mutableStr(str(input()))
lsi = lambda : list(input())
sepi = lambda : map(int, input().split())
seti = lambda : set(map(int, input().split()))
for t in range(int(input())):
	difficulties = li()
	check = Counter(difficulties).values()
	printy(max(check) == 1, 0, 2, abs(len(difficulties) - max(check)))


for i in range(int(input())):
	A = list(map(int, input().split()))
	B = []
	for j in range(len(A)):
		B.append(A.count(A[j]))
	if max(B) == 1:
		print(2)
	else:
		print(len(A) - max(B))


testCases = int(input())
for _ in range(testCases):
	count = 0
	x = [int(x) for x in input().split()]
	x.sort()
	evaluate = True
	for i in range(3):
		j = i + 1
		if x[i] == x[j]:
			count += 1
	if count > 2:
		print('0')
	elif count == 2 and x[1] == x[2]:
		print('1')
	else:
		print('2')


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	lis = []
	for i in range(len(a)):
		if a.count(a[i]) == 1 or a.count(a[i]) == 2:
			lis.append(a[i])
	if len(lis) == 0:
		print(0)
	elif len(lis) == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	a = list(map(int, input().split(' ')))
	n = len(set(a))
	if n >= 3:
		print(2)
	elif n == 1:
		print(0)
	else:
		a.sort()
		if a[1] == a[2]:
			print(1)
		else:
			print(2)


for i in range(int(input())):
	A = list(map(int, input().split()))
	B = set(A)
	if len(B) == 1:
		print(0)
	elif len(B) == 4 or len(B) == 3:
		print(2)
	else:
		x = 0
		for z in range(4):
			if A[z] == A[0]:
				x += 1
		if x == 1 or x == 3:
			print(1)
		else:
			print(2)


from collections import Counter
for z in range(int(input())):
	l = sorted([int(i) for i in input().split()])
	d = Counter(l)
	o_c = list(d.values()).count(1)
	if o_c % 2 == 0:
		if len(set(l)) == 1:
			print(0)
		else:
			print(2)
	else:
		print(1)


t = int(input())
while t > 0:
	c = list(map(int, input().strip().split()))
	v = []
	for i in c:
		v.append(c.count(i))
	if max(v) == 1:
		print('2')
	else:
		print(4 - max(v))
	t = t - 1


for x in range(int(input())):
	A = input().split()
	group = []
	for x in A:
		group.append(A.count(x))
	if max(group) == 1:
		print('2')
	else:
		print(4 - max(group))


t = int(input(''))
if 1 <= t <= 1000:
	for _ in range(t):
		a = input().split()
		max = 1
		for i in a:
			if 1 <= int(i) <= 10:
				if a.count(i) >= max:
					max = a.count(i)
			else:
				max = 5
		if max == 1:
			print(2)
		elif max == 2:
			print(2)
		elif max == 3:
			print(1)
		elif max == 4:
			print(0)
		else:
			pass


for _ in range(int(input())):
	l = list(map(int, input().strip().split()))
	m = []
	for i in l:
		m.append(l.count(i))
	if max(m) == 1:
		print('2')
	else:
		print(4 - max(m))


for t in range(int(input())):
	b = list(map(int, input().split()))
	a = set(b)
	if len(a) == 1:
		print(0)
	elif len(a) == 2 and b.count(b[0]) != 2:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	l = list(map(int, input().split()))[:4]
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] = d[i] + 1
	if len(d) == 1:
		print(0)
	elif len(d) == 2:
		v = set(list(d.values()))
		if len(v) == 1:
			print(2)
		else:
			print(1)
	else:
		print(2)


for i in range(int(input())):
	list1 = list(map(int, input().split()))
	max1 = list1[0]
	for j in list1:
		if j > max1:
			max1 = j
	list2 = [0 for x in range(max1 + 1)]
	for l in list1:
		list2[l] += 1
	max2 = list2[0]
	for s in list2:
		if s > max2:
			max2 = s
	if max2 == 4:
		print(0)
	elif max2 == 3:
		print(1)
	elif max2 == 2:
		print(2)
	else:
		print(2)


for _ in range(int(input())):
	s = list(map(int, input().split()))
	n = len(set(s))
	if n == 1:
		print(0)
	elif n in (3, 4):
		print(2)
	elif s.count(s[0]) == 2:
		print(2)
	else:
		print(1)