MoEngage has a bundle of N sticks. The i^{th} stick has a length L_{i} meters. 

Find the minimum number of sticks (of any length) you need to add to the bundle such that you can construct some [rectangles] where each stick of the bundle belongs to exactly one rectangle and each side of a rectangle should be formed with exactly one stick.

------ 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 line of each test case contains a single integer N, denoting the number of given sticks.
- The second line of each test case contains N space-separated integers L_{1}, L_{2}, \dots, L_{N}, denoting the length of the sticks.

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

For each test case, output in a single line, the minimum number of sticks you need to add to the bundle to satisfy the given conditions.

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

$1 ≤ T ≤ 1000$
$1 ≤ N ≤ 100$
$1 ≤ L_{i} ≤ 100$

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

----- Sample Output 1 ------ 
3
2
0
1

----- explanation 1 ------ 
Test case $1$: One possible way is to add $3$ sticks with lengths $1, 2,$ and $2$. Now, it is possible to construct a rectangle with one pair of opposite sides having a length of $1$ and another pair of opposite sides having a length of $2$.

Test case $2$: The optimal way is to add $2$ sticks with lengths $2$ and $5$. Now, it is possible to construct a rectangle with one pair of opposite sides having a length of $2$ and another pair of opposite sides having a length of $5$.

Test case $3$: There is no need to add more sticks to the bundle as it is possible to construct a rectangle using the given sticks.

