Read problems statements in Mandarin chinese, Russian and Vietnamese as well. 

Chef has a sequence A containing N integers A_{1}, A_{2}, ..., A_{N}.

Chef is playing a game with this sequence. In this game, he may perform the following operation any number of times (including zero): Choose an arbitrary pair of elements from the sequence such that their sum is even, delete these two elements from the sequence and insert their sum into the sequence instead.

The goal of the game is to minimise the number of elements in the sequence.

Help Chef to play the game and find the minimum possible size of the sequence at the end of the game!

------ Input ------ 

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.
The second line contains N space-separated integers A_{1}, A_{2}, ..., A_{N}.

------ Output ------ 

For each test case, print a single line containing one integer — the minimum possible final size of the sequence.

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

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$1 ≤ A_{i} ≤ 1,000 for each valid i$

------ Subtasks ------ 

Subtask #1 (100 points): original constraints

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

Source: codechef | Difficulty: EASY
Tags: Constructive algorithms

Ad-hoc


Solutions:
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	odd = sum([1 for x in a if x % 2])
	print(odd % 2 + 1)


x = int(input())
for i in range(x):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	for j in range(n):
		s = s + a[j]
	if s % 2 == 1 and n > 1:
		print('2')
	else:
		print('1')


for i in range(int(input())):
	a = int(input())
	lst = list(map(int, input().split()))
	odd_count = 0
	for num in lst:
		if num % 2 == 1:
			odd_count += 1
	if a == 1:
		print(1)
	elif odd_count % 2 == 1:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	for j in l:
		if j % 2 != 0:
			c += j
	if c % 2 != 0 and n > 1:
		print(2)
	else:
		print(1)


for i in range(int(input())):
	n = int(input())
	A = [int(x) for x in input().split()]
	odd = 0
	for x in A:
		if x % 2 == 1:
			odd += 1
	if len(A) == 1:
		print(1)
		continue
	if odd % 2 != 0:
		print(2)
	else:
		print(1)


def minimise(length, l):
	for i in range(0, length):
		for j in range(i + 1, length):
			if (l[j] + l[i]) % 2 == 0:
				l[i] = l[j] + l[i]
				l.remove(l[j])
				return minimise(len(l), l)
	return length
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(minimise(n, l))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) % 2 == 0 or n == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	no = 0
	if n == 1:
		print('1')
		continue
	for i in l:
		if i % 2:
			no += 1
	print(no % 2 + 1)


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	a = []
	c = []
	for i in range(n):
		if b[i] % 2 == 0:
			c.append(b[i])
		if b[i] % 2 != 0:
			a.append(b[i])
	if sum(a + c) % 2 == 0:
		print(1)
	else:
		print(2)


T = int(input())
for i in range(T):
	n = int(input())
	o1 = 0
	e1 = 0
	lst = list(map(int, input().split()))
	for i in range(n):
		if lst[i] & 1:
			o1 += 1
		else:
			e1 += 1
	if o1 == 1 and e1 == 0:
		print(1)
	elif o1 & 1:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) % 2 == 0 or n == 1:
		print(1)
	else:
		print(2)


t = int(input())
while t:
	n = int(input())
	series = [int(k) for k in input().split()]
	sum1 = int(0)
	for i in range(n):
		sum1 = sum1 + series[i]
	if sum1 % 2 == 1 and n > 1:
		print('2')
	else:
		print('1')
	t = t - 1


t = int(input())
while t:
	n = int(input())
	oddcount = int(0)
	series = [int(k) for k in input().split()]
	for i in range(n):
		if series[i] % 2 == 1:
			oddcount = oddcount + 1
	if n == 1:
		print('1')
	elif oddcount % 2 == 1:
		print('2')
	else:
		print('1')
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	even = []
	odd = []
	for i in range(n):
		if a[i] % 2 == 0:
			even.append(a[i])
		else:
			odd.append(a[i])
	if len(odd) % 2 != 0 and n > 1:
		print('2')
	else:
		print('1')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	for i in range(n):
		if a[i] % 2 != 0:
			count += a[i]
	if count % 2 != 0 and n > 1:
		print('2')
	else:
		print('1')


for i in range(int(input())):
	n = int(input())
	oddlst = []
	lst = list(map(int, input().split()))
	for i in range(n):
		if lst[i] % 2 == 1:
			oddlst.append(lst[i])
	if n == 1:
		print(1)
	elif len(oddlst) % 2 == 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))[:n]
	o = 0
	for j in l:
		if j % 2 != 0:
			o += 1
	if o % 2 == 0 or (n == 1 and o == 1):
		print(1)
	else:
		print(2)


n = int(input())
for i in range(n):
	if int(input()) == 1:
		a = list(map(int, input().split()))
		del a
		print(1)
		continue
	print(int(not sum(list(map(int, input().split()))) % 2 == 0) + 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	e = 0
	o = 0
	for num in s:
		if num % 2 == 0:
			e = e + 1
		else:
			o = o + 1
	e = o // 2 + e
	o = o % 2
	while e // 2 > 0:
		e = e - e // 2
	print(e + o)


for _ in range(int(input())):
	x = int(input())
	list1 = list(map(int, input().split()))
	list1 = list(list1)
	if sum(list1) % 2 == 0 or len(list1) == 1:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	c = 0
	if len(l) == 1:
		print(1)
	else:
		for i in l:
			if i % 2 != 0:
				c = c + 1
		if c % 2 == 0:
			print(1)
		else:
			print(2)


for i in range(int(input())):
	a = int(input())
	f = list(map(int, input().split()))
	k = 0
	if a == 1:
		print(1)
	else:
		for i in range(a):
			if f[i] % 2 != 0:
				k += 1
		if k % 2 == 0:
			print(1)
		else:
			print(2)


def fun(l):
	for x in l:
		f = x
		for x in l:
			s = x
			if s != f:
				sum = f + s
				if sum % 2 == 0:
					l.remove(f)
					l.remove(s)
					l.append(sum)
					break
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	while n != 1:
		fun(l)
		n = n - 1
	print(len(l))


import random
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	f = sum(a) % 2
	if f == 0 or n == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = 0
	if n == 1:
		print(n)
	else:
		for i in l:
			if i % 2 == 1:
				o += 1
		print(o % 2 + 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = map(int, input().split())
	c = 0
	for j in a:
		j % 2 != 0
		c = c + j
	if c % 2 != 0 and n > 1:
		print('2')
	else:
		print('1')


test = int(input())
for I in range(test):
	n = int(input())
	lst = list(map(int, input().split()))
	sum = 0
	for i in lst:
		sum = sum + i
	if sum % 2 != 0 and n > 1:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) % 2 != 0 and n > 1:
		print('2')
	else:
		print('1')


for i in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	if N == 1:
		print(1)
	else:
		c = 0
		for i in A:
			if i % 2 == 1:
				c += i
		if c % 2 == 1:
			print(2)
		else:
			print(1)


for __ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = 0
	for k in l:
		if k % 2 != 0:
			o += 1
	if o % 2 == 0 or n == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = 0
	for i in arr:
		if i % 2:
			c += 1
	if c % 2 and n > 1:
		print(2)
	else:
		print(1)


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	even_count = 0
	odd_count = 0
	if N == 1:
		print(1)
	else:
		for i in A:
			if i % 2 == 0:
				even_count += 1
			else:
				odd_count += 1
		if odd_count % 2 != 0:
			print(2)
		else:
			print(1)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	odd = sum([1 for x in p if x % 2])
	print(odd % 2 + 1)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = 0
	b = 0
	for i in l:
		if i % 2 == 0:
			a += 1
		elif i % 2 == 1:
			b += 1
	if b % 2 == 1 and a == 0 and (b > 1) or (b % 2 == 1 and a != 0):
		print(2)
	else:
		print(1)


tc = int(input())
for _ in range(tc):
	len1 = int(input())
	arr = map(int, input().split())
	oddcount = 0
	for j in arr:
		if j % 2 != 0:
			oddcount += 1
	if oddcount % 2 != 0 and len1 > 1:
		print('2')
	else:
		print('1')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	odd = 0
	even = 0
	for j in l:
		if j % 2 == 0:
			even += 1
		else:
			odd += 1
	pe = even % 2
	po = odd % 2
	if pe == 0 and n > 1:
		print(pe + po + 1)
	elif pe == 0:
		print(pe + po)
	else:
		print(pe + po)


for i in range(int(input())):
	x = int(input())
	a = list(map(int, input().split()))
	b = 0
	c = 0
	for i in range(x):
		if a[i] % 2 == 0:
			b = b + 1
		else:
			c = c + 1
	if c % 2 == 1 and x > 1:
		print(2)
	else:
		print(1)