Difficulty: MEDIUM

Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	dic = {}
	for i in L:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	(count, temp, total) = (0, 0, 0)
	for values in dic.values():
		count = values % 2
		temp += count
		total += values + count
	total = total % 4
	print(total + temp)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = a.copy()
	b = list(set(b))
	dic = []
	for x in b:
		dic.append(a.count(x) % 4)
	ones = dic.count(1)
	twos = dic.count(2) % 2
	threes = dic.count(3)
	if twos == 0:
		print(threes + ones // 2 * 2 + ones % 2 * 3)
	elif ones % 2 == 0:
		print(threes + ones // 2 * 2 + 2)
	else:
		print(threes + ones // 2 * 2 + 1)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = len(l)
	l.sort()
	if len(l) == 1:
		print(3)
	elif len(l) == 2:
		print(2)
	else:
		for i in l:
			if l.count(i) % 2 == 1:
				l.append(i)
		if len(l) % 4 == 0:
			print(len(l) - a)
		else:
			print(len(l) + 2 - a)


t = int(input())
for i in range(t):
	N = int(input())
	Li = list(map(int, input().split()))
	l = []
	Li.sort()
	for i in Li:
		if Li.count(i) % 2 != 0:
			Li.append(i)
	if len(Li) % 4 == 0:
		print(len(Li) - N)
	else:
		print(len(Li) - N + 2)


from collections import defaultdict
p = int(input())
a = 1
while p:
	e = defaultdict(lambda : 0)
	f = int(input())
	d = 0
	g = list(map(int, input().split()))
	for b in g:
		e[b] += a
	for b in e.keys():
		if e[b] % (2 * a) != 0:
			d += a
	c = len(g) + d
	while c % (4 * a) != 0:
		c += a
		d += a
	print(d)
	p -= 1


tests = int(input())
for i in range(tests):
	length = int(input())
	arr = list(map(int, input().split()))
	length_arr = [0] * 101
	for j in arr:
		length_arr[j] += 1
		length_arr[j] %= 4
	one_count_lengths = 0
	two_count_lengths = 0
	ans = 0
	for j in range(101):
		if length_arr[j] == 1:
			one_count_lengths += 1
		elif length_arr[j] == 2:
			two_count_lengths += 1
		elif length_arr[j] == 3:
			ans += 1
	ans += one_count_lengths // 2 * 2
	one_count_lengths %= 2
	if two_count_lengths & 1:
		if one_count_lengths:
			ans += 1
			one_count_lengths -= 1
		else:
			ans += 2
	if one_count_lengths:
		ans += 3
	print(ans)


for _ in range(int(input())):
	n = int(input())
	Li = list(map(int, input().split()))
	Mi = set(Li)
	count = 0
	for i in Mi:
		if Li.count(i) & 1:
			count += 1
	count += (len(Li) + count) % 4
	print(count)


import math
from bisect import bisect_left
from code import interact
from heapq import heapify, heappush, heappop
from collections import deque
from pydoc import plain
from re import X
import sys
from math import gcd, sqrt, log10, log2, floor, ceil, sqrt
input = sys.stdin.readline

def il():
	return [int(a) for a in input().strip().split()]

def ip():
	return input().strip()

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

def ot(in_p, *args, e=' '):
	if type(in_p) == list:
		print(*in_p, end=e)
	if type(in_p) == str or type(in_p) == int:
		print(in_p, end=e)
		for l in args:
			print(l, end=e)
	print()

def a_pwr_n(a, n, mod):
	if n == 1:
		return a % mod
	if n % 2 == 0:
		val = a_pwr_n(a, n // 2, mod)
		return val % mod * val % mod
	else:
		return a % mod * a_pwr_n(a, n - 1, mod) % mod

def rg(*ag):
	if len(ag) == 3:
		return range(ag[0], ag[1], ag[2])
	elif len(ag) == 2:
		return range(ag[0], ag[1])
	elif len(ag) == 1:
		return range(ag[0])
	else:
		raise 'invalid input'

def ispal(i, j, st):
	while i <= j:
		if st[i] == st[j]:
			i = i + 1
			j = j - 1
		else:
			return False
	return True
mod = 1000000000 + 7
dx = [-1, -2, 1, 2, 2, -2, -1, 1]
dy = [2, 1, 2, 1, -1, -1, -2, -2]
for t1 in range(ii()):
	count = 0
	n = ii()
	my_list = il()
	freq = {}
	for items in my_list:
		freq[items] = my_list.count(items)
	for i in set(my_list):
		if freq[i] % 2 != 0:
			count += 1
	print(count + (len(my_list) + count) % 4)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = set(a)
	(c, s) = (0, 0)
	for j in b:
		x = a.count(j)
		if x % 2 == 1:
			if x == 1:
				c += 1
				s += 1
			else:
				c += x // 2 + 1
				s += 1
		else:
			c += x // 2
	if c % 2 == 1:
		s += 2
	print(s)


from math import ceil
t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = set(a)
	(count1, total) = (0, 0)
	for i in b:
		c = a.count(i)
		if c % 2 == 1:
			count1 += ceil(c / 2)
			total += 1
		else:
			count1 += c // 2
	if count1 % 2 == 1:
		total += 2
	print(total)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	f = [0] * 101
	for i in l:
		x = (f[i] + 1) % 4
		f[i] = x
	c2 = 0
	c1 = 0
	for i in range(101):
		if f[i] == 3:
			c2 += 2
			c1 += 1
		elif f[i] == 2:
			c2 += 2
		elif f[i] == 1:
			c1 += 1
	ans = 0
	if c2 % 4 == 2:
		(c1, ans) = (c1 - 1, ans + 1) if c1 > 0 else (0, ans + 2)
	if c1 > 0:
		ans += c1 - 1 + 3 if c1 % 2 else c1
	print(ans)


T = int(input())
for t in range(T):
	num = int(input())
	L = [int(i) for i in input().split()]
	d = dict()
	for i in L:
		try:
			d[i] += 1
		except:
			d[i] = 1
	count = 0
	for i in d:
		if d[i] % 2 != 0:
			count += 1
	if (num + count) % 4 != 0:
		count += 2
	print(count)


t = int(input())
for x in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for y in l:
		if d.get(y):
			d[y] += 1
		else:
			d[y] = 1
	count = 0
	for m in d:
		if d[m] % 2 == 1:
			count += 1
	if (count + n) % 4 == 0:
		print(count)
	else:
		print(count + 2)


for _ in range(int(input())):
	n = int(input())
	li = [0] * 100
	for i in input().split():
		li[int(i) - 1] += 1
	c = 0
	cont = 0
	for i in range(100):
		if li[i] != 0:
			if li[i] % 2 == 1:
				li[i] += 1
				cont += 1
			c += li[i] // 2
	if c % 2 == 0:
		print(cont)
	else:
		print(cont + 2)


for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	d = {}
	x = len(arr)
	for i in arr:
		d[i] = d.get(i, 0) + 1
	cnt = 0
	for i in d:
		if d[i] % 2 != 0:
			cnt += 1
	x += cnt
	if x % 4 == 0:
		print(cnt)
	else:
		rem = 4 - x % 4
		print(rem + cnt)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = {x: 0 for x in l}
	for item in l:
		o[item] += 1
	for (key, value) in o.items():
		if value % 2 == 1:
			o[key] += 1
	total = sum(o.values())
	if total % 4 != 0:
		print(total - n + 2)
	else:
		print(total - n)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	count_1 = 0
	count = 0
	count_2 = 0
	count_3 = 0
	for i in arr:
		if d.get(i) == None:
			d[i] = 1
		else:
			d[i] += 1
	for i in d:
		if d[i] % 4 == 0:
			continue
		elif d[i] % 4 == 1:
			count_1 += 1
		elif d[i] % 4 == 2:
			count_2 += 1
		else:
			count_3 += 1
	if count_2 % 2 != 0:
		count_2 = 1
	else:
		count_2 = 0
	if count_1 > 0:
		if count_1 % 2 == 0:
			count += count_1 // 2 * 2
		else:
			count += count_1 // 2 * 2 + abs(2 * count_2 - 3)
			if count_2 == 1:
				count_2 = 0
	count += count_3
	count += count_2 * 2
	print(count)
	t -= 1


T = int(input())
for i in range(T):
	N = int(input())
	L = list(map(int, input().split()))
	count = []
	for i in set(L):
		count.append(L.count(i))
	res = 0
	for i in count:
		res += i % 2
	temp = res + len(L)
	res += temp % 4
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = map(int, input().split())
	d = [0] * 101
	if n <= 2:
		print(4 - n)
	else:
		res = 0
		count = 0
		for c in a:
			d[c] += 1
		for i in d:
			res += i % 2
			count += i
		count += res
		if count % 4 != 0:
			res += 4 - count % 4
		print(res)


T = int(input())
for _ in range(T):
	N = int(input())
	L = [int(x) for x in input().split()]
	if N == 1:
		print(3)
	elif N == 2:
		print(2)
	else:
		my_dict = dict(((x, L.count(x)) for x in set(L) if L.count(x) & 1))
		if (N + len(my_dict.keys())) % 4 == 0:
			print(len(my_dict.keys()))
		else:
			print(len(my_dict.keys()) + 2)


from collections import Counter
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	val = list(Counter(a).values())
	ct = 0
	for i in val:
		if i % 2 != 0:
			ct += 1
	if (n + ct) % 4 != 0:
		ct = ct + (n + ct) % 4
	print(ct)


from collections import defaultdict
yyyyyyyyy = 1
y = int(input())
for yy in range(y):
	yyy = defaultdict(lambda : 0)
	(yyyy, yyyyy) = (int(input()), yyyyyyyyy - yyyyyyyyy)
	yyyyyy = list(map(int, input().split()))
	for yyyyyyy in yyyyyy:
		yyy[yyyyyyy] += yyyyyyyyy
	for yyyyyyy in yyy.keys():
		if yyy[yyyyyyy] % (yyyyyyyyy + yyyyyyyyy) != yyyyyyyyy - yyyyyyyyy:
			yyyyy += yyyyyyyyy
	yyyyyyyy = len(yyyyyy) + yyyyy
	while yyyyyyyy % (yyyyyyyyy + yyyyyyyyy + yyyyyyyyy + yyyyyyyyy) != yyyyyyyyy - yyyyyyyyy:
		yyyyyyyy += yyyyyyyyy
		yyyyy += yyyyyyyyy
	print(yyyyy)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	nli = list(map(int, input().split()))
	sln = len(set(nli))
	counts = Counter(nli)
	no_of_odds = 0
	for (key, value) in counts.items():
		if value % 2 == 1:
			no_of_odds += 1
	sticks_to_be_added = no_of_odds
	if (n + sticks_to_be_added) % 4 != 0:
		sticks_to_be_added += 2
	print(sticks_to_be_added)


for i in range(int(input())):
	x = int(input())
	arr = [int(i) for i in input().split()]
	cnt = 0
	ans = 0
	while len(arr) > 0:
		t = arr.pop()
		if t in arr:
			arr.remove(t)
			cnt += 2
		else:
			ans += 1
			cnt += 2
		if cnt == 4:
			cnt = 0
	if cnt != 4 and cnt != 0:
		ans += 2
	print(ans)


from collections import Counter
t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	dic = {}
	dic = Counter(l)
	sum = 0
	count = 0
	for i in dic.values():
		sum = sum + i
		if i % 2 != 0:
			sum = sum + 1
			count = count + 1
	if sum % 4 != 0:
		count = count + 2
	print(count)
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	s = 0
	l = list(map(int, input().strip().split(' ')))
	p = sorted(set(l))
	for j in p:
		b = l.count(j)
		if b % 2 != 0:
			s = s + 1
	if (n + s) % 4 == 0:
		print(s)
	else:
		print(s + 2)


t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	s = sorted(set(ls))
	a = 0
	for x in s:
		c = ls.count(x)
		if c % 2 != 0:
			a += 1
	if (n + a) % 4 == 0:
		print(a)
	else:
		print(a + 2)


from collections import Counter
for x in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	sticks_pairs = Counter(L)
	sticks_needed = 0
	for (stick, count) in sticks_pairs.items():
		if count % 2 != 0:
			sticks_needed = sticks_needed + 1
	print((len(L) + sticks_needed) % 4 + sticks_needed)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	dict = {}
	for i in range(len(li)):
		if li[i] in dict:
			dict[li[i]] += 1
		else:
			dict[li[i]] = 1
	count = 0
	for i in dict.values():
		if i % 2 != 0:
			count += 1
	ans = n + count
	if ans % 4 == 0:
		print(ans - n)
	else:
		ans += 4 - ans % 4
		print(ans - n)


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = set(b)
	d = 0
	if a < 3:
		print(4 - a)
	else:
		for i in c:
			if b.count(i) % 2 != 0:
				d += 1
		if (d + a) % 4 == 0:
			print(d)
		else:
			print(d + 2)


from collections import defaultdict
c = 1
flag = 0
for _ in range(int(input())):
	dic = defaultdict(lambda : 0)
	(x, sticks_needed) = (int(input()), c - c)
	arr = list(map(int, input().split()))
	for i in arr:
		dic[i] += c
		flag += 1
	for i in dic.keys():
		if dic[i] % (c + c) != c - c:
			sticks_needed += c
	a = len(arr) + sticks_needed
	while a % (c + c + c + c) != c - c:
		a += c
		sticks_needed += c
	print(sticks_needed)


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	s1 = set(list1)
	ans = 0
	if n < 3:
		print(abs(n - 4))
	else:
		for i in s1:
			if list1.count(i) % 2 != 0:
				ans += 1
		if (ans + n) % 4 == 0:
			print(ans)
		else:
			print(ans + 2)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	ans = 0
	lis1 = set(lis)
	if n < 3:
		print(4 - n)
	else:
		for i in lis1:
			if lis.count(i) % 2 != 0:
				ans += 1
		if (ans + n) % 4 == 0:
			print(ans)
		else:
			print(ans + 2)


from collections import defaultdict
T = int(input())
for _ in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	dic = defaultdict(lambda : 0)
	for l in a:
		dic[l] += 1
	answer = 0
	for cnt in dic.values():
		if cnt % 2 == 1:
			answer += 1
	while (N + answer) % 4 != 0:
		answer += 1
	print(answer)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	length = list(map(int, input().split()))
	df = defaultdict(int)
	count = n
	for i in range(n):
		df[length[i]] += 1
	for j in df:
		if df[j] % 2:
			count += 1
	if count / 2 % 2:
		count += 2
	print(count - n)


from collections import Counter

def solve(arr):
	n = len(arr)
	counts = Counter(arr)
	no_of_odds = 0
	for (key, value) in counts.items():
		if value % 2 == 1:
			no_of_odds += 1
	sticks_to_be_added = no_of_odds
	if (n + sticks_to_be_added) % 4 != 0:
		sticks_to_be_added += 2
	return sticks_to_be_added

def print_output():
	for input_case in all_input_cases:
		output = solve(input_case)
		print(output)

def get_input():
	for i in range(t):
		tmp = input()
		all_input_cases.append(list(map(int, input().split())))
t = int(input().strip())
all_input_cases = []
get_input()
print_output()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	ans = 0
	c = Counter(l)
	for x in c:
		if c[x] % 2 == 1:
			n += 1
			ans += 1
	if n % 4 != 0:
		ans += 2
	print(ans)


from collections import Counter
for i in range(int(input())):
	n = int(input())
	L = Counter([int(i) for i in input().split()])
	freq_mod_2 = [[x // 2, x % 2] for x in list(L.values())]
	pair_sum = 0
	rem_sum = 0
	ans = 0
	for a in freq_mod_2:
		if a[0] % 2 != 0:
			a[0] += 1
			a[1] -= 1
			ans += 1
		pair_sum += a[0]
		rem_sum += a[1]
	if pair_sum % 2 != 0:
		ans += 2
	if rem_sum % 2 == 0:
		ans += rem_sum
	else:
		ans += rem_sum + 2
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	count = 0
	temp = Counter(L)
	for t in temp:
		if temp[t] % 2 != 0:
			n += 1
			count += 1
	if n % 4 != 0:
		count = count + 2
	print(count)


from sys import stdin, stdout
from collections import defaultdict
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pairs = 0
	ans = 0
	count = defaultdict(lambda : 0)
	for j in a:
		count[j] += 1
	for j in count.keys():
		val = count[j]
		pairs += val // 2
		val = val % 2
		if val == 1:
			ans += 1
			pairs += 1
	if pairs % 2 != 0:
		ans += 2
	print(ans)


from collections import defaultdict

def sticks_rec(arr):
	d = defaultdict(int)
	for x in arr:
		d[x] += 1
	double = False
	for x in d:
		d[x] = d[x] % 4
		if d[x] >= 2:
			if double:
				d[x] -= 2
				double = not double
			else:
				d[x] -= 2
				double = not double
	ones = 0
	for x in d:
		if d[x] == 1:
			ones += 1
	if ones == 0:
		if not double:
			return 0
		else:
			return 2
	elif ones == 1:
		if not double:
			return 3
		else:
			return 1
	elif ones % 2 == 0:
		if not double:
			return ones
		else:
			return 2 + ones
	elif not double:
		return ones - 1 + 3
	else:
		return ones
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(sticks_rec(arr))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pairs = []
	singles = []
	for i in l:
		if l.count(i) % 4 == 2 and i not in pairs:
			pairs.append(i)
		elif l.count(i) % 4 == 1 and i not in singles:
			singles.append(i)
		elif l.count(i) % 4 == 3 and i not in pairs:
			pairs.append(i)
			singles.append(i)
	if len(pairs) % 2 and len(singles) % 2:
		print(len(singles))
	elif len(singles) % 2:
		print(len(singles) + 2)
	elif len(pairs) % 2:
		print(len(singles) + 2)
	else:
		print(len(singles))
	del n
	del singles
	del pairs
	del l


n = int(input())
for i in range(n):
	n1 = int(input())
	l = list(map(int, input().split()))
	s = list(set(l))
	s1 = []
	for j in range(len(s)):
		s1.append(0)
	d = dict(zip(s, s1))
	for j in l:
		d[j] += 1
	c = 0
	t = 0
	for j in s:
		if d[j] % 2 != 0:
			c += 1
			t += d[j] // 2 + 1
		else:
			t += d[j] // 2
	if t % 2 != 0:
		c += 2
	print(c)


for _ in range(int(input())):
	N = int(input())
	single = set()
	for x in input().split():
		if x in single:
			single.remove(x)
		else:
			single.add(x)
	l = len(single)
	print(l + 4 - (l + N) % 4 if (l + N) % 4 else l)


import math

def sol(n, x):
	pass

def dictionary(arr):
	d = {}
	for x in arr:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	d = dictionary(lst)
	c = 0
	ans = 0
	l = len(lst)
	for x in d:
		if True:
			if d[x] % 2 == 0:
				c += d[x] // 2
			else:
				c += (d[x] + 1) // 2
				ans += 1
	if c % 2 != 0:
		ans += 2
	print(ans)


def solutions():
	t = int(input())
	for _ in range(t):
		n = int(input())
		li = [int(i) for i in input().split()]
		count = {}
		add = 0
		for i in li:
			if i not in count:
				count[i] = 0
			count[i] += 1
		for key in count.keys():
			if count[key] % 2 != 0:
				add += 1
		if (n + add) % 4 != 0:
			print(add + 2)
		else:
			print(add)
solutions()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	mp = defaultdict(int)
	for i in a:
		mp[i] += 1
	total = n
	for i in mp:
		if mp[i] & 1:
			total += 1
	total += total % 4
	print(total - n)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	(cnt, ttl) = ([0] * 101, n)
	for i in l:
		cnt[i] += 1
	for i in cnt:
		if i % 2 != 0:
			ttl += 1
	if ttl // 2 % 2 == 0:
		print(ttl - n)
	else:
		print(ttl + 2 - n)


for _ in range(int(input())):
	n = int(input())
	li = input().split()
	m = 0
	while len(li) > 0:
		element = li[0]
		cnt_of_element = 0
		for i in range(len(li) - 1, -1, -1):
			if li[i] == element:
				cnt_of_element += 1
				li.pop(i)
		m += cnt_of_element % 2
	if (n + m) % 4 != 0:
		m = m + (4 - (n + m) % 4)
	print(m)


def countsticks(N, L):
	Li = [0] * 101
	tot = 0
	for i in range(N):
		Li[L[i]] += 1
	for i in range(101):
		if Li[i] % 2:
			tot += 1
	if (tot + N) / 2 % 2:
		tot += 2
	return tot
t = int(input())
while t > 0:
	N = int(input())
	L = [int(x) for x in input().split(' ')]
	sticks = countsticks(N, L)
	print(sticks)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	count = 0
	s = set(lst)
	for i in s:
		if lst.count(i) % 2 != 0:
			count += 1
	res = (count + n) % 4
	ans = count
	if res > 0:
		ans = res + count
	print(ans)


import collections
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = collections.Counter(a)
	ans = 0
	for i in c:
		if c[i] % 2 != 0:
			ans += 1
	ans += (n + ans) % 4
	print(ans)


T = int(input())
check = 0
arr = []
while T:
	ans = 0
	N = int(input())
	arr = list(map(int, input().split()))
	var = len(arr)
	pair = 0
	single = 0
	i = 1
	while 0 < var:
		while i < len(arr):
			if arr[0] == arr[i]:
				rem = arr[i]
				check += 1
				break
			i += 1
		if check == 1:
			arr.remove(rem)
			arr.remove(rem)
			check = 0
			var -= 2
		else:
			arr.remove(arr[0])
			var -= 1
			single += 1
		i = 1
	if (single + N) % 4 == 0:
		print(single)
	else:
		print(single + 4 - (single + N) % 4)
	T = T - 1


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	c = 0
	d = defaultdict(int)
	for i in l:
		d[i] += 1
	for i in d:
		if d[i] & 1:
			c += 1
	if (c + n) % 4 != 0:
		print(c + 4 - (c + n) % 4)
	else:
		print(c)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mp = {}
	for i in arr:
		if i in mp:
			mp[i] += 1
		else:
			mp[i] = 1
	count = 0
	for i in mp:
		if mp[i] % 2 != 0:
			count += 1
	if (n + count) % 4 == 0:
		print(count)
	else:
		print(count + (4 - (n + count) % 4))


from calendar import c
from math import ceil
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	coun = dict()
	for i in l:
		if i in coun:
			coun[i] += 1
		else:
			coun[i] = 1
	two_c = 0
	one_c = 0
	for i in coun:
		two_c += coun[i] // 2
		one_c += coun[i] % 2
	two_c = two_c % 2
	ans = 0
	ans += one_c // 2 * 2
	one_c = one_c % 2
	if two_c == 1 and one_c == 1:
		ans += 1
	elif two_c == 0 and one_c == 1:
		ans += 3
	elif two_c == 1 and one_c == 0:
		ans += 2
	print(ans)


Cases = int(input())
Test = 1
while Test <= Cases:
	Test += 1
	n = int(input())
	A = input().split()
	for i in A:
		A.append(int(A[0]))
		A.remove(A[0])
	B = 0
	ans = 0
	b = []
	A.sort()
	while len(A) != 0:
		if len(A) > 1:
			if A[0] == A[1]:
				b.append(A[0])
				A.remove(A[0])
				A.remove(A[0])
			else:
				B += 1
				A.remove(A[0])
		else:
			B += 1
			A.remove(A[0])
	if len(b) % 2 != 0 and len(b) != 0:
		if B == 0:
			ans += 2
		else:
			B -= 1
			ans += 1
	if B != 0:
		if B % 2 == 0:
			ans += abs(B)
		else:
			ans += abs(B - 1)
			ans += 3
	print(int(ans))


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	n = len(A)
	ans = 0
	pair = 0
	countfre = [0] * (max(A) + 1)
	for j in A:
		countfre[j] += 1
	for k in countfre:
		if k % 2 != 0:
			ans += 1
		pair += (k + 1) // 2
	if pair % 2 != 0:
		ans += 2
	print(ans)


for _ in range(int(input())):
	size = int(input())
	inputList = list(map(int, input().split()))
	inputList.sort()
	pairCount = 0
	nonPairCount = 0
	totalCount = 0
	i = 0
	while i < len(inputList) - 1:
		if inputList[i] == inputList[i + 1]:
			pairCount += 1
			i += 2
		else:
			nonPairCount += 1
			i += 1
	if pairCount * 2 + nonPairCount < size:
		nonPairCount += 1
	oddpairCount = pairCount % 2
	if oddpairCount == 1:
		if nonPairCount >= 1:
			totalCount += 1
			nonPairCount -= 1
		else:
			totalCount += 2
	totalCount += nonPairCount // 2 * 2
	if nonPairCount % 2 != 0:
		totalCount += 3
	print(totalCount)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	dic = defaultdict(int)
	for i in l:
		dic[i] += 1
	if len(l) == 1:
		print(3)
	elif len(l) == 2:
		print(2)
	else:
		count = 0
		odd_count = 0
		for i in dic:
			if dic[i] % 2 == 1:
				odd_count += 1
			count += dic[i]
		if (count + odd_count) % 4 != 0:
			odd_count += 2
		print(odd_count)


t = int(input())
for _ in range(t):
	n = int(input())
	dic = {}
	a = input().split()
	for y in a:
		x = int(y)
		if x in dic:
			dic[x] = dic[x] + 1
		else:
			dic[x] = 1
	c = 0
	for x in dic:
		if dic[x] % 2 == 1:
			c = c + 1
			n = n + 1
	if n % 4 == 0:
		print(c)
	else:
		print(c + 2)


T = int(input())
for t in range(T):
	n = int(input())
	arr = [int(_) for _ in input().split()]
	freq = {}
	pairs = 0
	for i in arr:
		if i not in freq:
			freq[i] = 1
		else:
			freq[i] += 1
	for i in freq.values():
		pairs += i // 2
	temp = sum(freq.values()) - 2 * pairs
	if (pairs + temp) % 2 == 0:
		ans = temp
	else:
		ans = temp + 2
	print(ans)


for _ in range(int(input())):
	val = {}
	N = int(input())
	l = list(map(int, input().split()))
	for i in l:
		if i not in val:
			val[i] = 1
		else:
			val[i] += 1
	v = list(val.values())
	ans = 0
	for i in range(len(v)):
		if v[i] % 2 == 1:
			v[i] += 1
			ans += 1
	if sum(v) // 2 % 2 == 1:
		ans += 2
	print(ans)


from collections import Counter

def solve(arr):
	d = Counter(arr)
	singles = 0
	doubles = 0
	for i in list(d.values()):
		singles += i % 2
		doubles += i // 2
	ans = 0
	if doubles % 2:
		ans += 1
		singles -= 1
	b = singles % 2
	ans += singles + 2 * b
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr))


from collections import defaultdict as df
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = df(int)
	for i in a:
		d[i] += 1
	ans = 0
	for i in d:
		if d[i] % 2 == 1:
			d[i] += 1
			ans += 1
	pairs = 0
	for i in d:
		pairs += d[i] // 2
	if pairs % 2:
		ans += 2
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	total = 0
	for i in l:
		if l.count(i) % 2 == 0:
			pass
		else:
			total += 1
			l.append(i)
	if len(l) % 4 == 0:
		print(total)
	else:
		print(total + 2)


def cal(s, b):
	a = b[0] - 1
	y = 0
	d = 0
	for x in b:
		if x > a:
			c = b.count(x) % 2
			y = y + c
			d = b.count(x) + c + d
			a = x
	y = y + d % 4
	return y
i = int(input())
c = []
for x in range(0, i):
	s = int(input())
	b = [int(b) for b in input().split()]
	b.sort()
	d = cal(s, b)
	print(d)