A palindrome is a string $t$ which reads the same backward as forward (formally, $t[i] = t[|t| + 1 - i]$ for all $i \in [1, |t|]$). Here $|t|$ denotes the length of a string $t$. For example, the strings 010, 1001 and 0 are palindromes.

You have $n$ binary strings $s_1, s_2, \dots, s_n$ (each $s_i$ consists of zeroes and/or ones). You can swap any pair of characters any number of times (possibly, zero). Characters can be either from the same string or from different strings — there are no restrictions.

Formally, in one move you:  choose four integer numbers $x, a, y, b$ such that $1 \le x, y \le n$ and $1 \le a \le |s_x|$ and $1 \le b \le |s_y|$ (where $x$ and $y$ are string indices and $a$ and $b$ are positions in strings $s_x$ and $s_y$ respectively),  swap (exchange) the characters $s_x[a]$ and $s_y[b]$. 

What is the maximum number of strings you can make palindromic simultaneously?


-----Input-----

The first line contains single integer $Q$ ($1 \le Q \le 50$) — the number of test cases.

The first line on each test case contains single integer $n$ ($1 \le n \le 50$) — the number of binary strings you have.

Next $n$ lines contains binary strings $s_1, s_2, \dots, s_n$ — one per line. It's guaranteed that $1 \le |s_i| \le 50$ and all strings constist of zeroes and/or ones.


-----Output-----

Print $Q$ integers — one per test case. The $i$-th integer should be the maximum number of palindromic strings you can achieve simultaneously performing zero or more swaps on strings from the $i$-th test case.


-----Example-----
Input
4
1
0
3
1110
100110
010101
2
11111
000001
2
001
11100111

Output
1
2
2
2



-----Note-----

In the first test case, $s_1$ is palindrome, so the answer is $1$.

In the second test case you can't make all three strings palindromic at the same time, but you can make any pair of strings palindromic. For example, let's make $s_1 = \text{0110}$, $s_2 = \text{111111}$ and $s_3 = \text{010000}$.

In the third test case we can make both strings palindromic. For example, $s_1 = \text{11011}$ and $s_2 = \text{100001}$.

In the last test case $s_2$ is palindrome and you can make $s_1$ palindrome, for example, by swapping $s_1[2]$ and $s_1[3]$.

Source: codeforces | Difficulty: MEDIUM
Tags: String algorithms

Greedy algorithms


Solutions:
q = int(input())
for i in range(q):
	n = int(input())
	strings = []
	lengths = []
	zeros = 0
	ones = 0
	for i in range(n):
		strings.append(input())
		lengths.append(len(strings[-1]))
		zeros += strings[-1].count('0')
		ones += strings[-1].count('1')
	lengths = sorted(lengths)
	ans = 0
	for l in lengths:
		if l <= zeros + ones:
			if l % 2 == 1:
				if zeros % 2 == 1 and l <= zeros:
					ans += 1
					zeros -= l
				elif ones % 2 == 1 and l <= ones:
					ans += 1
					ones -= l
				else:
					if zeros % 2 == 1:
						zeros -= 1
					elif ones % 2 == 1:
						ones -= 1
					available_ones = ones // 2 * 2
					available_zeros = zeros // 2 * 2
					if available_zeros + available_ones >= l - 1:
						ans += 1
						used_zeros = min(available_zeros, l - 1)
						zeros -= used_zeros
						ones -= min(available_ones, l - 1 - used_zeros)
			else:
				available_ones = ones // 2 * 2
				available_zeros = zeros // 2 * 2
				if available_zeros + available_ones >= l:
					ans += 1
					used_zeros = min(available_zeros, l)
					zeros -= used_zeros
					ones -= min(available_ones, l - used_zeros)
	print(ans)


Q = int(input())
for something in range(Q):
	n = int(input())
	list1 = []
	count = 0
	even = 0
	flag = 0
	for _ in range(n):
		list1.append(input())
	for string in list1:
		ones = 0
		if len(string) % 2 == 0:
			for char in string:
				if char == '1':
					ones += 1
			if ones % 2 == 0:
				count += 1
			else:
				even += 1
		else:
			count += 1
			flag += 1
	if flag:
		print(n)
	else:
		print(count + even // 2 * 2)


q = int(input())
for _ in range(q):
	n = int(input())
	s = []
	ava = 0
	req = 0
	ans = 0
	for i in range(n):
		s = input()
		ones = 0
		zeros = 0
		for x in s:
			if x == '1':
				ones += 1
			else:
				zeros += 1
		if len(s) % 2 == 0:
			if ones % 2 != 0:
				req += 1
			else:
				ans += 1
		else:
			ava += 1
			ans += 1
	ans += 2 * (req // 2)
	req = req % 2
	if ava != 0 and req != 0:
		ans += 1
	print(ans)


t = [int(k) for k in input().split(' ')][0]
for k in range(t):
	n = [int(k) for k in input().split(' ')][0]
	s = []
	nb1 = 0
	isatleastoneimpair = False
	for k in range(n):
		s += [[int(k) for k in input()]]
		nb1 += sum(s[-1])
		isatleastoneimpair |= len(s[-1]) % 2
	print(n - (1 if nb1 % 2 and (not isatleastoneimpair) else 0))


t = int(input())
for _ in range(t):
	n = int(input())
	l = []
	c = 0
	r = 0
	for i in range(n):
		s = input()
		o = 0
		z = 0
		if len(s) % 2 == 1:
			c += 1
		else:
			for j in range(len(s)):
				if s[j] == '0':
					z += 1
				else:
					o += 1
			if z % 2 != 0 and o % 2 != 0:
				r += 1
	if r % 2 == 0 or c > 0:
		print(n)
	else:
		print(n - 1)


q = int(input())
for _ in range(q):
	n = int(input())
	l = []
	ones = 0
	zeros = 0
	for i in range(n):
		x = input()
		l.append(len(x))
		ones += x.count('1')
		zeros += x.count('0')
	l.sort()
	count = 0
	if ones > zeros:
		(zeros, ones) = (ones, zeros)
	for i in l:
		if i % 2 == 0:
			if ones // 2 + zeros // 2 >= i // 2:
				count += 1
				temp = ones // 2
				if temp >= i // 2:
					ones -= i
				else:
					ones -= 2 * temp
					zeros -= (i // 2 - temp) * 2
			else:
				break
		elif ones // 2 + zeros // 2 >= i // 2 and ones + zeros >= i:
			count += 1
			temp = ones // 2
			if temp >= i // 2:
				ones -= i // 2 * 2
			else:
				ones -= 2 * temp
				zeros -= (i // 2 - temp) * 2
			if ones % 2 == 1:
				ones -= 1
			else:
				zeros -= 1
			if zeros < 0:
				zeros = 0
				ones -= 1
		else:
			break
		if ones > zeros:
			(zeros, ones) = (ones, zeros)
	print(count)


import sys
inputs = sys.stdin.readline().split()
Q = int(inputs[0])
for _ in range(Q):
	inputs = sys.stdin.readline().split()
	n = int(inputs[0])
	zeros_count = 0
	ones_count = 0
	odd_strings = 0
	for _ in range(n):
		inputs = sys.stdin.readline().split()
		strg = inputs[0]
		zeros_count += strg.count('0')
		ones_count += strg.count('1')
		if len(strg) % 2 == 1:
			odd_strings += 1
	odd_nums = zeros_count % 2 + ones_count % 2
	if odd_strings >= odd_nums:
		print(n)
	else:
		print(n - 1)


def patate(m, l):
	zero = 0
	for h in l:
		if len(h) % 2 == 1:
			return m
		for x in h:
			if x == '0':
				zero += 1
	if zero % 2 == 1:
		return m - 1
	else:
		return m
n = int(input())
for _ in range(n):
	m = int(input())
	l = [input() for _ in range(m)]
	print(patate(m, l))


q = int(input())
for t in range(q):
	n = int(input())
	dl = []
	ed = 0
	nu = 0
	c1 = 0
	c2 = 0
	for i in range(n):
		s = input()
		for j in range(len(s)):
			if s[j] == '0':
				nu += 1
			else:
				ed += 1
		if len(s) % 2 == 0:
			c1 += 1
		else:
			c2 += 1
	v = 0
	if ed % 2 == 1:
		v += 1
	if nu % 2 == 1:
		v += 1
	if c2 >= v:
		print(n)
	else:
		print(n - 1)


q = int(input())
from collections import Counter
for i in range(q):
	n = int(input())
	count1 = 0
	count0 = 0
	long = []
	for j in range(n):
		s = input()
		long.append(len(s))
		c = Counter(s)
		count1 += c['1']
		count0 += c['0']
	odd = 0
	for item in long:
		if item % 2 == 1:
			odd += 1
	if count1 % 2 == 0 and count0 % 2 == 0:
		print(n)
	elif count1 % 2 == 1 and count0 % 2 == 1:
		if odd % 2 == 0 and odd != 0:
			print(n)
		else:
			print(n - 1)
	else:
		print(n)


T = int(input())
for t in range(T):
	n = int(input())
	s = [0] * n
	for i in range(n):
		s[i] = input()
	c0 = 0
	c1 = 0
	l = 0
	for i in range(n):
		l += len(s[i])
	for i in range(n):
		for j in range(len(s[i])):
			if s[i][j] == '0':
				c0 += 1
			else:
				c1 += 1
	if l % 2 == 1:
		print(n)
	elif c0 % 2 == 1:
		chk = 0
		for i in range(n):
			if len(s[i]) % 2 == 1:
				chk = 1
		if chk == 0:
			print(n - 1)
		else:
			print(n)
	else:
		print(n)


t = int(input())
for p in range(t):
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(input())
	a = []
	for d in arr:
		a.append([d.count('0') % 2, d.count('1') % 2])
	ans = 0
	ans1 = 0
	c = 0
	for d in a:
		if sum(d) == 1:
			ans += 1
		elif sum(d) == 0:
			ans1 += 1
		else:
			c += 1
	if c % 2 == 1 and ans == 0:
		c -= 1
	print(ans + ans1 + c)


q = int(input())
while q:
	q -= 1
	n = int(input())
	a = 0
	b = 0
	c = 0
	for i in range(n):
		s = input()
		c1 = 0
		c2 = 0
		for i in s:
			if i == '1':
				c1 += 1
			else:
				c2 += 1
		if c1 % 2 and c2 % 2:
			a += 1
		elif c1 % 2 == 0 and c2 % 2 == 0:
			c += 1
		else:
			b += 1
	if a % 2 == 0:
		print(n)
	elif b > 0:
		print(n)
	else:
		print(n - 1)


def solve():
	n = int(input())
	o = 0
	eb = 0
	eg = 0
	for _ in range(n):
		s = str(input())
		if len(s) & 1 != 0:
			o += 1
		elif len(s) & 1 == 0:
			if int(s.count('0')) % 2 == 0:
				eg += 1
			else:
				eb += 1
	res = 0
	if o == 0 and eb % 2 == 1:
		res = 1
	else:
		res = 0
	print(n - res)
t = int(input())
for _ in range(t):
	solve()


q = int(input())
for i in range(q):
	n = int(input())
	binary = []
	for i in range(n):
		string = input()
		binary.append(string)
	goododd = 0
	goodeven = 0
	badeven = 0
	for i in range(len(binary)):
		if len(binary[i]) % 2 != 0:
			goododd += 1
	for i in range(len(binary)):
		if len(binary[i]) % 2 == 0:
			size = len(binary[i])
			zero = 0
			one = 0
			for j in range(size):
				if binary[i][j] == '0':
					zero += 1
				else:
					one += 1
			if zero % 2 == 0 and one % 2 == 0:
				goodeven += 1
			elif goododd > 0:
				goodeven += 1
			elif badeven > 0:
				goodeven += 2
				badeven -= 1
			else:
				badeven += 1
	print(goododd + goodeven)


t = int(input())
for _ in range(t):
	n = int(input())
	l = []
	a = 0
	b = 0
	for i in range(n):
		s = input()
		l.append(len(s))
		for i in s:
			if i == '1':
				a += 1
			else:
				b += 1
	cnt = a % 2 + b % 2
	for i in l:
		cnt -= i % 2
		if cnt <= 0:
			break
	if cnt > 0:
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	s = []
	for __ in range(n):
		s.append(input())
	c = sum([x.count('1') for x in s])
	l = [len(x) for x in s]
	if 1 not in list(map(lambda x: x % 2, l)) and c % 2 == 1:
		print(n - 1)
	else:
		print(n)


q = int(input())
for i in range(q):
	n = int(input())
	s = []
	c = []
	c1 = 0
	all = 0
	ans = 0
	for j in range(n):
		s = str(input())
		if len(s) % 2 == 1:
			ans = n
		c.append(0)
		if len(s) == 1:
			continue
		for ch in range(len(s) // 2 + len(s) % 2):
			if len(s) // 2 == ch and len(s) % 2 == 1:
				continue
			if s[ch] != s[len(s) - 1 - ch]:
				c[j] += 1
		all += c[j]
	if ans == n:
		print(ans)
		continue
	if all % 2 == 0:
		ans = n
	else:
		ans = n - 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	odd_str = 0
	good_str = 0
	bad_str = 0
	for i in range(n):
		s = input()
		if len(s) % 2 != 0:
			odd_str += 1
		elif s.count('0') % 2 == 0 and s.count('1') % 2 == 0:
			good_str += 1
		else:
			bad_str += 1
	if bad_str % 2 != 0 and (not odd_str):
		print(n - 1)
	else:
		print(n)


for i in range(int(input())):
	n = int(input())
	s = []
	for j in range(n):
		s.append(input())
	one = 0
	zero = 0
	leng = 0
	even = 0
	odd = 0
	for j in s:
		l = len(j)
		leng += l
		if l % 2 == 0:
			even = 1
		else:
			odd = 1
		for k in j:
			if k == '1':
				one += 1
			else:
				zero += 1
	k = 0
	if leng % 2 == 0:
		if even == 1 and odd == 0:
			if one % 2 != 0 or zero % 2 != 0:
				k = 1
	print(n - k)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	N = int(readline())
	ZO = [0, 0]
	OE = [0, 0]
	for i in range(N):
		S = [1 if s == '1' else 0 for s in readline().strip()]
		OE[len(S) % 2] += 1
		for s in S:
			ZO[s] += 1
	if OE[1] > 0:
		Ans[qu] = N
	elif ZO[0] % 2 == 1:
		Ans[qu] = N - 1
	else:
		Ans[qu] = N
print('\n'.join(map(str, Ans)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	lengths = []
	zeros = 0
	ones = 0
	for s in range(n):
		binary = [int(i) for i in input()]
		for b in range(len(binary)):
			if binary[b] == 0:
				zeros += 1
			else:
				ones += 1
		lengths.append(len(binary))
	made = 0
	for s in range(n):
		if lengths[s] <= zeros + ones:
			if lengths[s] % 2 == 1:
				made += 1
				if ones <= zeros:
					rem = lengths[s] - ones
					ones = 0
					zeros -= rem
				else:
					rem = lengths[s] - zeros
					zeros = 0
					ones -= rem
			elif lengths[s] <= zeros - zeros % 2 + (ones - ones % 2):
				made += 1
				if ones <= zeros:
					rem = lengths[s] - (ones - ones % 2)
					ones -= ones - ones % 2
					zeros -= rem
				else:
					rem = lengths[s] - (zeros - zeros % 2)
					zeros -= zeros - zeros % 2
					ones -= rem
			else:
				break
		else:
			break
	print(made)


for i in range(int(input())):
	n = int(input())
	a = []
	z = 0
	suma = 0
	k = 0
	r = 0
	for i in range(n):
		s = input()
		if len(s) % 2 == 1:
			z = 1
		else:
			x1 = 0
			x2 = 0
			for j in range(len(s)):
				if s[j] == '0':
					x1 += 1
				else:
					x2 += 1
			if x1 % 2 == 0 and x2 % 2 == 0:
				k += 1
			else:
				r += 1
	if z == 1:
		print(n)
		continue
	if r % 2 == 0:
		print(n)
	else:
		print(r - 1 + k)


t = int(input())
for _ in range(t):
	n = int(input())
	has_odd = False
	even_dependant = 0
	for _ in range(n):
		a = input()
		if len(a) % 2 == 1:
			has_odd = True
			continue
		x = a.count('0')
		if x % 2 == 1:
			even_dependant += 1
	print(n - (not has_odd and even_dependant % 2 == 1))


from collections import defaultdict as dd
t = int(input())
for _ in range(t):
	n = int(input())
	d = dd(int)
	l = []
	d[0] = 0
	d[1] = 0
	for j in range(n):
		arr = list(map(int, input().strip()))
		l += [len(arr)]
		for i in arr:
			d[i] += 1
	l.sort()
	count = 0
	for i in l:
		if i % 2 == 1:
			count += 1
	if d[0] % 2 == 1 and d[1] % 2 == 1 and (count < 2):
		print(n - 1)
	else:
		print(n)


q = int(input())
for k in range(q):
	n = int(input())
	s = [input() for _ in range(n)]
	c = [0, 0]
	m_1 = []
	m_2 = []
	for i in range(n):
		if len(s[i]) % 2 == 0:
			m_2.append(len(s[i]))
		else:
			m_1.append(len(s[i]))
		for j in range(len(s[i])):
			if s[i][j] == '0':
				c[0] += 1
			else:
				c[1] += 1
	m_1.sort()
	m_2.sort()
	m = m_2 + m_1
	c.sort()
	ans = 0
	for i in range(n):
		if c[0] + c[1] < m[i]:
			break
		if c[-1] - m[i] >= 0:
			c[-1] -= m[i]
			ans += 1
		elif m[i] % 2 == 0:
			p = c[-1] // 2
			p *= 2
			m[i] -= p
			if c[0] - m[i] >= 0:
				ans += 1
				c[0] -= m[i]
			else:
				continue
		else:
			m[i] -= c[-1]
			if c[0] - m[i] >= 0:
				ans += 1
				c[0] -= m[i]
			else:
				continue
		c.sort()
	print(ans)


import math
n = int(input())
for i in range(n):
	k = int(input())
	L = []
	All = 0
	zero = 0
	one = 0
	for j in range(k):
		s = input()
		L.append(len(s))
		one += s.count('0')
		zero += s.count('1')
	L.sort()
	flag = False
	for m in range(k):
		x = 0
		if flag:
			break
		while x != L[m]:
			if L[m] - x > 1:
				if one > zero:
					if one < 2:
						print(m)
						flag = True
						break
					else:
						x += 2
						one -= 2
				elif zero < 2:
					print(m)
					flag = True
					break
				else:
					x += 2
					zero -= 2
			elif one > zero:
				if one % 2 == 0 and zero % 2 == 1:
					x += 1
					zero -= 1
				else:
					x += 1
					one -= 1
			elif one % 2 == 1 and zero % 2 == 0:
				x += 1
				one -= 1
			else:
				x += 1
				zero -= 1
	if not flag:
		print(k)


def main():
	n = int(input())
	one = 0
	zero = 0
	odd = False
	for i in range(n):
		ln = input()
		for i in ln:
			if i == '1':
				one += 1
			else:
				zero += 1
		if len(ln) % 2 == 1:
			odd = True
	if one % 2 == 0 and zero % 2 == 0:
		print(n)
	elif odd:
		print(n)
	else:
		print(n - 1)
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	n = int(input())
	zeroes = 0
	ones = 0
	total = 0
	for i in range(n):
		s = input()
		zeroes += s.count('0')
		ones += s.count('1')
		total += len(s) // 2
	if zeroes // 2 + ones // 2 >= total:
		print(n)
	else:
		print(n - 1)


def solve(arr):
	not_pal = 0
	pal = 0
	odd = 0
	for i in arr:
		if i[0] == 1 and i[1] == 1:
			not_pal += 1
		else:
			pal += 1
			if i[0] == 1 or i[1] == 1:
				odd += 1
	ans = pal
	if odd > 0:
		ans += not_pal
	else:
		ans += 2 * (not_pal // 2)
	print(ans)

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		arr = []
		for j in range(n):
			s = input()
			one = s.count('1') % 2
			zero = s.count('0') % 2
			arr.append([zero, one])
		solve(arr)
main()


Q = int(input())
results = []
for _ in range(Q):
	n = int(input())
	zeroes = 0
	ones = 0
	fine = False
	for _ in range(n):
		msg = input()
		zeroes += msg.count('0')
		ones += msg.count('1')
		if len(msg) % 2 == 1:
			fine = True
	if not fine and zeroes % 2 == 1 and (ones % 2 == 1):
		results.append(n - 1)
	else:
		results.append(n)
for i in results:
	print(i)


for _ in range(int(input())):
	z = o = a = 0
	n = int(input())
	for i in range(n):
		s = input()
		z += s.count('0')
		o += s.count('1')
		a += len(s) // 2
	if z // 2 + o // 2 >= a:
		print(n)
	else:
		print(n - 1)


n = int(input())
for t in range(n):
	x = int(input())
	parity = 0
	odds = 0
	can = 0
	for i in range(x):
		string = input()
		odd = len(string) % 2 == 1
		if odd:
			can += 1
			odds += 1
		else:
			cnt0 = string.count('0')
			cnt1 = string.count('1')
			if cnt0 % 2 != len(string) % 2:
				parity += 1
			else:
				can += 1
	can += parity // 2 * 2
	parity %= 2
	can += min(parity, odds)
	print(can)


def manage(a, n, z):
	for i in range(0, z + 1, 2):
		if n >= a - i:
			return (n + i - a, z - i)

def f(l):
	z = 0
	n = 0
	ans = 0
	l2 = []
	for i in range(0, len(l)):
		l2.append(len(l[i]))
		if len(l[i]) % 2 != 0:
			ans = 1
			break
		for j in range(0, len(l[i])):
			if l[i][j] == '0':
				z += 1
			else:
				n += 1
	if ans != 1:
		for i in range(0, len(l2)):
			if i == len(l2) - 1:
				if l2[i] % 2 == 0:
					if z % 2 == 0 and n % 2 == 0:
						ans = 1
					else:
						ans = 0
				else:
					ans = 1
			elif l2[i] <= z:
				z = z - l2[i]
			elif l2[i] <= n:
				n = n - l2[i]
			elif l2[i] > z and l2[i] > n:
				(n, z) = manage(l2[i], n, z)
	if ans == 1:
		return len(l)
	else:
		return len(l) - 1
k = int(input())
for i in range(0, k):
	n = int(input())
	l = []
	for i in range(0, n):
		s = input()
		l.append(s)
	print(f(l))


q = int(input())
a = []
c = 0
while True:
	n = int(input())
	m = []
	for i in range(n):
		s = input()
		m.append(s)
	a.append(m)
	c = c + 1
	if c == q:
		break
for i in range(q):
	tar = a[i]
	tar_leng = 0
	tar_lenk_ok = 0
	tar_lenk_ng = 0
	for k in range(len(tar)):
		zeros = 0
		ones = 0
		for m in range(len(tar[k])):
			if tar[k][m] == '0':
				zeros += 1
			else:
				ones += 1
		if len(tar[k]) % 2 == 1:
			tar_leng += 1
		elif zeros % 2 == 0:
			tar_lenk_ok += 1
		else:
			tar_lenk_ng += 1
	if tar_lenk_ng % 2 == 0:
		print(len(tar))
	elif tar_leng > 0:
		print(len(tar))
	else:
		print(len(tar) - 1)


from collections import Counter
from typing import List
from functools import reduce

def binary_palindromes(n: int, binary_strings: List[str]):
	sum_of_counters = reduce(lambda c1, c2: c1 + c2, [Counter(s) for s in binary_strings])
	for s in binary_strings:
		if len(s) % 2 == 1:
			return n
	return n - 1 if sum_of_counters['0'] % 2 else n
q = int(input())
for _ in range(q):
	n = int(input())
	binary_strings = [input() for i in range(n)]
	print(binary_palindromes(n, binary_strings))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	b = [0] * 2
	a = [0] * n
	for i in range(n):
		s = minp()
		b[0] += s.count('0')
		b[1] += s.count('1')
		a[i] = len(s)
	a.sort()
	ans = 0
	for j in range(n + 1):
		c = b[:]
		d = a[:]
		r = 0
		for i in range(n):
			l = d[i]
			if j == 0:
				break
			if l % 2 == 1:
				if c[0] % 2 == 1:
					d[i] -= 1
					c[0] -= 1
				elif c[1] % 2 == 1:
					d[i] -= 1
					c[1] -= 1
				elif c[0] > 0:
					c[0] -= 1
					d[i] -= 1
				elif c[1] > 0:
					c[1] -= 1
					d[i] -= 1
		for i in range(n):
			l = d[i]
			if l % 2 == 0:
				if c[0] >= l:
					c[0] -= l
					r += 1
				elif c[1] >= l:
					c[1] -= l
					r += 1
				elif c[1] // 2 >= l // 2 - c[0] // 2:
					l -= c[0] // 2 * 2
					c[0] = 0
					c[1] -= l
					r += 1
		ans = max(ans, r)
	print(ans)
for i in range(mint()):
	solve()


I = input
for _ in [0] * int(I()):
	n = int(I())
	f = c = 0
	for _ in [0] * n:
		s = input()
		f |= len(s)
		c ^= s.count('1')
	print(n - (~f & c & 1))


Q = int(input())
for _ in range(Q):
	N = int(input())
	S = [input() for _ in range(N)]
	S = sorted(S, key=len)
	count_zero = sum(map(lambda x: len(list(filter(lambda y: y == '0', x))), S))
	count_one = sum(map(lambda x: len(list(filter(lambda y: y == '1', x))), S))
	cnt = 0
	while cnt < len(S):
		l = len(S[cnt])
		if l % 2 == 1:
			if count_one % 2 == 1:
				l -= 1
				count_one -= 1
			else:
				l -= 1
				count_zero -= 1
		if count_one > 0 and l != 0:
			changes = int(min(count_one, l) / 2) * 2
			l -= changes
			count_one -= changes
		if count_zero > 0 and l != 0:
			changes = int(min(count_zero, l) / 2) * 2
			l -= changes
			count_zero -= changes
		if l != 0:
			break
		else:
			cnt += 1
	print(cnt)


tcs = int(input())
for _ in range(tcs):
	n = int(input())
	bins = list()
	tot = 0
	even = 0
	odd = 0
	for i in range(n):
		bins.append(list(map(int, list(str(input())))))
		for j in range(len(bins[i])):
			if bins[i][j] == 1:
				tot += 1
		if len(bins[i]) % 2 == 0:
			even += 1
		else:
			odd += 1
	if even == 0:
		print(n)
		continue
	if odd == 0 and even >= 1 and (tot % 2 == 1):
		print(n - 1)
		continue
	if odd == 0 and even >= 1 and (tot % 2 == 0):
		print(n)
		continue
	if odd >= 1:
		print(n)
		continue


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	m = int(sys.stdin.readline())
	l = []
	for i in range(m):
		s = sys.stdin.readline()[:-1]
		l.append(s)
	(count0, count1) = (0, 0)
	arr = []
	for i in range(m):
		n = len(l[i])
		arr.append(n)
		for j in range(n):
			if l[i][j] == '1':
				count1 += 1
			else:
				count0 += 1
	ans = 0
	arr.sort()
	z = True
	even = 0
	eve = []
	for i in range(m):
		if arr[i] % 2 == 0:
			even += 1
			eve.append(arr[i])
	seve = sum(eve)
	if count1 >= sum(eve):
		print(m)
	else:
		while count1 > 1:
			for x in range(even):
				if eve[x] > 0 and count1 >= 2:
					eve[x] -= 2
					count1 -= 2
		if count1 == 1 and sum(arr) - seve > 0:
			print(m)
		elif count1 == 0:
			print(m)
		else:
			print(m - 1)


q = int(input())
for i in range(q):
	n = int(input())
	ones = 0
	odd = 0
	for i in range(n):
		s = input()
		if len(s) % 2 == 1:
			odd += 1
		for i in s:
			if i == '1':
				ones += 1
	if ones % 2 == 1 and odd == 0:
		print(n - 1)
	else:
		print(n)


for iiiii in range(int(input())):
	n = int(input())
	a = []
	for itr in range(n):
		a.append(input())
	l = []
	ans = 0
	onec = 0
	zeroc = 0
	evenc = 0
	for i in a:
		l.append(len(i))
		onec += i.count('1')
		zeroc += i.count('0')
		if len(i) % 2 == 0:
			evenc += len(i)
	if zeroc // 2 * 2 + onec // 2 * 2 >= evenc:
		print(n)
	else:
		print(n - 1)


import sys
import bisect as b
import math
from collections import defaultdict as dd
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for i in range(inin()):
	m = inin()
	E = 0
	O = 0
	C1 = 0
	C2 = 0
	for i in range(m):
		s = sin().strip()
		n = len(s)
		if n % 2 == 0:
			E += 1
		else:
			O += 1
		te = s.count('1')
		C1 += te
		C2 += n - te
	if C1 % 2 == 0 and C2 % 2 == 0:
		print(m)
	elif C1 % 2 == 1 and C2 % 2 == 1:
		if O == 0:
			print(m - 1)
		else:
			print(m)
	else:
		print(m)


q = int(input())
for _ in range(q):
	n = int(input())
	a = []
	cc = 0
	cn = 0
	nc = 0
	nn = 0
	for i in range(n):
		a.append(input())
		z = a[i].count('0')
		o = len(a[i]) - z
		if z % 2 == 0 and o % 2 == 0:
			cc += 1
		elif z % 2 == 0 and o % 2 == 1:
			cn += 1
		elif z % 2 == 1 and o % 2 == 0:
			nc += 1
		else:
			nn += 1
	cnt = cc + cn + nc + nn // 2 * 2
	nn = nn % 2
	if nc + cn != 0 and nn > 0:
		cnt += 1
	print(cnt)


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	totalzero = 0
	totalone = 0
	evens = 0
	odds = 0
	for i in range(n):
		x = input()
		totalzero += x.count('0')
		totalone += x.count('1')
		if (len(x) - 1) % 2 == 1:
			odds += 1
		else:
			evens += 1
	if odds > 0:
		print(n)
	elif totalzero % 2 == 0:
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	data = []
	(one, zero, lenn, fl) = (0, 0, 0, 0)
	for i in range(n):
		s = input()
		for x in s:
			lenn += 1
			if x == '1':
				one += 1
			else:
				zero += 1
		if lenn % 2 != 0:
			fl += 1
	if zero % 2 == 0 and one % 2 == 0:
		print(n)
	elif zero % 2 == 0 and one % 2 != 0 or (zero % 2 != 0 and one % 2 == 0):
		print(n)
	elif fl == 0:
		print(n - 1)
	else:
		print(n)


t = int(input())
for i in range(t):
	n = int(input())
	zeros = 0
	ones = 0
	even = 0
	odd = 0
	pals = []
	for j in range(n):
		string = input()
		pals.append(len(string))
		for s in string:
			if s == '1':
				ones += 1
			else:
				zeros += 1
	for j in pals:
		if j % 2 == 1:
			odd += 1
		else:
			even += 1
	if odd > 0:
		print(n)
	elif zeros % 2 == 0 and ones % 2 == 0:
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	S = []
	for i in range(n):
		s = input()
		S.append(s)
	ans = 0
	bad = 0
	gud = 0
	for i in S:
		z = 0
		o = 0
		for j in i:
			if j == '0':
				z += 1
		if len(i) % 2 != 0:
			ans += 1
		if z % 2 == 0:
			gud += 1
		else:
			bad += 1
	if ans == 0 and bad % 2 == 1:
		print(n - 1)
	else:
		print(n)


from collections import Counter

def canBePal(s):
	c = Counter(s)
	if len(c) == 1:
		return True
	if len(s) & 1:
		return True
	if not c['0'] & 1 and (not c['1'] & 1):
		return True
q = int(input())
for _ in range(q):
	n = int(input())
	strings = []
	for _ in range(n):
		s = input()
		strings.append(s)
	pals = []
	notPals = []
	for i in strings:
		if len(i) == 1:
			pals.append(i)
		elif canBePal(i):
			pals.append(i)
		else:
			notPals.append(i)
	odd = 0
	for s in strings:
		if len(s) & 1:
			odd += 1
	count = len(pals)
	evenpals = 2 * (len(notPals) // 2)
	count += evenpals
	if evenpals < len(notPals) and odd > 0:
		count += 1
	print(count)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, input().split()))

def ei():
	return map(int, input().split())

def ip():
	return int(stdin.readline())

def op(ans):
	return stdout.write(str(ans) + '\n')

def sv():
	n = ip()
	sum0 = 0
	allEven = True
	for i in range(n):
		s = input()
		if len(s) % 2:
			allEven = False
		sum0 += sum((1 for c in s if c == '0'))
	op(n - 1 if allEven and sum0 % 2 else n)
TC = ip()
for tc in range(TC):
	sv()


from collections import defaultdict
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	Q = int(input())
	for i in range(Q):
		n = int(input())
		L = []
		D = [0, 0]
		for j in range(n):
			s = list(input())
			L.append(len(s))
			for i in s:
				if i == '1':
					D[1] += 1
				else:
					D[0] += 1
		judge = 'even'
		for i in D:
			if i % 2 == 1:
				judge = 'odd'
				break
		judge2 = 'No'
		for i in L:
			if i % 2 == 1:
				judge2 = 'Yes'
		if judge == 'odd' and sum(D) % 2 == 0 and (judge2 == 'No'):
			print(n - 1)
		else:
			print(n)
main()


for _ in range(int(input())):
	n = int(input())
	l = [input().strip() for i in range(n)]
	prob = 0
	odd = 0
	for i in range(n):
		z = l[i].count('0')
		o = l[i].count('1')
		if len(l[i]) % 2 == 1:
			odd = 1
			break
		elif z % 2 == 1:
			prob += 1
	if odd == 1:
		print(n)
	elif prob % 2 == 1:
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	c0 = 0
	c1 = 0
	cods = 0
	n = int(input())
	for y in range(n):
		s = input()
		zr = s.count('0')
		c0 += zr
		c1 += len(s) - zr
		cods += len(s) % 2
	if c0 % 2 + c1 % 2 <= cods:
		print(n)
	else:
		print(n - 1)


q = int(input())
for i in range(q):
	n = int(input())
	cnt1 = cnt0 = c0 = c1 = 0
	for j in range(n):
		a = [int(x) for x in list(input())]
		counter = 0
		for item in a:
			counter += 1
			if item == 0:
				cnt0 += 1
			else:
				cnt1 += 1
		if counter % 2 == 0:
			c0 += 1
		else:
			c1 += 1
	if c1 % 2 == 1:
		if cnt1 % 2 == cnt0 % 2:
			print(n - 1)
		else:
			print(n)
	elif cnt1 % 2 == cnt0 % 2 == 1 and c1 != 0:
		print(n)
	elif cnt0 % 2 == cnt1 % 2 == 0:
		print(n)
	else:
		print(n - 1)


t = int(input())

def solve():
	n = int(input())
	ff = 0
	ft = 0
	p = 0
	for i in range(n):
		s = input()
		zero = 0
		one = 0
		for c in s:
			if c == '1':
				one += 1
			else:
				zero += 1
		if zero % 2 == 0 and one % 2 == 0:
			p += 1
		elif zero % 2 == 0 or one % 2 == 0:
			ft += 1
			p += 1
		else:
			ff += 1
	p += ff - ff % 2
	if ff % 2 == 1 and ft > 0:
		p += 1
	print(p)
for _ in range(t):
	solve()


for t in range(int(input())):
	n = int(input())
	one = 0
	zer = 0
	odd = 0
	for i in range(n):
		s = input()
		l = len(s)
		tot = 0
		for j in range(l):
			tot += ord(s[j]) - ord('0')
		one += tot
		zer += l - tot
		if l % 2 == 1:
			odd += 1
	if one % 2 + zer % 2 > odd:
		print(n - 1)
	else:
		print(n)


from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())
q = intput()
for _ in range(q):
	n = intput()
	s = []
	evens = []
	odds = []
	onecount = 0
	for i in range(n):
		s.append(input())
		if len(s[-1]) % 2 == 0:
			evens.append(len(s[-1]))
		else:
			odds.append(len(s[-1]))
		for x in s[-1]:
			if x == '1':
				onecount += 1
	for x in evens:
		while onecount - x < 0:
			x -= 2
		onecount -= x
		if onecount == 0:
			break
	if n - len(evens) == 0:
		print(n - onecount)
	elif onecount <= sum(odds):
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	l = []
	c0 = 0
	c1 = 0
	for i in range(n):
		l.append(input())
		c0 += l[-1].count('0')
		c1 += l[-1].count('1')
		l[-1] = [len(l[-1]), l[-1]]
	l.sort()
	p = 0
	br = 0
	while p < n:
		if l[p][0] % 2 == 0:
			if c0 >= l[p][0]:
				c0 -= l[p][0]
			elif c1 >= l[p][0]:
				c1 -= l[p][0]
			else:
				br = 1
		elif c0 >= l[p][0]:
			if c1 % 2:
				c0 += 1
				c1 -= 1
			c0 -= l[p][0]
		elif c1 >= l[p][0]:
			if c0 % 2:
				c1 += 1
				c0 -= 1
			c1 -= l[p][0]
		else:
			br = 1
		if br:
			break
		p += 1
	if p < n:
		c = 0
		if l[p][0] % 2 == 0:
			c = c0 // 2 * 2 + c1 // 2 * 2
		else:
			c = c0 // 2 * 2 + c1 // 2 * 2 + max(c0 % 2, c1 % 2)
		p += c >= l[p][0]
	print(p)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		k = ri()
		ol = 0
		be = 0
		ze = 0
		for i in range(k):
			z = rs()
			if len(z) % 2 == 0:
				ze = 0
				for j in z:
					if j == '0':
						ze += 1
				if ze % 2 != 0:
					be += 1
			else:
				ol += 1
		if be % 2 == 1 and ol == 0:
			k -= 1
		print(k)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


q = int(input())
for _ in range(q):
	n = int(input())
	l = []
	for i in range(n):
		s = input()
		l.append(s)
	(z, o) = (0, 0)
	(od, ev) = (0, 0)
	for i in range(len(l)):
		x = l[i]
		if len(x) % 2:
			od += 1
		else:
			ev += 1
		for j in range(len(x)):
			if x[j] == '0':
				z += 1
			else:
				o += 1
	if z % 2 and o % 2 and (od == 0):
		print(n - 1)
	else:
		print(n)


j = int(input())
ans = []
for just_a_num in range(j):
	n = int(input())
	string = ''
	zero = 0
	ones = 0
	odds = 0
	size = []
	for n in range(n):
		string = list(input())
		size.append(len(string))
		zero += string.count('0')
		ones += string.count('1')
	if ones % 2 != 0:
		ones -= 1
		odds += 1
	if zero % 2 != 0:
		zero -= 1
		odds += 1
	total = ones + zero
	size.sort()
	count = 0
	for i in size:
		if i % 2 == 0:
			if total - i >= 0:
				total -= i
				count += 1
		elif total - i + 1 >= 0:
			odds -= 1
			total -= i - 1
			count += 1
	ans.append(count)
for i in ans:
	print(i)


for _ in range(int(input())):
	n = int(input())
	pair = 0
	zeros = 0
	ones = 0
	for i in range(n):
		x = input()
		le = len(x)
		pair += le // 2
		z = x.count('0')
		zeros += z
		ones += le - z
	if pair <= zeros // 2 + ones // 2:
		print(n)
	else:
		print(n - 1)


R = lambda : list(map(int, input().split()))
(q,) = R()
for w in range(q):
	(nechet, ans) = (0, 0)
	(n,) = R()
	for i1 in range(n):
		s = input()
		if len(s) % 2 == 1:
			nechet = 1
		ans += s.count('1')
	if nechet == 1:
		print(n)
	elif ans % 2 == 0:
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	z = 0
	f = 0
	o = 0
	for x in range(n):
		s = input()
		if len(s) % 2 == 0 and s.count('0') % 2 == 0:
			f += 1
		elif len(s) % 2 == 0 and s.count('0') % 2 != 0:
			z += 1
		elif len(s) % 2 != 0:
			o += 1
	if o > 0 and z % 2 != 0:
		print(f + z // 2 * 2 + 1 + o)
	else:
		print(f + z // 2 * 2 + o)


Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	Ss = [input() for _ in range(N)]
	Query.append((N, Ss))
for (N, Ss) in Query:
	NUM = [0, 0]
	even_odd = [0, 0]
	for S in Ss:
		even_odd[0] += S.count('0')
		even_odd[1] += S.count('1')
		NUM[len(S) % 2] += 1
	if even_odd[0] % 2 == 1 and even_odd[1] % 2 == 1:
		if NUM[1] % 2 == 0 and NUM[1] >= 2:
			print(N)
		else:
			print(N - 1)
	elif sum(even_odd) % 2 == NUM[1] % 2:
		print(N)
	else:
		print(N - 1)


t = int(input(''))
for _ in range(t):
	n = int(input(''))
	l = []
	op = 0
	e = 0
	for i in range(n):
		z = 0
		o = 0
		a = input('')
		l = len(a)
		for c in a:
			if c == '1':
				o = o + 1
			else:
				z = z + 1
		if l % 2 == 0:
			if z % 2 == 1 and o % 2 == 1:
				e = e + 1
		elif z % 2 == 0 and o % 2 == 0:
			e = e + 1
		else:
			op = op + 1
	if e % 2 == 0:
		print(n)
	elif op > 0:
		print(n)
	else:
		print(n - 1)


Q = int(input())
for q in range(Q):
	n = int(input())
	arr = [input() for i in range(n)]
	lens = [len(i) % 2 for i in arr]
	counts = [i.count('1') for i in arr]
	if sum(counts) % 2 == 0:
		print(n)
	elif 1 in lens:
		print(n)
	else:
		print(n - 1)


for t in range(int(input())):
	n = int(input())
	sol = 0
	wrong = 0
	extra = False
	for i in range(n):
		arr = [int(x) for x in input()]
		num1 = 0
		if len(arr) % 2 == 1:
			extra = True
			continue
		for j in arr:
			if j == 1:
				num1 += 1
		if num1 % 2 == 1:
			wrong += 1
	if wrong % 2 == 1 and (not extra):
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	s = []
	for i in range(n):
		s.append(input())
	c1 = 0
	c2 = 0
	p = []
	for i in s:
		p.append(len(i))
		c1 += i.count('0')
		c2 += i.count('1')
	p.sort()
	res = 0
	f = 0
	for i in p:
		cl = ''
		if i % 2 == 0:
			for j in range(i // 2):
				if c1 > c2 and c1 >= 2:
					c1 -= 2
					continue
				if c2 >= c1 and c2 >= 2:
					c2 -= 2
					continue
				else:
					f = 1
					break
			if f == 0:
				res += 1
			else:
				f = 0
		else:
			if c1 % 2 != 0 and c1 >= 1:
				c1 -= 1
			elif c2 % 2 != 0 and c2 >= 1:
				c2 -= 1
			for j in range(i // 2):
				if c1 > c2 and c1 >= 2:
					c1 -= 2
					continue
				if c2 >= c1 and c2 >= 2:
					c2 -= 2
					continue
				else:
					f = 1
					break
			if f == 0:
				res += 1
			else:
				f = 0
	print(res)


a = int(input())
for i in range(a):
	n = int(input())
	one = zero = w = 0
	for x in range(n):
		qw = input()
		w += len(qw) % 2
		one += qw.count('1')
		zero += qw.count('0')
	if w == 0:
		if one % 2 == 1 and zero % 2 == 1:
			print(n - 1)
		else:
			print(n)
	else:
		print(n)


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(sys.stdin.readline())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def myceil(x, y):
	return (x + y - 1) // y

def Solution(arr, n):
	odd = 0
	even = 0
	for s in arr:
		if len(s) % 2:
			odd += 1
			continue
		cnt = 0
		for c in s:
			if c == '0':
				cnt += 1
		if cnt % 2:
			even += 1
	if odd == 0 and even % 2:
		print(n - 1)
	else:
		print(n)

def main():
	for _ in range(get_int()):
		n = get_int()
		arr = [get_string() for _ in range(n)]
		Solution(arr, n)
main()


for _ in range(int(input())):
	n = int(input())
	flag = 0
	flag2 = 0
	c1 = 0
	c0 = 0
	for __ in range(n):
		s = input()
		if len(s) % 2 != 0:
			flag += 1
		c1 += s.count('1')
		c0 += s.count('0')
	if (c1 % 2 != 0 and c0 % 2 == 0 or (c1 % 2 == 0 and c0 % 2 != 0)) and flag > 0:
		flag2 = 1
	if (c1 % 2 == 0 and c0 % 2 == 0) and flag % 2 == 0:
		flag2 = 1
	if (c1 % 2 != 0 and c0 % 2 != 0) and flag > 0:
		flag2 = 1
	if flag2 == 1:
		print(n)
	else:
		print(n - 1)


from collections import *
from math import *
t = int(input())
for y in range(t):
	n = int(input())
	l = []
	for i in range(n):
		l.append(list(input()))
	ct = 0
	s = 0
	flag = 0
	for i in l:
		ct += i.count('1')
		s += len(i)
		if len(i) % 2 == 1:
			flag = 1
	if s % 2 == 1:
		print(n)
	elif ct % 2 == 0 or flag == 1:
		print(n)
	else:
		print(n - 1)


def posP(s):
	if len(s) % 2 == 0:
		co1 = 0
		for i in s:
			if i == '1':
				co1 += 1
		if co1 % 2 == 1:
			return False
		else:
			return True
	return True
Q = int(input())
aR = []
for z in range(Q):
	n = int(input())
	su = 0
	cO = False
	for i in range(n):
		t = input()
		if posP(t):
			su += 1
		if len(t) % 2 == 1:
			cO = True
	if (n - su) % 2 == 0 or cO:
		aR.append(n)
	else:
		aR.append(n - 1)
for i in aR:
	print(i)


for i in range(int(input())):
	n = int(input())
	flag = 0
	cnt = 0
	c = 0
	for i in range(n):
		var = input()
		if len(var) % 2 != 0:
			flag = 1
		elif var.count('1') % 2 != 0:
			cnt += 1
		else:
			c += 1
	if flag == 1:
		print(n)
	else:
		print(n if cnt % 2 == 0 else n - 1)


for i in range(int(input())):
	n = int(input())
	zr = on = odds = 0
	for i in range(n):
		s = input()
		if len(s) % 2:
			odds += 1
		else:
			zr += s.count('0')
			on += s.count('1')
	if zr % 2 and on % 2 and (odds == 0):
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	(o, z) = (0, 0)
	for i in range(n):
		b = input().rstrip()
		o += len(b) % 2
		z += b.count('1')
	print(n - (not o and z % 2))


def func(x):
	return len(x)
for _ in range(int(input())):
	n = int(input())
	z = []
	for i in range(n):
		z.append(input())
	(c1, c0) = (0, 0)
	for i in z:
		c1 += i.count('1')
		c0 += i.count('0')
	flag = 0
	for i in z:
		if len(i) % 2:
			flag = 1
	if c1 % 2 or c0 % 2:
		if flag:
			print(n)
		else:
			print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	s = [list(input()) for _ in range(n)]
	for elem in s:
		elem.sort()
	numberZeroes = 0
	numberOnes = 0
	numOdd = 0
	for elem in s:
		if len(elem) % 2 == 1:
			numOdd += 1
		for num in elem:
			if num == '0':
				numberZeroes += 1
			else:
				numberOnes += 1
	while numOdd > 1:
		if numberOnes > 1:
			numberOnes -= 1
		else:
			numberZeroes -= 1
		numOdd -= 1
	if numOdd == 1:
		if numberOnes % 2 == 1:
			numberOnes -= 1
		elif numberZeroes % 2 == 1:
			numberZeroes -= 1
		elif numberOnes > 0:
			numberOnes -= 1
		else:
			numberZeroes -= 1
	if numberOnes % 2 == 0 and numberZeroes % 2 == 0:
		print(n)
	else:
		print(n - 1)


Q = int(input())
inf = []
for i in range(Q):
	s = []
	n = int(input())
	for j in range(n):
		s.append(input())
	inf.append(s)
for i in inf:
	sum_0 = 0
	sum_lenth = 0
	n = len(i)
	flag = 1
	for j in i:
		sum_0 += j.count('0')
		sum_lenth += len(j) % 2
	for j in i:
		if sum_lenth == 0 and sum_0 % 2 != 0:
			n -= 1
			flag = 0
			print(n)
			break
	if flag == 1:
		print(n)


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	all = []
	for i in range(n):
		all.append(input()[:-1])
	ones = 0
	zeros = 0
	lens = []
	for i in all:
		for j in i:
			if int(j):
				ones += 1
			else:
				zeros += 1
		lens.append(len(i))
	lens = sorted(lens)
	ans = 0
	for i in lens:
		val = i - i % 2
		if ones >= val:
			ones -= val
			ans += 1
		elif zeros >= val:
			zeros -= val
			ans += 1
		else:
			temp1 = ones - ones % 2
			temp2 = zeros - zeros % 2
			if temp1 + temp2 >= val:
				ans += 1
			break
	print(ans)


a = int(input())
gg = []
for i in range(a):
	s1 = 0
	s2 = 0
	s3 = 0
	s4 = 0
	aa = int(input())
	for i in range(aa):
		aaa = input()
		aaa = [aaa.count('0'), len(aaa), aaa.count('1')]
		s1 += aaa[0]
		s2 += aaa[1]
		s3 += aaa[2]
		s4 += aaa[1] % 2
	if s1 % 2 + s3 % 2 > s4:
		aa = aa - 1
	gg.append(aa)
for i in gg:
	print(i)


q = int(input())
for test in range(q):
	n = int(input())
	lenght = list()
	ans = 0
	c1 = 0
	c0 = 0
	for i in range(n):
		s = input()
		lenght += [len(s)]
		for j in s:
			if j == '1':
				c1 += 1
			else:
				c0 += 1
	lenght.sort()
	for i in lenght:
		if i % 2:
			if c1 % 2:
				c1 -= 1
			elif c0 % 2:
				c0 -= 1
			elif c1 > 0:
				c1 -= 1
			elif c0 > 0:
				c0 -= 1
			else:
				break
			i -= 1
		if c1 // 2 + c0 // 2 >= i // 2:
			num = min(c1 // 2, i // 2)
			c1 -= 2 * num
			c0 -= 2 * (i // 2 - num)
			ans += 1
		else:
			break
	print(ans)


Q = int(input())
for _ in range(Q):
	num0 = 0
	num1 = 0
	ls = []
	n = int(input())
	for _ in range(n):
		s = input()
		ls.append(len(s))
		num0 += s.count('0')
		num1 += s.count('1')
	amari = 0
	flg = False
	for l in ls:
		if l % 2 == 1:
			flg = True
		elif l % 4 == 2:
			amari += 2
		else:
			continue
	if flg:
		print(len(ls))
	elif not flg and abs(num0 - num1) % 4 == amari % 4:
		print(len(ls))
	else:
		print(len(ls) - 1)


from collections import defaultdict as dc
import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	e = 0
	o = 0
	b = 0
	c = 0
	for i in range(n):
		s = input()[:-1]
		if len(s) % 2:
			o += 1
			c += 1
		else:
			x = 0
			y = 0
			for j in s:
				if j == '0':
					x += 1
				else:
					y += 1
			if x % 2 or y % 2:
				b += 1
			else:
				c += 1
	x = min(o, b)
	y = (b - x) // 2 * 2
	m = c + x + y
	x = b // 2 * 2
	y = min(o, b - x)
	m = max(m, c + x + y)
	print(m)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	lens = []
	cnt = Counter()
	for _ in range(n):
		s = input()
		lens.append(len(s))
		cnt += Counter(s)
	pairs = 0
	singles = 0
	for v in cnt.values():
		(div, mod) = divmod(v, 2)
		pairs += div
		singles += mod
	ans = 0
	lens.sort()
	for len_ in lens:
		(div, mod) = divmod(len_, 2)
		pairs -= div
		if mod:
			if singles:
				singles -= 1
			else:
				singles = 1
				pairs -= 1
		if pairs < 0:
			break
		ans += 1
	print(ans)


for _ in ' ' * int(input()):
	(o, g, b) = (0, 0, 0)
	p = int(input())
	for i in range(p):
		z = input()
		if len(z) % 2:
			o += 1
		elif z.count('0') % 2:
			b += 1
		else:
			g += 1
	if o or b % 2 == 0:
		print(p)
	else:
		print(p - 1)


for _ in range(int(input())):
	n = int(input())
	f = 0
	r = 0
	for _ in range(n):
		s = input()
		if len(s) % 2 == 1:
			f = 1
		else:
			to = 0
			tz = 0
			for c in s:
				if c == '1':
					to += 1
				else:
					tz += 1
			if to % 2 == 1:
				r += 1
	if f or r % 2 == 0:
		print(n)
	else:
		print(n - 1)


n = int(input())
for i in range(n):
	quan = int(input())
	ans = 0
	x1 = 0
	x2 = 0
	x3 = 0
	for j in range(quan):
		one = 0
		zer = 0
		zt = input()
		for s in zt:
			if s == '1':
				one += 1
			else:
				zer += 1
		if one % 2 + zer % 2 == 1:
			x1 += 1
		elif one % 2 + zer % 2 == 0:
			x2 += 1
		else:
			x3 += 1
	if x3 % 2 == 0 or x1 > 0:
		ans = quan
	else:
		ans = quan - 1
	print(ans)


t = int(input())
for __ in [0] * t:
	n = int(input())
	zero = 0
	one = 0
	judge = True
	for i in range(n):
		s = list(input())
		if len(s) % 2 == 1:
			judge = False
		for e in s:
			if e == '1':
				one += 1
			else:
				zero += 1
	if judge and one % 2 == 1:
		print(n - 1)
	else:
		print(n)


for __ in range(int(input())):
	n = int(input())
	cnt1 = 0
	cnt2 = 0
	x = 0
	for i in range(n):
		a = list(map(int, input()))
		for j in range(len(a)):
			if a[j] == 0:
				cnt1 += 1
			else:
				cnt2 += 1
		if len(a) % 2 == 1:
			x += 1
	if x == 0 and cnt1 % 2 == 1 and (cnt2 % 2 == 1):
		print(max(0, n - 1))
	elif x == 0 and (cnt1 % 2 == 1 or cnt2 % 2 == 1):
		print(max(0, n - 1))
	elif x == 0:
		print(n)
	elif x % 2 == 1 and cnt1 % 2 == 1 and (cnt2 % 2 == 1):
		print(n - 1)
	elif x % 2 == 1 and (cnt1 % 2 == 1 or cnt2 % 2 == 1):
		print(n)
	elif x % 2 == 1:
		print(n - 1)
	elif x % 2 == 0 and cnt1 % 2 == 1 and (cnt2 % 2 == 1):
		print(n)
	elif x % 2 == 0 and (cnt1 % 2 == 1 or cnt2 % 2 == 1):
		print(n - 1)
	else:
		print(n)


def swap(a, b):
	if a > b:
		return (a, b)
	else:
		return (b, a)
testcase = int(input())
for i in range(testcase):
	n = int(input())
	a = []
	for k in range(n):
		a.append(input())
	length = [len(x) for x in a]
	length.sort()
	count1 = 0
	count0 = 0
	total = 0
	ans = 0
	for x in a:
		count1 += x.count('1')
		count0 += x.count('0')
	fre0 = count0 % 2
	fre1 = count1 % 2
	count0 //= 2
	count1 //= 2
	for x in length:
		count0 += fre0 // 2
		count1 += fre1 // 2
		fre1 %= 2
		fre0 %= 2
		if x % 2 == 0 and count1 * 2 + count0 * 2 >= total + x:
			total += x
			ans += 1
		elif fre1 + fre0 > 0:
			if count0 * 2 + count1 * 2 >= total + x - 1:
				total = total + x - 1
				ans += 1
				if fre1:
					fre1 -= 1
				else:
					fre0 -= 1
		elif count0 > count1 and count0 > 0:
			if 2 * (count0 - 1) + count1 * 2 + 1 >= total + x:
				total = total + x - 1
				count0 -= 1
				fre0 += 1
				ans += 1
		elif count1 > 0 and 2 * (count1 - 1) + 2 * count0 + 1 >= total + x:
			count1 -= 1
			total = total + x - 1
			fre1 += 1
			ans += 1
	print(ans)


Q = int(input())
for _ in range(Q):
	n = int(input())
	bad_ones = 0
	flex_length = 0
	non_palindromic = []
	for _ in range(n):
		s = input()
		length = len(s)
		r_s = tuple(reversed(s))
		n_ps = 0
		for (i, let) in enumerate(s[:length // 2]):
			if let != r_s[i]:
				n_ps += 1
				bad_ones += let == '1'
		non_palindromic.append(n_ps)
		flex_length += length % 2
	total_bad = sum(non_palindromic)
	unfixable = max(0, total_bad % 2 - flex_length)
	print(n - unfixable)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = []
	t_0 = 0
	t_1 = 0
	for i in range(n):
		n_0 = 0
		n_1 = 0
		s = input()
		for i in s:
			if i == '0':
				n_0 += 1
			else:
				n_1 += 1
		arr.append(n_0 + n_1)
		t_0 += n_0
		t_1 += n_1
	arr.sort()
	ans = 0
	while ans < n:
		if t_0 >= arr[ans]:
			if arr[ans] % 2 and t_1 % 2:
				t_0 -= arr[ans] - 1
				t_1 -= 1
			else:
				t_0 -= arr[ans]
			ans += 1
		elif t_1 >= arr[ans]:
			if arr[ans] % 2 and t_0 % 2:
				t_1 -= arr[ans] - 1
				t_0 -= 1
			else:
				t_1 -= arr[ans]
			ans += 1
		elif t_0 - t_0 % 2 + t_1 - t_1 % 2 >= arr[ans] - arr[ans] % 2:
			req = arr[ans]
			req -= t_0 - t_0 % 2
			t_0 = t_0 % 2
			if arr[ans] % 2 and t_0 % 2:
				t_1 -= req - 1
				t_0 -= 1
			else:
				t_1 -= req
			ans += 1
		else:
			break
	print(ans)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	lens = []
	a = 0
	b = 0
	for i in range(n):
		s = input()
		lens.append(len(s))
		a += s.count('0')
		b += s.count('1')
	lens.sort()
	ans = 0
	k = a + b
	for i in lens:
		if i > k:
			break
		if i % 2:
			if a and a % 2:
				a -= 1
				i -= 1
			elif b:
				b -= 1
				i -= 1
		if i <= a:
			ans += 1
			a -= i
		elif i <= b:
			ans += 1
			b -= i
		else:
			for j in range(0, i, 2):
				if j <= a and i - j <= b:
					a -= j
					b -= i - j
					ans += 1
					break
		k = a + b
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [[0, 0] for i in range(n)]
	for i in range(n):
		s = input()
		if s.count('0') % 2 == 1:
			arr[i][0] = 1
		if s.count('1') % 2 == 1:
			arr[i][1] = 1
	count = 0
	count1 = 0
	count2 = 0
	count3 = 0
	for i in range(n):
		if arr[i][0] == 1 and arr[i][1] == 1:
			count += 1
		if arr[i][0] == 0 and arr[i][1] == 0:
			count1 += 1
		if arr[i][0] == 0 and arr[i][1] == 1:
			count2 += 1
		if arr[i][0] == 1 and arr[i][1] == 0:
			count3 += 1
	if count % 2 == 1 and (count2 > 0 or count3 > 0):
		print(n)
	else:
		print(n - count % 2)


for _ in range(int(input())):
	n = int(input())
	c = 0
	f = 0
	for i in range(n):
		s = input()
		c += s.count('0')
		if f == 0 and len(s) % 2 == 1:
			f = 1
	if f == 0 and c % 2 == 1:
		print(n - 1)
	else:
		print(n)


import sys
import math
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}'.format(i) + sep)
INF = float('inf')
MOD = int(1000000000.0 + 7)
for _ in range(int(input())):
	n = int(input())
	arr = sorted([input() for i in range(n)], key=lambda x: len(x))
	(zero_cnt, one_cnt) = (0, 0)
	for i in arr:
		zero_cnt += i.count('0')
		one_cnt += i.count('1')
	total = zero_cnt // 2 + one_cnt // 2
	ans = 0
	for i in arr:
		if total >= len(i) // 2:
			total -= len(i) // 2
			ans += 1
	print(ans)


for _ in range(int(input())):
	ct0 = 0
	ct1 = 0
	f = 0
	n = int(input())
	for i in range(n):
		s = input()
		if len(s) % 2 != 0:
			f = 1
		for j in range(len(s)):
			if s[j] == '1':
				ct1 += 1
			else:
				ct0 += 1
	if f == 1:
		print(n)
	elif ct1 % 2 == 0 and ct0 % 2 == 0:
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	lis = []
	c1 = c0 = e = o = 0
	for i in range(n):
		s1 = input()
		lis.append(len(s1))
		if lis[-1] % 2 == 0:
			e += 1
		else:
			o += 1
		for i in s1:
			if i == '1':
				c1 += 1
			else:
				c0 += 1
	if c0 % 2 != 0 and c1 % 2 != 0 and (e == len(lis)):
		print(n - 1)
	else:
		print(n)


q = int(input())

def create_lists(check_lists, n):
	if len(check_lists) > 0:
		for l in check_lists:
			for r in l:
				if len(r) % 2 == 1:
					return n
			s_join = ''.join(l)
			result = check(s_join, n)
			if result:
				return result
		new_check_lists = []
		for l in check_lists:
			for ni in range(n):
				new_element = l[0:ni] + l[ni + 1:]
				if len(new_element) > 0:
					new_check_lists.append(new_element)
		check_lists = new_check_lists
		return create_lists(check_lists, n - 1)
	else:
		return 0

def check(string, n):
	zero_count = 0
	one_count = 0
	for x in string:
		if x == '0':
			zero_count += 1
		else:
			one_count += 1
	if len(string) % 2 == 0:
		if zero_count % 2 == 0:
			return n
		else:
			return False
	else:
		return n
for i in range(q):
	n = int(input())
	s_list = []
	for j in range(n):
		s = input()
		s_list.append(s)
	check_lists = []
	check_lists.append(s_list)
	print(create_lists(check_lists, n))


cases = int(input())
for q in range(cases):
	n = int(input())
	ss = 0
	ls = False
	for i in range(n):
		s = input()
		if len(s) % 2 != 0:
			ls = True
		for j in s:
			ss += j == '0'
	if ss % 2 != 0 and (not ls):
		print(n - 1)
	else:
		print(n)


for x in range(int(input())):
	n = int(input())
	r = 0
	d = []
	for i in range(n):
		s = input()
		if len(s) % 2:
			r = 1
		d.append(s.count('1'))
	if r == 0 and sum(d) % 2:
		print(n - 1)
	else:
		print(n)


t = int(input())
for _ in range(t):
	n = int(input())
	l = []
	d = dict()
	d[0] = 0
	d[1] = 0
	for ii in range(n):
		s = input()
		l.append(len(s))
		for i in s:
			d[int(i)] += 1
	l.sort()
	ans = 0
	for i in range(n):
		ll = l[i]
		flag = False
		while ll > 0:
			pre = ll
			if ll == 1:
				if d[0] == 1:
					d[0] -= 1
					ll -= 1
					continue
				elif d[1] == 1:
					d[1] -= 1
					ll -= 1
					continue
				elif d[0] & 1 == 1 and d[1] & 1 == 1:
					if d[0] < d[1]:
						d[0] -= 1
						ll -= 1
						continue
					else:
						d[1] -= 1
						ll -= 1
						continue
				elif d[0] & 1 == 1:
					d[0] -= 1
					ll -= 1
					continue
				elif d[1] & 1 == 1:
					d[1] -= 1
					ll -= 1
					continue
			if d[0] > d[1]:
				if ll >= 2 and d[0] >= 2:
					d[0] -= 2
					ll -= 2
				elif ll == 1 and d[0] >= 1:
					d[0] -= 1
					ll -= 1
			elif d[0] <= d[1]:
				if ll >= 2 and d[1] >= 2:
					d[1] -= 2
					ll -= 2
				elif ll == 1 and d[1] >= 1:
					d[1] -= 1
					ll -= 1
			if pre == ll:
				flag = True
				break
		if flag:
			break
		else:
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	strings = []
	for __ in range(n):
		strings.append(input())
	o = 0
	z = 0
	oddStringCnt = 0
	for s in strings:
		if len(s) % 2 == 1:
			oddStringCnt += 1
		o += s.count('1')
		z += s.count('0')
	oddStringsRequired = 0
	if o % 2 == 1:
		oddStringsRequired += 1
	if z % 2 == 1:
		oddStringsRequired += 1
	ans = n
	if oddStringCnt < oddStringsRequired:
		ans -= 1
	print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	S = [str(input()) for _ in range(n)]
	cnt0 = 0
	cnt1 = 0
	L = [0] * n
	k = 0
	for (i, s) in enumerate(S):
		cnt0 += s.count('0')
		cnt1 += s.count('1')
		L[i] = len(s)
		if len(s) % 2 == 1:
			k += 1
	if k == 0:
		if cnt0 % 2 != 0 or cnt1 % 2 != 0:
			ans = n - 1
		else:
			ans = n
	elif k % 2 == 0:
		if cnt0 % 2 == cnt1 % 2:
			ans = n
		else:
			ans = n - 1
	elif cnt0 % 2 != cnt1 % 2:
		ans = n
	else:
		ans = n - 1
	print(ans)


import sys
from collections import Counter
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))

def solve():
	n = getN()
	iso = False
	ise = False
	(cnt1, cnt0) = (0, 0)
	for _ in range(n):
		s = input().strip()
		if len(s) % 2 == 1:
			iso = 1
		else:
			ise = 1
		cnt = Counter(s)
		cnt1 += cnt['1']
		cnt0 += cnt['0']
	if not iso and cnt1 % 2 and cnt0 % 2:
		print(n - 1)
	else:
		print(n)

def main():
	t = getN()
	for times in range(t):
		solve()

def __starting_point():
	main()
__starting_point()


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		ans = 0
		f = 0
		a = 0
		for y in range(n):
			s = str(input())
			t = len(s)
			z = s.count('0')
			if t % 2 == 1:
				f = 1
			elif z % 2 == 1:
				a += 1
		if f == 1:
			print(n)
		elif a % 2 == 0:
			print(n)
		else:
			print(n - 1)
main()


for _ in range(int(input())):
	n = int(input())
	c = 0
	one = 0
	zero = 0
	length = []
	for _ in range(n):
		s = input()
		length.append(len(s))
		for i in range(len(s)):
			if s[i] == '0':
				zero += 1
			else:
				one += 1
	length.sort()
	for l in length:
		if l == 1:
			c += 1
		else:
			if l & 1:
				l -= 1
			if one >= 2:
				minus = min(l, one)
				if minus % 2 == 1:
					minus -= 1
				one -= minus
				l -= minus
			if l > 0:
				minus = min(l, zero)
				if minus % 2 == 1:
					minus -= 1
				zero -= minus
				l -= minus
			if l == 0:
				c += 1
	print(c)


q = int(input())
for _ in range(q):
	n = int(input())
	s = []
	zero = 0
	one = 0
	for i in range(n):
		t = input()
		s.append(len(t))
		zero += t.count('0')
		one += t.count('1')
	odd = False
	for i in range(n):
		if s[i] % 2 == 1:
			odd = True
	if odd:
		print(n)
	elif zero % 2 == 0:
		print(n)
	else:
		print(n - 1)


import array
import math
import os
import sys

def main():
	Q = read_int()
	for _ in range(Q):
		N = read_int()
		S = [inp() for _ in range(N)]
		print(solve(N, S))

def solve(N, S):
	lens = []
	counts = [0, 0]
	for s in S:
		lens.append(len(s))
		for c in s:
			if c == '0':
				counts[0] += 1
			else:
				counts[1] += 1
	pairs = counts[0] // 2 + counts[1] // 2
	lens.sort()
	ans = 0
	for ln in lens:
		p = ln // 2
		if pairs < p:
			break
		pairs -= p
		ans += 1
	return ans
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


Q = int(input())
for i in [0] * Q:
	n = int(input())
	flag = False
	col = 0
	for j in [0] * n:
		s = input()
		for elem in s:
			if elem == '1':
				col += 1
		if len(s) % 2 == 1:
			flag = True
	if flag or col % 2 == 0:
		print(n)
	else:
		print(n - 1)


t = int(input())
while t:
	odd = False
	count_of_zero = 0
	n = int(input())
	num = n
	while n:
		s = input()
		if len(s) % 2 != 0:
			odd = True
		count_of_zero += s.count('0')
		n -= 1
	if odd or count_of_zero % 2 == 0:
		print(num)
	else:
		print(num - 1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	(even, odd_ones, odd_zeros) = (0, 0, 0)
	odd = 0
	for z in range(n):
		s = input()
		l = len(s)
		if l % 2 != 0:
			odd += 1
			odd_ones += s.count('1')
			odd_zeros += l - odd_ones
		elif s.count('1') % 2 != 0:
			even += 1
	if even % 2 == 0 or odd > 0:
		print(n)
	else:
		print(n - 1)


for i in range(int(input())):
	n = int(input())
	(cnt0, cnt1, cnt2) = (0, 0, 0)
	for i in range(n):
		x = input()
		cnt2 += len(x) & 1
		for i in x:
			if i == '0':
				cnt0 += 1
			else:
				cnt1 += 1
	if (cnt2 - (cnt0 & 1) - (cnt1 & 1)) % 2 == 1 or (cnt0 & 1 and cnt1 & 1 and (cnt2 == 0)):
		print(n - 1)
	else:
		print(n)


for rpt in range(int(input())):
	scount = int(input())
	strings = [input() for x in range(scount)]
	ones = 0
	zeros = 0
	for i in strings:
		for j in i:
			if j == '0':
				zeros += 1
			else:
				ones += 1
	middles = 0
	for i in strings:
		if len(i) % 2 == 1:
			middles = middles + 1
	if ones % 2 == 1 and zeros % 2 == 1 and (middles < 2):
		print(len(strings) - 1)
	else:
		print(len(strings))


t = int(input())
for _ in range(t):
	ch1 = 0
	ch0 = 0
	cnp = 0
	pp = 0
	n = int(input())
	for i in range(n):
		s = input()
		c1 = 0
		c0 = 0
		for j in range(len(s)):
			if s[j] == '1':
				c1 += 1
			else:
				c0 += 1
		if c1 % 2 == 0 and c0 % 2 == 0:
			cnp += 1
		elif c1 % 2 == 0 and c0 % 2 == 1:
			cnp += 1
			ch0 = 1
		elif c1 % 2 == 1 and c0 % 2 == 0:
			cnp += 1
			ch1 = 1
		elif c1 % 2 == 1 and c0 % 2 == 1:
			pp += 1
	cnp += pp // 2 * 2
	if pp % 2 == 1:
		pp = 1
	if pp == 1 and (ch0 == 1 or ch1 == 1):
		cnp += 1
	print(cnp)


for _ in range(int(input())):
	n = int(input())
	(ee, oo, eo) = (0, 0, 0)
	for i in range(n):
		s = list(input())
		x = s.count('1')
		if x % 2 == 0:
			if (len(s) - x) % 2 == 0:
				ee += 1
			else:
				eo += 1
		elif (len(s) - x) % 2 == 0:
			eo += 1
		else:
			oo += 1
	if oo % 2 == 0:
		print(n)
	elif eo >= 1:
		print(n)
	else:
		print(n - 1)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	v = odd = even = 0
	for i in range(n):
		x = input().rstrip('\n')
		v += x.count('1')
		l = len(x)
		if l % 2:
			odd += l
		else:
			even += l
	if even:
		if v % 2:
			v -= min(v - 1, even)
		else:
			v -= min(v, even)
	v -= min(v, odd)
	print(n - v)


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
for i in range(t):
	n = int(input())
	lens = []
	cnts = {'0': 0, '1': 0}
	for i in range(n):
		s = input()
		for i in s:
			cnts[i] += 1
		lens.append(len(s))
	lens.sort()
	ans = 0
	cnts = list(cnts.values())
	for length in lens:
		for i in range(length // 2):
			if cnts[0] >= 2:
				cnts[0] -= 2
			elif cnts[1] >= 2:
				cnts[1] -= 2
			else:
				break
		else:
			if length % 2:
				if cnts[0] % 2 and cnts[0] >= 1:
					cnts[0] -= 1
				elif cnts[1] % 2 and cnts[1] >= 1:
					cnts[1] -= 1
				elif cnts[0] >= 1:
					cnts[0] -= 1
				elif cnts[1] >= 1:
					cnts[1] -= 1
				else:
					break
			ans += 1
			continue
		break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	count = [0, 0]
	odd = 0
	for i in range(n):
		s = input()
		if len(s) % 2:
			odd += 1
		for j in s:
			count[int(j)] += 1
	temp = count[0] % 2 + count[1] % 2
	if temp > odd or (odd - temp) % 2 == 1:
		print(n - 1)
	else:
		print(n)


t = int(input())
while t:
	n = int(input())
	cnt0 = cnt1 = a = 0
	for i in range(0, n):
		s = input()
		for j in s:
			if j == '0':
				cnt0 += 1
			else:
				cnt1 += 1
		if len(s) % 2:
			a += 1
	if cnt0 % 2 and cnt1 % 2 and (a == 0):
		print(n - 1)
	else:
		print(n)
	t -= 1


def f():
	n = int(input())
	z = 0
	c = 0
	flag = 0
	for i in range(n):
		a = input()
		a = list(a)
		if len(a) % 2 != 0:
			flag = 1
		elif a.count('1') % 2 == 0:
			c += 1
	if flag == 1:
		return n
	if n - c > 0:
		t = n - c
		if t % 2:
			return c + t - 1
		else:
			return n
	return c
for i in range(int(input())):
	print(f())


n = int(input())
all_testcases = []
for i in range(n):
	n_str = int(input())
	testcases_lst = []
	for j in range(n_str):
		testcase = str(input())
		testcases_lst.append(testcase)
	all_testcases.append(testcases_lst)

def deal_with_non_palindromic(non_palin, num_of_odd_str):
	num_of_palindromic_cases = 0
	ones_lst = []
	if len(non_palin) % 2 == 0:
		num_of_palindromic_cases += len(non_palin)
	else:
		num_of_palindromic_cases += len(non_palin) - 1
		if num_of_odd_str > 0:
			num_of_palindromic_cases += 1
	return num_of_palindromic_cases
for i in range(len(all_testcases)):
	ones = 0
	output = 0
	non_palin = []
	num_of_odd_str = 0
	for j in range(len(all_testcases[i])):
		ones = all_testcases[i][j].count('1')
		if len(all_testcases[i][j]) % 2 == 0:
			if ones % 2 == 0:
				output += 1
			else:
				non_palin.append(all_testcases[i][j])
		else:
			num_of_odd_str += 1
			output += 1
	if output < len(all_testcases[i]):
		output += deal_with_non_palindromic(non_palin, num_of_odd_str)
	print(output)


ans = []
n = int(input())
for i in range(n):
	flag = 'OK'
	l = 0
	t1 = 0
	tn = 0
	arr = []
	t = int(input())
	for j in range(t):
		arr.append(input())
	for j in range(t):
		l = len(arr[j])
		if l % 2 != 0:
			flag = 'False'
			ans.append(t)
			break
		if l % 2 == 0:
			t1 = 0
			for ind in range(l):
				if arr[j][ind] == '1':
					t1 += 1
			if t1 % 2 == 1:
				tn += 1
	if flag == 'OK':
		if tn % 2 == 0:
			ans.append(t)
		else:
			ans.append(t - 1)
for i in range(len(ans)):
	print(ans[i])


n = int(input())
while n:
	n -= 1
	p = int(input())
	zeroes = 0
	ones = 0
	Lo = []
	Le = []
	for i in range(p):
		S = input()
		z = S.count('0')
		zeroes += z
		ones += len(S) - z
		if len(S) % 2:
			Lo.append(len(S))
		else:
			Le.append(len(S))
	Le.sort()
	Lo.sort()
	if zeroes % 2 == 0 and ones % 2 == 0:
		print(p)
	elif zeroes % 2 == 1 and ones % 2 == 1:
		if len(Lo) > 0:
			print(p)
		else:
			print(p - 1)
	else:
		print(p)


for _ in range(int(input())):
	n = int(input())
	s = []
	bad = 0
	good = 0
	odd = 0
	for i in range(n):
		s.append(input())
		temp = 0
		for c in s[i]:
			if c == '0':
				temp += 1
		if len(s[i]) % 2 != 0:
			odd += 1
		elif temp % 2 != 0:
			bad += 1
	ans = good
	if bad % 2 != 0 and odd == 0:
		n -= 1
	print(n)


import sys
from collections import deque
readline = sys.stdin.readline
q = int(readline())
for _ in range(q):
	n = int(readline())
	tmp = []
	ans = False
	c = 0
	for i in range(n):
		s = str(readline().split()[0])
		tmp.append(s)
		if len(s) % 2 == 1:
			ans = True
		for ss in s:
			if ss == '1':
				c += 1
	if ans or c % 2 == 0:
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	a = [input() for _ in range(n)]
	u = all((len(s) % 2 == 0 for s in a))
	o = sum((sum(map(int, s)) for s in a)) % 2
	print(n - (u and o))


t = int(input())
for i in range(t):
	S = []
	p = 0
	p1 = 0
	p2 = 0
	np = 0
	flag = 0
	n = int(input())
	for j in range(n):
		S.append(input())
	for j in S:
		c1 = j.count('0')
		c2 = j.count('1')
		if c1 % 2 == 0 or c2 % 2 == 0:
			p = p + 1
			if c1 % 2 == 0 and c2 % 2 == 0:
				p1 = p1 + 1
		else:
			np = np + 1
	while np > 0 and np != 1:
		np = np - 2
		p2 = p2 + 2
	if np == 1 and p - p1 > 0:
		p = p + 1
	print(p + p2)


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	x1 = 0
	x0 = 0
	ki = 0
	for i in range(n):
		s = input()
		if (len(s) - 1) % 2 == 1:
			ki += 1
		x0 += s.count('0')
		x1 += s.count('1')
	if x1 % 2 + x0 % 2 > ki:
		print(n - 1)
	else:
		print(n)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
from collections import deque, Counter, OrderedDict, defaultdict
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		n = ii()
		s = []
		for i in range(n):
			s.append(list(si()))
		one = []
		sz = []
		for i in range(n):
			cnt = 0
			for j in s[i]:
				if j == '1':
					cnt += 1
			one.append(cnt)
			sz.append(len(s[i]))
		cnt = 0
		odd = []
		for i in range(n):
			if sz[i] % 2 == 0:
				if one[i] % 2 == 1:
					cnt += 1
			else:
				odd.append(one[i])
		if cnt % 2 == 0:
			print(n)
		else:
			ans = n - 1
			for i in range(len(odd)):
				ans = n
				break
			print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(cnt0, cnt1) = (0, 0)
	length = list()
	for _ in range(int(input())):
		s = input()
		length.append(len(s))
		for i in s:
			if i == '0':
				cnt0 += 1
			else:
				cnt1 += 1
	length.sort()
	ans = 0
	for i in length:
		if i % 2 == 1:
			if cnt0 % 2 == 1:
				cnt0 -= 1
				i -= 1
			elif cnt1 >= 1:
				cnt1 -= 1
				i -= 1
			elif cnt0 >= 1:
				cnt0 -= 1
				i -= 1
		if cnt0 % 2 == 0:
			if i <= cnt0:
				cnt0 -= i
				i = 0
			else:
				i -= cnt0
				cnt0 = 0
		elif cnt0 < i:
			i -= cnt0 - 1
			cnt0 = 1
		else:
			cnt0 -= i
			i = 0
		if cnt1 >= i:
			cnt1 -= i
			i = 0
		if i == 0:
			ans += 1
	print(ans)


q = int(input())
d = dict()

def dp(c0, c1, ind, Q):
	if (c0, c1, ind) in d:
		return d[c0, c1, ind]
	if ind >= len(Q):
		return 0
	if c0 + c1 < Q[ind]:
		return 0
	if c0 < 0 or c1 < 0:
		return 0
	if Q[ind] % 2 == 0 and ((c0 % 2 and c1 - c0 % 2 < Q[ind]) and (c1 % 2 and c0 - c1 % 2 < Q[ind])):
		return 0
	ans = 0
	for i in range(Q[ind] + 1):
		k = ans
		if Q[ind] % 2 == 0 and (i % 2 or (Q[ind] - i) % 2):
			continue
		ans = max(ans, dp(c0 - i, c1 + i - Q[ind], ind + 1, Q) + 1)
	d[c0, c1, ind] = ans
	return ans
for query in range(q):
	n = int(input())
	L = []
	Q = []
	ans = 0
	extra = 0
	for i in range(n):
		s = input()
		if len(s) % 2 == 0:
			L.append(s)
		else:
			ans += 1
			extra += 5
			continue
		c0 = 0
		c1 = 0
		for j in s:
			if j == '0':
				c0 += 1
			else:
				c1 += 1
		if c0 % 2:
			Q.append(1)
		else:
			ans += 1
	ans += len(Q) // 2 * 2
	if extra and len(Q) % 2:
		ans += 1
	print(ans)


import sys
data = sys.stdin.read().split()
data_ptr = 0

def data_next():
	global data_ptr, data
	data_ptr += 1
	return data[data_ptr - 1]
Q = int(data_next())
for test in range(Q):
	N = int(data_next())
	zero_cnt = 0
	one_cnt = 0
	odd_length = False
	for i in range(N):
		string = data_next()
		if len(string) % 2 == 1:
			odd_length = True
		for c in string:
			if c == '0':
				zero_cnt += 1
			else:
				one_cnt += 1
	if odd_length:
		print(N)
	elif zero_cnt % 2 == 0 and one_cnt % 2 == 0:
		print(N)
	else:
		print(N - 1)


mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
import random

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		m = mm = p = 0
		for i in range(n):
			s = sin()
			mm += len(s)
			if len(s) % 2 == 1:
				p += 1
			for i in s:
				if i == '1':
					m += 1
		mm -= m
		if p % 2 == 1:
			print(n)
		elif m % 2 == 0 and mm % 2 == 0 or p >= 2:
			print(n)
		else:
			print(n - 1)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
Q = int(input())
for _ in range(Q):
	n = int(input())
	zeros = 0
	ones = 0
	oddLens = 0
	for i in range(n):
		s = input()
		if len(s) & 1:
			oddLens += 1
		for c in s:
			if c == '0':
				zeros = 1 - zeros
			else:
				ones = 1 - ones
	if oddLens >= 2:
		print(n)
	elif oddLens == 1:
		if zeros and ones:
			print(n - 1)
		else:
			print(n)
	elif zeros or ones:
		print(n - 1)
	else:
		print(n)


t = eval(input())
while t:
	t -= 1
	n = eval(input())
	a = 0
	b = 0
	c = 0
	d = 0
	for i in range(n):
		s = input()
		if len(s) % 2 == 0:
			a += 1
		else:
			b += 1
		for j in s:
			if j == '0':
				c += 1
			else:
				d += 1
	if b < (c % 2 == 1) + (d % 2 == 1):
		n -= 1
	print(n)


q = int(input())
answer = []
for i in range(q):
	n = int(input())
	strings = []
	for j in range(n):
		strings.append(str(input()))
	a = True
	for j in range(n):
		if len(strings[j]) % 2 == 1:
			answer.append(n)
			a = False
			break
	if a:
		num = 0
		for j in range(n):
			num += strings[j].count('0')
		if num % 2 == 1:
			answer.append(n - 1)
		else:
			answer.append(n)
for i in range(q):
	print(answer[i])


t = int(input())
for i in range(t):
	n = int(input())
	ss = []
	holes_num = 0
	div2 = [False, False]
	for k in range(n):
		ss.append(input())
		if len(ss[-1]) % 2 == 1:
			holes_num += 1
		zeros_num = ss[-1].count('0')
		if zeros_num % 2 == 1:
			div2[0] = not div2[0]
		if (len(ss[-1]) - zeros_num) % 2 == 1:
			div2[1] = not div2[1]
	others_num = sum(div2)
	if others_num <= holes_num:
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		s = input()
		one = 0
		zero = 0
		for j in s:
			if j == '1':
				one += 1
			else:
				zero += 1
		l.append([one, zero])
	oddodd = 0
	oddeven = 0
	for i in range(n):
		if l[i][0] % 2 == 1 and l[i][1] % 2 == 1:
			oddodd += 1
		elif l[i][0] % 2 == 0 and l[i][1] % 2 == 1 or (l[i][0] % 2 == 1 and l[i][1] % 2 == 0):
			oddeven += 1
	if oddeven > 0:
		print(n)
	elif oddodd % 2 == 0:
		print(n)
	else:
		print(n - 1)


q = int(input())
for i in range(q):
	length = 0
	amount_of_ones = 0
	even = 0
	odd = 0
	n = int(input())
	for j in range(n):
		s = input()
		if len(s) % 2 == 0:
			even += 1
		else:
			odd += 1
		length += len(s)
		amount_of_ones += s.count('1')
	if odd != 0 or (amount_of_ones % 2 == 0 and length % 2 == 0):
		print(n)
	else:
		print(n - 1)


for _ in range(int(input())):
	n = int(input())
	s = [input() for _ in range(n)]
	c0 = sum((u.count('0') for u in s))
	c1 = sum((u.count('1') for u in s))
	l = [len(u) // 2 * 2 for u in s]
	for i in range(len(l)):
		while l[i] > 0:
			if c0 >= 2:
				c0 -= 2
				l[i] -= 2
			elif c1 >= 2:
				c1 -= 2
				l[i] -= 2
			else:
				break
	print(l.count(0))


for i in range(int(input())):
	n = int(input())
	odd = 0
	oddd = 0
	for j in range(n):
		s = input()
		one = s.count('1')
		zero = s.count('0')
		if len(s) % 2 == 0:
			if one % 2 == 1 or zero % 2 == 1:
				odd += 1
		else:
			oddd = 1
	if odd % 2 == 0:
		print(n)
	elif oddd == 1:
		print(n)
	else:
		print(n - 1)


t = int(input())
for i in range(t):
	n = int(input())
	res = 0
	pr = False
	odd = False
	for j in range(n):
		a = input()
		if len(a) % 2 == 1:
			for k in range(n - j - 1):
				a = input()
			print(n)
			pr = True
			break
		elif a.count('0') % 2 == 1:
			odd = not odd
	if not pr:
		if odd:
			print(n - 1)
		else:
			print(n)


I = input
for _ in [0] * int(I()):
	n = int(I())
	a = [I() for _ in [0] * n]
	print(n - (all((len(s) % 2 == 0 for s in a)) & sum((sum(map(int, s)) for s in a)) % 2))


for i in range(int(input())):
	sp = []
	count = 0
	for j in range(int(input())):
		a = input()
		sp.append(len(a) % 2)
		a = [int(x) for x in a]
		count += sum(a)
	d = sum(sp)
	if count % 2 == 1 and d == 0:
		print(len(sp) - 1)
	else:
		print(len(sp))


for _ in range(int(input())):
	n = int(input())
	a = [input() for i in range(n)]
	ones = zeros = 0
	for s in a:
		ones += s.count('1')
		zeros += s.count('0')
	for s in a:
		if len(s) % 2:
			if zeros % 2:
				zeros -= 1
			else:
				ones -= 1
	if zeros % 2 or ones % 2:
		print('   ', n - 1)
	else:
		print('   ', n)


for _ in range(int(input())):
	n = int(input())
	singles = 0
	l = []
	for i in range(n):
		s = input()
		if len(s) == 1 or (s.count('1') == len(s) and len(s) % 2 != 0 or (s.count('0') == len(s) and len(s) % 2 != 0)):
			singles += 1
		else:
			l.append(s)
	d = []
	for i in range(len(l)):
		one = l[i].count('1')
		zero = l[i].count('0')
		d.append([zero, one])
	ans = 0
	c = 0
	for i in range(len(d)):
		if d[i][0] % 2 == 0 and d[i][1] % 2 == 0:
			ans += 1
		elif d[i][0] % 2 == 0 or d[i][1] % 2 == 0:
			singles += 1
		else:
			c += 1
	if c % 2 == 0:
		ans += c
	elif singles > 0:
		ans += c
	else:
		ans += c - 1
	ans += singles
	print(ans)


import sys
import os
import math
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect

def MOD():
	return 1000000007

def Int():
	return int(sys.stdin.readline())

def MInt():
	return map(int, sys.stdin.readline().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def LStr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def MStr():
	return map(str, sys.stdin.readline().strip().split())

def solution():
	for _ in range(Int()):
		a = Int()
		odd = 0
		ans = a
		(zero, one) = (0, 0)
		for _ in range(a):
			s = Str()
			if len(s) % 2 == 1:
				odd += 1
			else:
				zero += s.count('0')
				one += s.count('1')
		if odd == 0 and zero % 2 == 1 and (one % 2 == 1):
			print(ans - 1)
		else:
			print(ans)
solution()


for _ in range(int(input())):
	n = int(input())
	strings = []
	odd = 0
	ones = 0
	for _ in range(n):
		strings.append(input())
		if len(strings[-1]) % 2 == 1:
			odd += 1
		ones += strings[-1].count('1')
	if odd > 0 or ones % 2 == 0:
		print(n)
	else:
		print(n - 1)


n = int(input())
for i in range(n):
	num_of_lines = int(input())
	list_of_lines = list()
	num_of_zeros_in_even_lines = 0
	for line in range(num_of_lines):
		list_of_lines.append(input())
	flag = False
	for el in list_of_lines:
		if len(el) % 2 != 0:
			flag = True
		else:
			for elel in list(el):
				if elel == '0':
					num_of_zeros_in_even_lines += 1
	if not flag and num_of_zeros_in_even_lines % 2 == 1:
		print(num_of_lines - 1)
	else:
		print(num_of_lines)


T = int(input())
for _ in range(T):
	N = int(input())
	l = []
	a = 0
	b = 0
	x = 0
	s = ''
	for i in range(N):
		s = input()
		for j in s:
			if j == '1':
				a += 1
			else:
				b += 1
		if len(s) % 2 != 0:
			x += 1
	if a % 2 == 0 and b % 2 == 0 and (x % 2 == 0):
		print(N)
		t = 1
	elif a % 2 == 0 and b % 2 == 0 and (x % 2 != 0):
		print(N - 1)
		t = 2
	elif a % 2 == 0 and b % 2 != 0 and (x % 2 == 0):
		print(N - 1)
		t = 3
	elif a % 2 == 0 and b % 2 != 0 and (x % 2 != 0):
		print(N)
		t = 4
	elif a % 2 != 0 and b % 2 == 0 and (x % 2 == 0):
		print(N - 1)
		t = 5
	elif a % 2 != 0 and b % 2 == 0 and (x % 2 != 0):
		print(N)
		t = 6
	elif a % 2 != 0 and b % 2 != 0 and (x % 2 == 0):
		if x >= 2:
			print(N)
			t = 7
		else:
			print(N - 1)
			t = 8
	elif a % 2 != 0 and b % 2 != 0 and (x % 2 != 0):
		print(N - 1)
		t = 9


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	zeros = 0
	ones = 0
	count = 0
	for i in range(n):
		s = input()
		dic = Counter(s)
		zeros = zeros + dic['0']
		ones = ones + dic['1']
		l = len(s)
		if l % 2 == 1:
			count = count + 1
	if ones % 2 == 0 and zeros % 2 == 0:
		print(n)
	elif ones % 2 == 1 and zeros % 2 == 1:
		if count >= 2:
			print(n)
		else:
			print(n - 1)
	elif count >= 1:
		print(n)
	else:
		print(n - 1)


def solve_one():
	n = int(input())
	strs = [input() for i in range(n)]
	ones = 0
	zeros = 0
	for s in strs:
		ones += s.count('1')
		zeros += s.count('0')
	pairs = ones // 2 + zeros // 2
	left = ones % 2 + zeros % 2
	strs.sort(key=len)
	res = 0
	for s in strs:
		if len(s) % 2 == 1:
			left -= 1
			if left < 0:
				left += 2
				pairs -= 1
				if pairs < 0:
					return res
		pairs -= len(s) // 2
		if pairs < 0:
			return res
		res += 1
	return res
for i in range(int(input())):
	print(solve_one())


Q = int(input())
for i in range(Q):
	n = int(input())
	nechet = []
	chet_ploh = []
	for j in range(n):
		s = input()
		s = list(s)
		if len(s) % 2 != 0:
			nechet.append(1)
		elif s.count('0') % 2 != 0 and s.count('1') % 2 != 0:
			chet_ploh.append(1)
	if len(nechet) > 0:
		print(n)
	elif len(chet_ploh) % 2 != 0:
		print(n - 1)
	else:
		print(n)


q = int(input())
for i in range(q):
	n = int(input())
	e = 0
	ans = n
	p = 0
	for j in range(n):
		s = str(input())
		if len(s) % 2 == 0:
			if s.count('1') % 2 != 0:
				e += 1
		else:
			p += 1
	if e % 2 == 1:
		if p != 0:
			e -= 1
	print(ans - e % 2)


t = int(input())
while t != 0:
	n = int(input())
	odd = 0
	evenGood = 0
	evenBad = 0
	for i in range(n):
		s = str(input())
		if len(s) & 1:
			odd += 1
		elif s.count('1') & 1:
			evenBad += 1
		else:
			evenGood += 1
	if odd == 0 and evenBad & 1:
		print(n - 1)
	else:
		print(n)
	t -= 1


import sys
input = sys.stdin.readline
Q = int(input())
for test in range(Q):
	n = int(input())
	S = [input().strip() for i in range(n)]
	zero = 0
	lenflag = 0
	for s in S:
		zero += s.count('0')
		if len(s) % 2 == 1:
			lenflag = 1
	if lenflag == 1:
		print(n)
	elif zero % 2 == 0:
		print(n)
	else:
		print(n - 1)


t = int(input())
for i in range(t):
	n = int(input())
	spare = 0
	defect = 0
	total = 0
	for j in range(n):
		s = list(input())
		if len(s) % 2 != 0:
			spare += len(s)
			total += 1
		elif s.count('1') % 2 != 0 and s.count('0') % 2 != 0:
			defect += 1
		else:
			total += 1
	if spare >= defect:
		total += defect
	elif defect % 2 == 0:
		total += defect
	else:
		total += defect - 1
	print(total)


import sys, math
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = []
	qw = []
	for i in range(n):
		qq = list(input())
		qq.pop()
		qw.append(len(qq))
		a = a + qq
	q = a.count('1')
	w = a.count('0')
	c = 0
	qq = []
	ww = []
	for i in range(len(qw)):
		if qw[i] % 2 == 0:
			qq.append(qw[i])
		else:
			ww.append(qw[i])
	qq.sort()
	ww.sort()
	qw = qq + ww
	for i in range(len(qw)):
		if qw[i] % 2 == 0:
			if q > w:
				ww = (q - qw[i]) % 2
				qq = q
				q = max(q - qw[i], ww)
				w = w - qw[i] + qq - q
			else:
				ww = (w - qw[i]) % 2
				qq = w
				w = max(w - qw[i], ww)
				q = q - qw[i] + qq - w
		elif q > w:
			qq = q
			q = max(q - qw[i], 0)
			w = w - qw[i] + qq - q
		else:
			qq = w
			w = max(w - qw[i], 0)
			q = q - qw[i] + qq - w
		if q >= 0 and w >= 0:
			c = c + 1
	print(c)


n = int(input())
for i in range(n):
	t = int(input())
	a = [input() for k in range(t)]
	one = 0
	zero = 0
	for j in a:
		for char in j:
			if char == '1':
				one += 1
			else:
				zero += 1
	usable_ones = one // 2
	usable_zeroes = zero // 2
	usable = usable_ones + usable_zeroes
	manageable = 0
	for j in a:
		if len(j) // 2 <= usable:
			manageable += 1
			usable -= len(j) // 2
		elif len(j) // 2 <= usable:
			manageable += 1
			usable -= len(j) // 2
	print(manageable)


for _ in range(int(input())):
	n = int(input())
	flag = 0
	c1 = 0
	for __ in range(n):
		s = input()
		if len(s) % 2 != 0:
			flag = 1
		c1 += s.count('1')
	if flag == 1:
		print(n)
	elif c1 % 2 == 0:
		print(n)
	else:
		print(n - 1)


t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	a = [input() for i in range(n)]
	l = [len(a[i]) for i in range(n)]
	b = ''.join(a)
	c = Counter(b)
	for i in range(n):
		if l[i] % 2:
			flg = 1
			break
	else:
		flg = 0
	if flg:
		print(n)
	elif c['0'] % 2 == c['1'] % 2 == 1:
		print(n - 1)
	else:
		print(n)


q = int(input())
for _ in range(q):
	n = int(input())
	ans = 0
	odd = 0
	even_bad = 0
	even_good = 0
	a = []
	for i in range(n):
		x = list(input())
		if len(x) % 2 != 0:
			odd += 1
		if x.count('0') % 2 == 0:
			even_good += 1
		else:
			even_bad += 1
	if odd == 0 and even_bad % 2 != 0:
		print(n - 1)
	else:
		print(n)


def solve(s):
	return True
t = int(input())
for case in range(t):
	n = int(input())
	s = ''
	c = 0
	for i in range(n):
		x = input()
		c += int(len(x) % 2)
		s += x
	ans = n - (c - s.count('0') - s.count('1')) % 2 - int(c == 0) * int(s.count('0') * s.count('1') % 2 == 1)
	print(ans)


def count(s):
	zero = 0
	one = 0
	for i in range(len(s)):
		if s[i] == '0':
			zero += 1
		else:
			one += 1
	return (zero, one)
for t in range(int(input())):
	zero = 0
	one = 0
	length = 0
	n = int(input())
	condition = True
	for i in range(n):
		s = input()
		if len(s) & 1:
			condition = False
		length += len(s)
		(a, b) = count(s)
		zero += a
		one += b
	if condition and length & 1 == 0 and zero & 1:
		print(n - 1)
	else:
		print(n)


from sys import stdin, stdout
for i in stdin:
	q = int(i.strip())
	break
while q > 0:
	for i in stdin:
		n = int(i.strip())
		break
	S = []
	while n > 0:
		for i in stdin:
			S.append(i.strip())
			break
		n -= 1
	k = 0
	for i in S:
		if len(i) % 2 == 1:
			k = 2
			break
		elif i.count('1') % 2 == 1:
			k += 1
	stdout.write(str(len(S) - k % 2) + '\n')
	q -= 1


q = int(input())
while q > 0:
	q -= 1
	n = int(input())
	c = n
	odd = 0
	bad = 0
	while n > 0:
		n -= 1
		s = input()
		if len(s) % 2 == 1:
			odd += 1
		elif s.count('1') % 2 == 1:
			bad += 1
	if odd == 0 and bad % 2 == 1:
		c -= 1
	print(c)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	n = ii()
	num1 = []
	num0 = []
	for i in range(n):
		s = si()
		num1.append(s.count('1'))
		num0.append(s.count('0'))
	codd = 0
	cpal = 0
	sm = 0
	for i in range(n):
		if num0[i] & 1 and num1[i] & 1:
			codd += 1
		elif num0[i] & 1 and num1[i] % 2 == 0 or (num0[i] % 2 == 0 and num1[i] & 1):
			sm += max(num0[i], num1[i])
			cpal += 1
		elif num0[i] % 2 == 0 and num1[i] % 2 == 0:
			cpal += 1
	print(cpal + codd - codd % 2 + min(codd % 2, sm))


n = int(input())
for _ in range(n):
	k = int(input())
	ppp = []
	for i in range(k):
		ppp.append(input())
	ones = 0
	for el in ppp:
		for bitt in el:
			if bitt == '1':
				ones += 1
	j = 0
	for i in range(k):
		if len(ppp[i]) % 2 == 0:
			j += 0
		else:
			j += 1
	if j >= 1:
		print(len(ppp))
	elif ones % 2 == 0:
		print(len(ppp))
	else:
		print(len(ppp) - 1)


import sys, math, bisect
from random import randint
inf = float('inf')
mod = 10 ** 9 + 7

def lcm(a, b):
	return int(a / math.gcd(a, b) * b)

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors

def isPrime(n, k=5):
	if n < 2:
		return True
	for i in range(0, k):
		a = randint(1, n - 1)
		if pow(a, n - 1, n) != 1:
			return False
	return True
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import string
for _ in range(int(input())):
	n = int(input())
	odd = False
	zeros = 0
	arr = []
	for _ in range(n):
		arr.append(input())
	for i in range(n):
		if len(arr[i]) % 2:
			odd = True
		zeros += arr[i].count('0')
	if odd or not zeros % 2:
		print(n)
	else:
		print(n - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	cnt = 0
	la = [input() for i in range(n)]
	flag = 0
	for i in la:
		if len(i) % 2 != 0:
			flag = 1
			break
		cnt += i.count('0')
	if flag == 0:
		if cnt % 2 != 0:
			print(n - 1)
		else:
			print(n)
	else:
		print(n)


def solve_query():
	n_bad = n_even = n_odd = n_even_with_both = 0
	for i in s:
		if len(i) % 2 == 1:
			n_odd += 1
		elif i.count('0') % 2 == 1:
			n_bad += 1
			if i.count('0') * i.count('1') != 0:
				n_even_with_both += 1
		else:
			n_even += 1
	print(min(n_bad - 2 * (n_bad // 2), n_odd) + n_even + 2 * (n_bad // 2) + n_odd)
q = int(input())
for _ in range(q):
	n = int(input())
	s = []
	for __ in range(n):
		s.append(input())
	solve_query()


for _ in range(int(input())):
	N = int(input())
	(s, o, ep, enp) = ([], 0, 0, 0)
	for i in range(N):
		r = input()
		if len(r) % 2 != 0:
			o += 1
		elif r.count('1') % 2 == 0:
			ep += 1
		else:
			enp += 1
		s.append(r)
	if o > 0:
		print(N)
	else:
		if enp % 2 != 0:
			enp -= 1
		print(ep + enp)


q = int(input())
for i in range(q):
	n = int(input())
	o = 0
	oc = 0
	zc = 0
	for j in range(n):
		x = input()
		if len(x) % 2:
			o += 1
		for k in x:
			if k == '1':
				oc += 1
			else:
				zc += 1
	if oc % 2 == 0 and zc % 2 == 0 or (oc % 2 + zc % 2 == 1 and o >= 1) or (oc % 2 + zc % 2 == 2 and o >= 2):
		print(n)
	else:
		print(n - 1)


def errors(line):
	err = 0
	nn = len(line)
	for i in range(nn // 2):
		if line[i] != line[-i - 1]:
			err += 1
	return err
n = int(input())
for _ in range(n):
	k = int(input())
	errs = []
	helps = 0
	for _ in range(k):
		arr = input()
		if len(arr) % 2 == 1:
			helps += 1
		errs.append(errors(arr))
	total = sum(errs)
	if total % 2 == 0 or helps > 0:
		print(k)
	else:
		print(k - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = []
	for __ in range(n):
		arr.append(input())
	evendone = 0
	odddone = 0
	eundone = 0
	cnt = 0
	for i in range(len(arr)):
		if len(arr[i]) % 2 == 0:
			if arr[i].count('1') % 2 == 0:
				evendone += 1
			else:
				eundone += 1
		else:
			odddone += 1
	cnt += evendone
	cnt += 2 * (eundone // 2)
	eundone -= 2 * (eundone // 2)
	if odddone > 0:
		print(n)
	elif eundone != 0:
		print(n - 1)
	else:
		print(n)


from typing import List
import os

def p(nums: List[List[int]]):
	lengths = [0, 0]
	counts = [0, 0]
	for n in nums:
		lengths[len(n) % 2] += 1
		for x in n:
			counts[x] += 1
	if lengths[1] > 0 or (counts[0] % 2 == 0 and counts[1] % 2 == 0):
		return len(nums)
	else:
		return len(nums) - 1

def pp(input):
	n_test = int(input())
	for i in range(n_test):
		ns = int(input())
		nums = [list(map(int, input())) for _ in range(ns)]
		print(p(nums))
if 'paalto' in os.getcwd():
	from string_source import string_source
	s1 = string_source('26\n1\n1010001110\n2\n00000101101111111010\n01111001\n1\n11101110101101000011\n2\n001010100101100010010101010000001011\n10111001101011100101111000111000100011\n3\n10000010101010001010010101101011110001010111\n01011110\n01100110000010000000101011010111000100\n2\n0101111011111000001010111110010110\n111011100010001101\n3\n11000010000001101011100110001001010110\n010100100100001001010010\n10001101011001111010001011111110001001100010110101\n')
	pp(s1)
else:
	pp(input)


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
q = oint()
for _ in range(q):
	n = oint()
	odd = 0
	ss = ''
	for _ in range(n):
		s = input()
		ss = ss + s
		if len(s) % 2:
			odd = 1
	if odd:
		print(n)
	elif ss.count('1') % 2:
		print(n - 1)
	else:
		print(n)


q = int(input())
for _ in range(q):
	n = int(input())
	s = [input() for i in range(n)]
	cnt1 = 0
	cnt0 = 0
	cnt_odd = 0
	for i in range(n):
		if len(s[i]) % 2 == 1:
			cnt_odd += 1
		for j in range(len(s[i])):
			if s[i][j] == '1':
				cnt1 += 1
			else:
				cnt0 += 1
	if cnt_odd == 0:
		if cnt0 % 2 == 1 and cnt1 % 2 == 1:
			print(n - 1)
		else:
			print(n)
	else:
		print(n)


t = int(input())
for _ in range(t):
	odd = 0
	even1 = 0
	even2 = 0
	n = int(input())
	for i in range(n):
		s = str(input())
		o = 0
		e = 0
		if len(s) & 1:
			odd += 1
		else:
			for j in s:
				if j == '0':
					e += 1
				else:
					o += 1
			if e & 1 or o & 1:
				even2 += 1
			else:
				even1 += 1
	if odd == 0:
		print(odd + even1 + even2 // 2 * 2)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	c = [0, 0]
	o = 0
	for i in range(n):
		s = input()
		c[0] += s.count('0')
		c[1] += s.count('1')
		o += len(s) % 2
	while o:
		if c[0] % 2:
			c[0] -= 1
		elif c[1] % 2:
			c[1] -= 1
		elif c[0]:
			c[0] -= 1
		else:
			c[1] -= 1
		o -= 1
	print(n - (c[0] % 2 or c[1] % 2))


q = int(input())
for i in range(q):
	amount = 0
	n = int(input())
	flag = 0
	for j in range(n):
		s = input()
		for k in range(len(s)):
			if s[k] == '1':
				amount += 1
		if len(s) % 2:
			flag = 1
	if not flag and amount % 2:
		print(n - 1)
	else:
		print(n)


Q = int(input())
for _ in range(Q):
	N = int(input())
	X = []
	zeros = 0
	odds = 0
	for __ in range(N):
		s = input()
		odds += len(s) % 2
		zeros += s.count('0')
	if odds or zeros % 2 == 0:
		print(N)
	else:
		print(N - 1)


import sys
import itertools
import math
import collections
from collections import Counter

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def ceil(n, k):
	return n // k + (n % k != 0)

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

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
t = ii()
for _ in range(t):
	n = ii()
	o = z = 0
	d = []
	for i in range(n):
		s = input()
		if len(s) % 2 == 0:
			d.append(len(s))
		t = s.count('1')
		o += t
		z += len(s) - t
	f = True
	for i in range(len(d)):
		if o >= d[i]:
			o -= d[i]
		elif z >= d[i]:
			z -= d[i]
		elif z - z % 2 + o - o % 2 >= d[i]:
			t = z - z % 2
			z -= t
			o -= d[i] - t
		else:
			f = False
			break
	print(n) if f else print(n - 1)


Q = int(input())
while Q:
	n = int(input())
	count_0 = 0
	count_1 = 0
	length = []
	for i in range(n):
		s = input()
		length.append(len(s))
		for j in range(len(s)):
			if s[j] == '0':
				count_0 += 1
			else:
				count_1 += 1
	length.sort()
	count = 0
	flag = False
	if count_0 % 2 != 0 or count_1 % 2 != 0:
		for i in range(n):
			if length[i] % 2 != 0:
				flag = True
		if flag:
			print(n)
		else:
			print(n - 1)
	else:
		print(n)
	Q -= 1


def solve_query():
	n_zeros = n_ones = 0
	lengths = []
	r = 0
	for i in s:
		n_zeros += i.count('0')
		n_ones += i.count('1')
		lengths.append(len(i))
	lengths.sort()
	for l in lengths:
		if l % 2 == 0:
			if l <= n_zeros:
				n_zeros -= l
				r += 1
			elif l <= n_ones:
				n_ones -= l
				r += 1
			elif l <= n_zeros - n_zeros % 2 + (n_ones - n_ones % 2):
				n_ones -= l - (n_zeros - n_zeros % 2)
				n_zeros -= n_zeros - n_zeros % 2
				r += 1
			else:
				break
		elif l <= n_zeros and n_zeros % 2 == 1:
			n_zeros -= l
			r += 1
		elif l <= n_ones and n_ones % 2 == 1:
			n_ones -= l
			r += 1
		elif l <= n_zeros + n_ones:
			n_ones -= l - (n_zeros - n_zeros % 1)
			n_zeros -= n_zeros - n_zeros % 1
			r += 1
		else:
			break
	print(r)
q = int(input())
for _ in range(q):
	n = int(input())
	s = []
	for __ in range(n):
		s.append(input())
	solve_query()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	words = [input().strip() for i in range(n)]
	(ods, eve) = (0, 0)
	for i in words:
		if len(i) % 2:
			ods += 1
		elif i.count('1') % 2:
			eve += 1
	if ods or eve % 2 == 0:
		print(n)
	else:
		print(n - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	(n1, n0) = (0, 0)
	odd_bool = False
	for i in range(n):
		s = input().strip()
		n1 += s.count('1')
		n0 += s.count('0')
		if len(s) & 1:
			odd_bool = True
	if n0 % 2 == 0 or n1 % 2 == 0 or odd_bool:
		print(n)
	else:
		print(n - 1)


cases = int(input())
while cases:
	cases -= 1
	num = int(input())
	ones = 0
	zeros = 0
	broken = False
	for i in range(num):
		s = input()
		if len(s) % 2 != 0:
			broken = True
		ones += s.count('1')
		zeros += s.count('0')
	if broken:
		print(num)
	elif not broken:
		if ones % 2 == 0 and zeros % 2 == 0:
			print(num)
		else:
			print(num - 1)


Q = int(input())
for _ in range(Q):
	n = int(input())
	l = []
	(one, zero) = (0, 0)
	for _ in range(n):
		si = input()
		one += si.count('1')
		zero += si.count('0')
		l.append(len(si))
	l.sort()
	need_pair = 0
	odd = 0
	ans = 0
	for li in l:
		need_pair += li // 2
		if li % 2 == 1:
			odd += 1
		if one // 2 + zero // 2 >= need_pair and one + zero - 2 * need_pair >= odd:
			ans += 1
		else:
			break
	print(ans)


import sys
q = int(input())
for _ in range(q):
	n = int(input())
	c0 = 0
	c1 = 0
	codd = 0
	cl = []
	for i in range(n):
		s = input()
		if len(s) % 2 == 1:
			codd += 1
		for c in s:
			if c == '1':
				c1 += 1
			else:
				c0 += 1
	res = n
	miss = (1 if c1 % 2 == 1 else 0) + (1 if c0 % 2 == 1 else 0)
	if codd < miss:
		res -= 1
	print(res)


for _ in range(int(input())):
	n = int(input())
	(count1, count2, result) = (0, 0, 0)
	for i in range(n):
		s = input()
		zeros = s.count('0')
		ones = len(s) - zeros
		if zeros & 1 and ones & 1:
			count1 += 1
		elif zeros & 1 or ones & 1:
			count2 += 1
		else:
			result += 1
	if count1 % 2 == 1:
		if count2 == 0:
			count1 -= 1
	print(result + count1 + count2)


ctt = int(input())
for ct in range(ctt):
	um = 0
	ze = 0
	tam = []
	n = int(input())
	for i in range(n):
		s = input()
		um += s.count('1')
		ze += s.count('0')
		tam.append(len(s))
	tam.sort()
	total = um // 2 * 2 + ze // 2 * 2
	sobra = um % 2 + ze % 2
	cont = 0
	for i in range(len(tam)):
		if tam[i] % 2 == 0:
			if total >= tam[i]:
				total -= tam[i]
				cont += 1
		elif total >= tam[i] - 1 and sobra >= 1:
			cont += 1
			sobra -= 1
			total -= tam[i] - 1
		elif total >= tam[i] + 1 and sobra == 0:
			cont += 1
			sobra += 1
			total -= tam[i] + 1
	print(cont)


n = int(input())
for _ in range(n):
	m = int(input())
	strings = []
	for i in range(m):
		strings.append(input())
	zero_count = 0
	one_count = 0
	odd_count = 0
	even_count = 0
	for s in strings:
		for c in s:
			if c == '0':
				zero_count += 1
			elif c == '1':
				one_count += 1
		if len(s) % 2 == 0:
			even_count += 1
		else:
			odd_count += 1
	ans = len(strings)
	if odd_count == 0:
		if one_count % 2 != 0 or zero_count % 2 != 0:
			ans -= 1
	else:
		odity_count = 0
		if zero_count % 2 == 1:
			odity_count += 1
		if one_count % 2 == 1:
			odity_count += 1
		if odd_count % 2 != odity_count % 2:
			ans -= 1
	print(ans)


def solve():
	n = int(input())
	cnt = [0] * 2
	odd = 0
	for i in range(n):
		s = input()
		if len(s) % 2:
			odd += 1
		for c in s:
			cnt[int(c)] += 1
	ans = 0
	for i in range(odd + 1):
		if cnt[0] >= i and cnt[1] >= odd - i:
			if (cnt[0] - i) % 2 == 0:
				ans = n
			else:
				ans = max(ans, n - 1)
	print(ans)
t = int(input())
for i in range(t):
	solve()


import math

def make_bs(s_list):
	n = len(s_list)
	res = n
	n_odd_strings = 0
	n_even_bad_strings = 0
	for i in range(n):
		s = s_list[i]
		m = len(s)
		if m % 2 == 1:
			n_odd_strings += 1
		else:
			n_zeros = s.count('0')
			n_ones = s.count('1')
			if n_zeros % 2 == 1 or n_ones % 2 == 1:
				n_even_bad_strings += 1
	if n_odd_strings == 0 and n_even_bad_strings % 2 == 1:
		res -= 1
	return res
i_mode = True
if i_mode:
	q = input()
	q = int(q)
	res = [None for k in range(q)]
	for i in range(q):
		n = input()
		n = int(n)
		s_list = [None for k in range(n)]
		for j in range(n):
			s = input()
			s_list[j] = s
		res[i] = make_bs(s_list)
	for i in range(q):
		print(res[i])
else:
	s_list = ['00', '01']
	s_list = ['1110', '100110', '010101']
	print(make_bs(s_list))


t = int(input())

def isodd(n):
	return n % 2 == 1
for t_ in range(t):
	n = int(input())
	odd = even0 = odd0 = 0
	for i in range(n):
		s = input()
		if isodd(len(s)):
			odd += 1
		if not isodd(s.count('0')):
			even0 += 1
		else:
			odd0 += 1
	if odd == 0 and isodd(odd0):
		print(n - 1)
	else:
		print(n)


q = int(input())
for _ in range(q):
	n = int(input())
	cnt = {'0': 0, '1': 0}
	even = []
	odd = []
	for _ in range(n):
		s = input()
		if len(s) & 1:
			odd.append(len(s))
		else:
			even.append(len(s))
		cnt['0'] += s.count('0')
		cnt['1'] += s.count('1')
	ans = n
	if cnt['0'] & 1 and cnt['1'] & 1 and (len(odd) == 0):
		ans = n - 1
	print(ans)


t = int(input())
for zz in range(t):
	n = int(input())
	(zeros, ones, arr, ans) = (0, 0, [], 0)
	for pp in range(n):
		(n_0, n_1) = (0, 0)
		string_temp = input()
		for i in string_temp:
			if i == '0':
				n_0 += 1
			else:
				n_1 += 1
		zeros += n_0
		arr.append(n_0 + n_1)
		ones += n_1
	arr.sort()
	while ans < n:
		if zeros >= arr[ans]:
			if arr[ans] % 2 and ones % 2:
				zeros -= arr[ans] - 1
				ones -= 1
			else:
				zeros -= arr[ans]
			ans += 1
		elif ones >= arr[ans]:
			if arr[ans] % 2 == 1 and zeros % 2 == 1:
				ones -= arr[ans] - 1
				zeros -= 1
			else:
				ones -= arr[ans]
			ans += 1
		elif zeros - zeros % 2 + ones - ones % 2 >= arr[ans] - arr[ans] % 2:
			req = arr[ans]
			req -= zeros - zeros % 2
			zeros = zeros % 2
			if arr[ans] % 2 and zeros % 2:
				ones -= req - 1
				zeros -= 1
			else:
				ones -= req
			ans += 1
		else:
			break
	print(ans)


foo = []
n = int(input())
for i in range(n):
	q = int(input())
	l = 0
	ll = 0
	for j in range(q):
		o = 0
		s = input()
		if len(s) % 2 == 1:
			ll += 1
		if len(s) % 2 == 0:
			for w in s:
				if w == '1':
					o += 1
			if o % 2 == 1:
				l += 1
	if ll > 0:
		foo.append(q)
	else:
		foo.append(q - l % 2)
for i in foo:
	print(i)


for t in range(int(input())):
	n = int(input())
	lenseven = []
	lensodd = []
	strs = []
	cnt0 = 0
	cnt1 = 0
	need = 0
	cangive = 0
	for _ in range(n):
		s = input()
		if len(s) % 2 == 0:
			lenseven.append(len(s))
		else:
			lensodd.append(len(s))
		x = sum((1 if c == '0' else 0 for c in s))
		cnt0 += x
		cnt1 += len(s) - x
	poss = 0
	for l in lensodd:
		if cnt0 >= l:
			cnt0 -= l
			poss += 1
		elif cnt1 >= l:
			cnt1 -= l
			poss += 1
		else:
			cnt1 -= l - cnt0
			cnt0 = 0
	if len(lenseven) > 0 and cnt0 % 2 == 1 and (poss == 0):
		print(n - 1)
	else:
		print(n)


q = int(input())
for i in range(q):
	w = int(input())
	r = 0
	t = 0
	for j in range(w):
		e = input()
		r = max(r, len(e) % 2)
		t += e.count('1')
	print(max(r * w, w - t % 2))


t = int(input())
for _ in range(t):
	n = int(input())
	it = []
	co = 0
	coo = 0
	for i in range(n):
		a = input()
		co += a.count('1')
		coo += a.count('0')
		it.append([a.count('1'), a.count('0')])
	it.sort(key=lambda x: x[0] + x[1])
	ans = 0
	for i in range(n):
		m = it[i][0] + it[i][1]
		if co == 0 and coo == 0:
			break
		if m % 2 == 1:
			if co % 2 == 1:
				co -= 1
			elif coo % 2 == 1:
				coo -= 1
			m -= 1
			st = True
			while m > 0:
				if co > 1:
					co -= 2
					m -= 2
					continue
				if coo > 1:
					coo -= 2
					m -= 2
					continue
				st = False
				break
			if st:
				ans += 1
				continue
			else:
				break
		else:
			st = True
			while m > 0:
				if co > 1:
					co -= 2
					m -= 2
					continue
				if coo > 1:
					coo -= 2
					m -= 2
					continue
				st = False
				break
			if st:
				ans += 1
				continue
			else:
				break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list()
	odd = 0
	one = 0
	for i in range(n):
		s = input()
		one += s.count('1')
		if len(s) % 2 == 1:
			odd += 1
	if odd == 0 and one % 2 == 1:
		print(n - 1)
	else:
		print(n)


q = int(input())
for _ in range(q):
	n = int(input())
	l = [0] * n
	cnt0 = 0
	cnt1 = 0
	cntodd = 0
	for i in range(n):
		s = input()
		l[i] = len(s)
		if l[i] % 2 == 1:
			cntodd = cntodd + 1
		for c in s:
			if c == '0':
				cnt0 = cnt0 + 1
			else:
				cnt1 = cnt1 + 1
	if cnt0 % 2 == 1 and cntodd > 0:
		cnt0 = cnt0 - 1
		cntodd = cntodd - 1
	if cnt1 % 2 == 1 and cntodd > 0:
		cnt1 = cnt1 - 1
		cntodd = cntodd - 1
	if cnt0 % 2 == 1 or cnt1 % 2 == 1:
		print(n - 1)
	else:
		print(n)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	k = 0
	y = 0
	z = 0
	for i in range(n):
		s = input()
		if len(s) % 2 == 1:
			k += 1
			y += 1
			continue
		c = Counter(s)
		if c['0'] % 2 == 0:
			k += 1
			continue
		z += 1
	t = k + z
	if y == 0:
		t -= z % 2
	print(t)


tt = int(input())
for _ in range(tt):
	n = int(input())
	m = mm = p = 0
	for i in range(n):
		s = input()
		mm += len(s)
		if len(s) % 2 == 1:
			p += 1
		for i in s:
			if i == '1':
				m += 1
	mm -= m
	if p % 2 == 1:
		print(n)
	elif m % 2 == 0 and mm % 2 == 0 or p >= 2:
		print(n)
	else:
		print(n - 1)


Q = int(input())
for q in range(Q):
	palindromes = 0
	exchange = 0
	half_exchange = 0
	N = int(input())
	for n in range(N):
		line = input()
		if len(line) % 2 == 1:
			palindromes += 1
			half_exchange += 1
		elif line.count('0') % 2 == 0:
			palindromes += 1
		elif exchange > 0:
			exchange -= 1
			palindromes += 2
		else:
			exchange = 1
	if exchange > 0 and half_exchange > 0:
		palindromes += 1
	print(palindromes)


q = int(input())
for t in range(q):
	n = int(input())
	(odd_donors, even_donors) = (0, 0)
	recipients = 0
	for i in range(n):
		s = list(input())
		z = len(list(filter(lambda x: x == '0', s)))
		o = len(s) - z
		if len(s) % 2 == 0:
			if o % 2 == z % 2 == 0:
				even_donors += 1
			else:
				recipients += 1
		else:
			odd_donors += 1
	cnt = recipients - recipients % 2 + even_donors + odd_donors
	if odd_donors > 0 and recipients % 2 > 0:
		cnt += 1
	print(cnt)


Q = int(input())
for _ in range(Q):
	n = int(input())
	zs = 0
	os = 0
	odd = 0
	for k in range(n):
		s = input()
		zs += s.count('0')
		os += s.count('1')
		odd += len(s) % 2
	if zs % 2 == 1 and os % 2 == 1 and (odd == 0):
		print(n - 1)
	else:
		print(n)


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
q = int(input())
while q:
	n = int(input())
	s = []
	tt1 = 0
	tt0 = 0
	pp = 0
	for i in range(n):
		t = list(map(str, input().strip()))
		for j in t:
			if j == '1':
				tt1 += 1
			else:
				tt0 += 1
		if len(t) % 2:
			pp += 1
	ans = n
	if tt0 % 2 and tt1 % 2:
		if pp == 0:
			ans -= 1
	print(ans)
	q -= 1


q = int(input())
for fwefe in range(q):
	n = int(input())
	j = 0
	z = 0
	par = []
	npar = []
	for i in range(n):
		s = input()
		je = s.count('1')
		ze = s.count('0')
		j += je
		z += ze
		if len(s) % 2 == 0:
			par.append(len(s))
		else:
			npar.append(len(s))
	par.sort()
	wyn = 0
	for i in par:
		if j < 0 or z < 0:
			break
		kz = 0
		while z - kz > j - (i - kz) and z - kz >= 0 and (kz <= i):
			kz += 2
		z -= kz
		j -= i - kz
		wyn += 1
		if j < 0 or z < 0:
			wyn -= 1
	wyn += len(npar)
	print(wyn)


n = int(input())
for i in range(n):
	m = int(input())
	total_0 = 0
	total_1 = 0
	mark = 0
	for k in range(m):
		s = input()
		if len(s) % 2 != 0:
			mark = 1
		if mark == 0:
			for j in s:
				if j == '1':
					total_1 += 1
				else:
					total_0 += 1
	if mark == 0:
		if total_0 % 2 != 0:
			m -= 1
	print(m)


Q = int(input())

def solve():
	n = int(input())
	lengths = []
	count_1 = 0
	count_0 = 0
	for _ in range(n):
		s = input()
		for c in s:
			if c == '1':
				count_1 += 1
			else:
				count_0 += 1
		lengths.append(len(s))
	lengths = sorted(lengths)
	ans = 0
	for l in lengths:
		if count_1 + count_0 >= l:
			while l != 0:
				if l == 1:
					l -= 1
					if count_0 % 2 == 1:
						count_0 -= 1
						continue
					if count_1 % 2 == 1:
						count_1 -= 1
						continue
					if count_0 >= count_1:
						count_0 -= 1
					else:
						count_1 -= 1
				else:
					if count_0 == 1 and count_1 == 1:
						break
					l -= 2
					if count_0 >= count_1:
						count_0 -= 2
					else:
						count_1 -= 2
		else:
			break
		if l == 0:
			ans += 1
		else:
			break
	print(ans)
for _ in range(Q):
	solve()


Q = int(input())
for iter1 in range(Q):
	n = int(input())
	wordlist = []
	hasodd = False
	onecount = 0
	for iter2 in range(n):
		inp = input().strip()
		if len(inp) % 2 == 1:
			hasodd = True
		wordlist.append(inp)
		onecount += inp.count('1')
	if onecount % 2 == 0:
		print(n)
	elif hasodd == True:
		print(n)
	else:
		print(n - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = []
	one = 0
	zero = 0
	for i in range(n):
		a = input()
		s.append(len(a))
		one += a.count('1')
		zero += a.count('0')
	even = 0
	odd = 0
	for i in s:
		if i % 2 == 0:
			even += 1
		else:
			odd += 1
	if even == 0:
		if odd % 2 == 0:
			print(n)
			continue
		elif one % 2 == 1 or zero % 2 == 1:
			print(n)
			continue
		else:
			print(n - 1)
			continue
	elif odd == 0:
		if one % 2 == 0 or zero % 2 == 0:
			print(n)
			continue
		else:
			print(n - 1)
			continue
	else:
		print(n)


n = int(input())
r = []
for i in ' ' * n:
	k = int(input())
	c = 0
	f = 0
	t = 0
	for j in ' ' * k:
		s = input()
		l = len(s)
		nuls = s.count('0')
		if nuls % 2 == 0 or (l - nuls) % 2 == 0:
			c += 1
			if l % 2 == 1:
				t += 1
		else:
			f += 1
	m = f // 2
	f -= m * 2
	c += m * 2
	c += min(t, f)
	r += [c]
for i in r:
	print(i)


q = int(input())
for _ in range(q):
	n = int(input())
	lengths = []
	ones = 0
	zeros = 0
	odd = 0
	for i in range(n):
		str = input()
		ones += str.count('1')
		zeros += str.count('0')
		if len(str) % 2 == 1:
			odd += 1
	if ones % 2 == 1 and zeros % 2 == 1 and (odd == 0):
		print(n - 1)
	else:
		print(n)


q = int(input())
for j in range(0, q):
	n = int(input())
	t = 0
	p = 0
	for i in range(0, n):
		s = input()
		if len(s) % 2 == 1:
			p = 1
		for i in s:
			if i == '0':
				t += 1
	if t % 2 == 1 and p == 0:
		print(n - 1)
	else:
		print(n)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
q = int(input())
while q != 0:
	one = 0
	zero = 0
	pald = 0
	sz = []
	n = int(input())
	for i in range(n):
		x = input()
		sz.append(len(x))
		for elem in x:
			if elem == '1':
				one += 1
			else:
				zero += 1
	if one % 2 != 0:
		one -= 1
	if zero % 2 != 0:
		zero -= 1
	one += zero
	sz.sort()
	for item in sz:
		if item % 2 != 0:
			item -= 1
		if item <= one:
			pald += 1
			one -= item
	print(pald)
	q -= 1


q = int(input())
for _ in range(q):
	n = int(input())
	odd = 0
	even1 = 0
	even2 = 0
	for _ in range(n):
		s = input()
		if len(s) % 2:
			odd += 1
		elif s.count('1') % 2:
			even1 += 1
		else:
			even2 += 1
	if odd > 0:
		print(odd + even1 + even2)
	elif even1 % 2:
		print(even1 + even2 - 1)
	else:
		print(even1 + even2)


import sys
for nt in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	o = 0
	for i in a:
		o += i.count('0')
	flag = 0
	for i in a:
		if len(i) % 2 == 1:
			flag = 1
			break
	if not flag and o % 2:
		print(n - 1)
	else:
		print(n)


q = int(input())
for i in range(q):
	n = int(input())
	amount1 = 0
	amount0 = 0
	bad = 0
	for i in range(n):
		a = input()
		if len(a) % 2 == 0:
			amount0 += 1
			if a.count('0') % 2 == 1:
				bad += 1
		else:
			amount1 += 1
	if amount1 == 0 and bad % 2 == 1:
		print(amount0 - 1)
	else:
		print(amount1 + amount0)


def judge(n, l):
	t = sum((len(x) % 2 for x in l))
	d = {0: 0, 1: 0}
	for x in l:
		c = x.count('1')
		d[1] ^= c % 2
		d[0] ^= (len(x) - c) % 2
	return n - (t % 2 ^ (d[0] + d[1]) % 2 | (t < d[0] + d[1]))
q = int(input())
for _ in range(q):
	n = int(input())
	l = [input() for _ in range(n)]
	print(judge(n, l))


t = int(input())
for _ in range(t):
	n = int(input())
	a = 0
	b = 0
	l = 0
	for i in range(n):
		s = input()
		a += s.count('1')
		b += s.count('0')
		if len(s) % 2 == 1:
			l += 1
	if a % 2 == 1 and b % 2 == 1 and (l % 2 == 0) and (l > 0):
		print(n)
	elif a % 2 == 1 and b % 2 == 0 and (l % 2 == 1):
		print(n)
	elif a % 2 == 0 and b % 2 == 1 and (l % 2 == 1):
		print(n)
	elif a % 2 == 0 and b % 2 == 0 and (l % 2 == 0):
		print(n)
	else:
		print(n - 1)


Q = int(input())
for i in range(Q):
	n = int(input())
	odd = False
	fail = 0
	for j in range(n):
		s = input()
		ct = 0
		if len(s) % 2 == 1:
			odd = True
			continue
		for c in s:
			if c == '1':
				ct += 1
		if ct % 2 == 1:
			fail += 1
	if odd:
		print(n)
	else:
		print(n - fail % 2)


cases = int(input())
for _ in range(cases):
	strs = [input() for _ in range(int(input()))]
	strs.sort()
	count0 = 0
	count1 = 0
	for s in strs:
		for c in s:
			if c == '0':
				count0 += 1
			else:
				count1 += 1
	pairs = count0 // 2 + count1 // 2
	count = 0
	for s in strs:
		if len(s) // 2 <= pairs:
			pairs -= len(s) // 2
			count += 1
		else:
			break
	print(count)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	one = 0
	odd = 0
	for i in range(n):
		x = input()
		one += x.count('1')
		if len(x) % 2 == 1:
			odd += 1
	if odd == 0 and one % 2 == 1:
		print(n - 1)
	else:
		print(n)


t = int(input())
for _ in range(t):
	n = int(input())
	(odd, even, evenb) = (0, 0, 0)
	for i in range(n):
		s = input()
		if len(s) % 2:
			odd += 1
		if s.count('0') % 2 == 0:
			even += 1
		else:
			evenb += 1
	if odd == 0 and evenb % 2 == 1:
		print(n - 1)
	else:
		print(n)


from collections import Counter
cases = int(input())
for q in range(cases):
	n = int(input())
	ss = ''
	ls = False
	for i in range(n):
		s = input()
		if len(s) % 2 != 0:
			ls = True
		ss += s
	ss = Counter(ss)
	if ss['0'] % 2 != 0 and (not ls):
		print(n - 1)
	else:
		print(n)


import math
import os
import random
import re
import sys

def solve(n, a):
	cnt = 0
	odd = 0
	for i in range(n):
		if len(a[i]) % 2 != 0:
			odd = 1
		else:
			cnt1 = 0
			for j in range(len(a[i])):
				if a[i][j] == '1':
					cnt1 += 1
			if cnt1 % 2 != 0:
				cnt += 1
	if odd == 0 and cnt % 2 != 0:
		return n - 1
	return n
Q = int(input())
for t in range(Q):
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	print(solve(n, a))


q = int(input())
for i in range(q):
	n = int(input())
	ln = []
	ok = False
	(_1, _0) = (0, 0)
	for j in range(n):
		s = input()
		ln.append(len(s))
		if len(s) % 2 == 1:
			ok = True
		_1 += s.count('1')
		_0 += s.count('0')
	if ok:
		print(n)
		continue
	ln = sorted(ln)[::-1]
	res = 0
	for j in ln:
		if j <= _0:
			_0 -= j
			res += 1
		elif j <= _1:
			_1 -= j
			res += 1
		else:
			a = _0 // 2 * 2
			b = j - a
			if b <= _1:
				res += 1
				_0 -= a
				_1 -= b
				continue
			a = _1 // 2 * 2
			b = j - a
			if b <= _0:
				res += 1
				_1 -= a
				_0 -= b
				continue
	print(res)


for _ in range(int(input())):
	n = int(input())
	s = []
	(one, zero) = (0, 0)
	(odd, even) = (0, 0)
	for i in range(n):
		x = input()
		s.append(x)
		one += x.count('1')
		zero += x.count('0')
		if len(x) % 2 == 0:
			even += 1
		else:
			odd += 1
	one = one % 2
	zero = zero % 2
	need = one + zero
	if one + zero <= odd:
		ans = n
	else:
		ans = n - 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	ones = 0
	zeros = 0
	length = 0
	flag = 0
	for i in range(n):
		s = input()
		ones += s.count('1')
		zeros += s.count('0')
		length += len(s)
		if len(s) % 2:
			flag = 1
	if length % 2 == 0:
		if ones % 2 and zeros % 2 and (flag == 0):
			print(n - 1)
		else:
			print(n)
	else:
		print(n)


import os
import operator
from collections import defaultdict
import sys
from io import BytesIO, IOBase
import bisect

def main():
	for _ in range(int(input())):
		n = int(input())
		even_odd = 0
		ans = 0
		odd = 0
		for i in range(n):
			st = input()
			if len(st) & 1:
				odd += 1
				ans += 1
				continue
			o = 0
			z = 0
			for j in range(len(st)):
				if st[j] == '1':
					o += 1
				else:
					z += 1
			if z & 1 == 0:
				ans += 1
			else:
				even_odd += 1
		if even_odd & 1 == 1:
			if odd == 0:
				even_odd -= 1
		print(ans + even_odd)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
sys.setrecursionlimit(10 ** 8)
n = int(input())
for i in range(n):
	q = int(input())
	ones = 0
	zeros = 0
	odds = 0
	evens = 0
	for j in range(q):
		s = input().rstrip()
		ones += s.count('1')
		zeros += s.count('0')
		if len(s) % 2 == 1:
			odds += 1
		else:
			evens += 1
	if zeros % 2 == 0 and ones % 2 == 0:
		if evens == q:
			print(q)
		elif odds % 2 == 0:
			print(q)
		else:
			print(q - 1)
	elif zeros % 2 != ones % 2:
		if evens == q:
			print(q - 1)
		elif odds % 2 == 1:
			print(q)
		else:
			print(q - 1)
	elif zeros % 2 == 1 and ones % 2 == 1:
		if evens == q:
			print(q - 1)
		elif odds % 2 == 0:
			print(q)
		else:
			print(q - 1)


import math
t = int(input())
while t:
	n = int(input())
	j = n
	cnt = 0
	oo = 0
	oe = 0
	ee = 0
	while j:
		s = input()
		l = len(s)
		(o, z) = (0, 0)
		for i in range(l):
			if s[i] == '1':
				o += 1
			else:
				z += 1
		if l % 2 == 0:
			if o % 2 == 0 and z % 2 == 0:
				ee += 1
				cnt += 1
			if o % 2 != 0 and z % 2 != 0:
				oo += 1
		else:
			cnt += 1
			oe += 1
		j -= 1
	if ee > 0:
		if oo % 2 == 0:
			cnt += oo
			oo = 0
		else:
			cnt += oo - 1
			oo = 1
	cnt += 2 * (oo // 2)
	oo -= 2 * (oo // 2)
	cnt += min(oo, oe)
	oo -= min(oo, oe)
	print(cnt)
	t -= 1


q = int(input())
datalist = []
for j in range(q):
	m = int(input())
	a = []
	for i in range(m):
		a.append(str(input()))
	datalist.append(a)

def palindromer(inputlist):
	counterlist = []

	def eveodd(binarystring):
		zerocount = 0
		onecount = 0
		for k in binarystring:
			if k == '0':
				zerocount += 1
			else:
				onecount += 1
		return [zerocount, onecount]
	for j in inputlist:
		counterlist.append(eveodd(j))
	eveevecount = 0
	eveoddcount = 0
	oddoddcount = 0
	for j in counterlist:
		if j[0] % 2 == 0 and j[1] % 2 == 0:
			eveevecount += 1
		elif j[0] % 2 != 0 and j[1] % 2 != 0:
			oddoddcount += 1
		elif j[0] % 2 != 0 and j[1] % 2 == 0:
			eveoddcount += 1
		elif j[0] % 2 == 0 and j[1] % 2 != 0:
			eveoddcount += 1
	total = eveevecount + oddoddcount + eveoddcount
	if oddoddcount % 2 == 0:
		return total
	elif eveoddcount >= 1:
		return total
	else:
		return total - 1
for j in datalist:
	print(palindromer(j))


from math import ceil

def run_testcase():
	n = int(input())
	strings = [None] * n
	for i in range(n):
		strings[i] = [int(x) for x in input()]

	def swaps_to_palindrome(string):
		string_reversed = string[::-1]
		swaps = 0
		for (char1, char2) in zip(string, string_reversed):
			if char1 != char2:
				swaps += 1
		return ceil(swaps / 2)
	swaps = list(map(swaps_to_palindrome, strings))
	swaps.sort()
	palindromes = 0
	left = 0
	right = len(swaps) - 1
	sum_swaps = sum(swaps)
	odd_swaps = sum((swap % 2 == 1 for swap in swaps))
	even_swaps = n - odd_swaps
	odd_lengths = sum((len(string) % 2 == 1 for string in strings))
	if odd_swaps % 2 == 1 and odd_lengths == 0:
		return n - 1
	else:
		return n
testcase_count = int(input())
for i in range(testcase_count):
	print(str(run_testcase()))


from __future__ import division
import re

class Text_summarizer(object):

	def convert_sentences(self, text):
		text = text.replace('\n', '. ')
		return text.split('. ')

	def convert_paragraphs(self, text):
		return text.split('\n\n')

	def intersection_of_sentences(self, sentences1, sentences2):
		s1 = set(sentences1.split(' '))
		s2 = set(sentences2.split(' '))
		if len(s1) + len(s2) == 0:
			return 0
		return len(s1.intersection(s2)) / ((len(s1) + len(s2)) / 2)

	def format_sentence(self, sentence):
		sentence = re.sub('\\W+', '', sentence)
		return sentence

	def get_senteces_ranks(self, text):
		sentences = self.convert_sentences(text)
		n = len(sentences)
		values = [[0 for x in range(n)] for x in range(n)]
		for i in range(0, n):
			for j in range(0, n):
				values[i][j] = self.intersection_of_sentences(sentences[i], sentences[j])
		sentences_dic = {}
		for i in range(0, n):
			score = 0
			for j in range(0, n):
				if i == j:
					continue
				score += values[i][j]
			sentences_dic[self.format_sentence(sentences[i])] = score
		return sentences_dic

	def get_best_sentence(self, paragraph, sentences_dic):
		sentences = self.convert_sentences(paragraph)
		if len(sentences) < 2:
			return ''
		best_sentence = ''
		max_value = 0
		for s in sentences:
			strip_s = self.format_sentence(s)
			if strip_s:
				if sentences_dic[strip_s] > max_value:
					max_value = sentences_dic[strip_s]
					best_sentence = s
		return best_sentence

	def get_summary(self, title, text, sentences_dic):
		paragraphs = self.convert_paragraphs(text)
		summary = []
		summary.append(title.strip())
		summary.append('')
		for p in paragraphs:
			sentence = self.get_best_sentence(p, sentences_dic).strip()
			if sentence:
				summary.append(sentence)
		return '\n'.join(summary)

def main():
	for _ in range(int(input())):
		YYYn = int(input())
		(s, o, ep, enp) = ([], 0, 0, 0)
		for i in range(YYYn):
			r = input()
			if len(r) % 2 != 0:
				o += 1
			elif r.count('1') % 2 == 0:
				ep += 1
			else:
				enp += 1
			s.append(r)
		if o > 0:
			print(YYYn)
		else:
			if enp % 2 != 0:
				enp -= 1
			print(ep + enp)
main()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = []
	c = 0
	e = 0
	o = 0
	for i in range(n):
		p = input()
		p = list(p)
		if len(p) % 2 == 0:
			c += p.count('1')
		else:
			o += 1
	if 1:
		if o == 0:
			if c % 2 == 0:
				print(n)
			else:
				print(n - 1)
		else:
			print(n)


qs = int(input())
for q in range(qs):
	n = int(input())
	bs = []
	odd_count = 0
	even_good = 0
	even_bad = 0
	for i in range(n):
		s = input()
		one_count = 0
		for j in s:
			if j == '1':
				one_count += 1
		if len(s) % 2 == 1:
			odd_count += 1
		elif one_count % 2 == 1:
			even_bad += 1
		else:
			even_good += 1
	if odd_count == 0 and even_bad % 2 == 1:
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	l = []
	c = 0
	ans = 0
	for i in range(n):
		l.append(input())
	for i in range(n):
		s = l[i]
		if len(s) % 2:
			print(n)
			break
	else:
		for i in range(n):
			if l[i].count('1') % 2:
				c += 1
			else:
				ans += 1
		if c % 2:
			print(n - 1)
		else:
			print(n)


def counter1(s):
	count1 = 0
	count0 = 0
	for i in s:
		if i == '1':
			count1 += 1
		else:
			count0 += 1
	return (count1, count0)

def func1(l):
	numeven = 0
	count1 = 0
	count0 = 0
	for i in l:
		if len(i) % 2 == 0:
			numeven += 1
		temp = counter1(i)
		count1 += temp[0]
		count0 += temp[1]
	ll = 0
	if count1 % 2 != 0:
		ll += 1
	if count0 % 2 != 0:
		ll += 1
	if numeven == 0:
		return len(l)
	numodd = len(l) - numeven
	if numodd >= ll:
		return len(l)
	return len(l) - 1
n = int(input())
for i in range(n):
	ni = int(input())
	list1 = []
	for j in range(ni):
		list1.append(input())
	print(func1(list1))


def huiw(w):
	if w[::-1] == w:
		return 1
	else:
		return 0
q = int(input())
for i in range(0, q):
	n = int(input())
	p = [''] * n
	a = [0] * n
	b = [0] * n
	c = [0] * n
	for j in range(n):
		p[j] = input()
		a[j] = p[j].count('0')
		b[j] = p[j].count('1')
		c[j] = len(p[j])
	if sum(c) % 2 != 0:
		print(n)
	elif sum(c) % 2 == 0 and sum(a) % 2 == 0:
		print(n)
	else:
		for j in range(0, n):
			c[j] = c[j] % 2
		if 1 in c:
			print(n)
		else:
			print(n - 1)


n = int(input())
for _ in range(n):
	k = int(input())
	l = []
	for x in range(k):
		i = input()
		l.append(i)
	cc = len([x for x in l if len(x) % 2 == 0])
	p = 0
	for t in l:
		nc = len([x for x in t if x == '0'])
		if nc % 2 != 0:
			p += 1
	if cc == k and p % 2 != 0:
		print(k - 1)
	else:
		print(k)


for _ in range(int(input())):
	n = int(input())
	a = [0, 0]
	even = True
	for i in range(n):
		s = input()
		for i in s:
			a[ord(i) - ord('0')] += 1
		if len(s) % 2:
			even = False
	print(n - 1 if even and a[0] % 2 else n)


t = int(input())
for _ in range(t):
	n = int(input())
	ct = 0
	ct1 = 0
	res = 0
	for i in range(n):
		s = input()
		zc = s.count('0')
		oc = len(s) - zc
		if zc & 1 and oc & 1:
			ct += 1
		elif zc & 1 or oc & 1:
			ct1 += 1
		else:
			res += 1
	if ct % 2 == 1:
		if ct1 == 0:
			ct -= 1
	print(res + ct + ct1)


t = int(input())
for i in range(t):
	n = int(input())
	strings = [input() for i in range(n)]
	odd = 0
	evengood = 0
	evenbad = 0
	for i in range(n):
		if len(strings[i]) % 2 == 1:
			odd += 1
		elif strings[i].count('1') % 2 == 0:
			evengood += 1
		else:
			evenbad += 1
	if odd == 0 and evenbad % 2 == 1:
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	l = []
	doubt = 0
	ans = 0
	odd = 0
	even = 0
	for i in range(int(input())):
		s = input()
		l.append(s)
		if len(s) % 2 == 1:
			odd += 1
		elif s.count('1') % 2 == 0:
			even += 1
		else:
			doubt += 1
	if doubt % 2 == 0:
		even += doubt
	else:
		even += doubt - 1
		if odd > 0:
			odd += 1
	print(even + odd)


import sys

def I():
	return sys.stdin.readline().rstrip()
q = int(I())
for _ in range(q):
	n = int(I())
	(one, zero, odd) = (0, 0, 0)
	for _ in range(n):
		s = I()
		odd += len(s) & 1
		for c in s:
			if c == '0':
				zero += 1
			else:
				one += 1
	if one & 1 == 1 and zero & 1 == 1 and (odd == 0):
		n -= 1
	print(n)


def solve():
	n = int(input())
	odd_str = False
	zero_cnt = 0
	one_cnt = 0
	for i in range(n):
		s = input()
		for j in s:
			if j == '0':
				zero_cnt += 1
			else:
				one_cnt += 1
		if len(s) % 2 == 1:
			odd_str = True
	if odd_str or (zero_cnt % 2 == 0 and one_cnt % 2 == 0):
		print(n)
	else:
		print(n - 1)
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	flag = 0
	count = 0
	for j in range(n):
		s = input()
		l = len(s)
		if l % 2 == 1:
			flag = 1
		for k in range(l):
			if s[k] != s[l - 1 - k]:
				count += 1
	count //= 2
	if flag == 1 or count % 2 == 0:
		print(n)
	else:
		print(n - 1)


q = int(input())
for _ in range(q):
	n = int(input())
	st = [input() for _ in range(n)]
	print(n if any((len(s) % 2 for s in st)) or sum((s.count('0') for s in st)) % 2 == 0 else n - 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = 0
	b = 0
	aa = 0
	for j in range(n):
		ss = input()
		z = 0
		on = 0
		if len(ss) % 2 == 1:
			aa = 1
		else:
			for i in ss:
				if i == '0':
					z = z + 1
				else:
					on = on + 1
			if on % 2 == 0 and z % 2 == 0:
				s = s + 1
			else:
				b = b + 1
				if b == 2:
					s = s + 2
					b = 0
	if aa == 1:
		print(n)
	else:
		print(s)


q = int(input())
for i in range(q):
	n = int(input())
	zero_no = 0
	one_no = 0
	even_string = 0
	odd_string = 0
	for a in range(n):
		string = input()
		if len(string) % 2 == 0:
			even_string += 1
		else:
			odd_string += 1
		for binary in string:
			if binary == '0':
				zero_no += 1
			else:
				one_no += 1
	if odd_string == 0 and (zero_no % 2 == 1 and one_no % 2 == 1):
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(input())
	count1 = 0
	count2 = 0
	l = []
	for i in arr:
		l.append(len(i))
		count1 += i.count('0')
		count2 += i.count('1')
	l.sort()
	ans = 0
	f = 0
	for i in l:
		c = ''
		if i % 2 == 0:
			for j in range(i // 2):
				if count1 > count2 and count1 >= 2:
					count1 -= 2
					continue
				if count2 >= count1 and count2 >= 2:
					count2 -= 2
					continue
				else:
					f = 1
					break
			if f == 0:
				ans += 1
			else:
				f = 0
		else:
			if count1 % 2 != 0 and count1 >= 1:
				count1 -= 1
			elif count2 % 2 != 0 and count2 >= 1:
				count2 -= 1
			for j in range(i // 2):
				if count1 > count2 and count1 >= 2:
					count1 -= 2
					continue
				if count2 >= count1 and count2 >= 2:
					count2 -= 2
					continue
				else:
					f = 1
					break
			if f == 0:
				ans += 1
			else:
				f = 0
	print(ans)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = []
	alleven = True
	for i in range(N):
		tmp = list(input())
		if len(tmp) % 2 == 1:
			alleven = False
		A += tmp
	C = Counter(A)
	if alleven and C['0'] % 2 == 1:
		print(N - 1)
	else:
		print(N)


def solve():
	n = int(input())
	x = [0, 0]
	(ones, zeros) = (0, 0)
	for i in range(n):
		s = input()
		x[len(s) % 2] += 1
		ones += s.count('1')
		zeros += s.count('0')
	if x[1] > 0:
		print(n)
		return
	elif ones % 2 == 1 and zeros % 2 == 1:
		print(n - 1)
		return
	print(n)
for i in range(int(input())):
	solve()


def main():
	import sys
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		N = int(input())
		odd = 0
		zero_num = 0
		for _ in range(N):
			s = input().rstrip('\n')
			L = len(s)
			if L % 2 == 1:
				odd = 1
			zero_num += s.count('0')
		if odd:
			print(N)
		elif zero_num % 2 == 1:
			print(N - 1)
		else:
			print(N)
main()


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = (0, 0, 0)
	for i in range(n):
		s = input()
		if len(s) % 2 == 1:
			a += 1
		elif s.count('0') % 2 == 0:
			b += 1
		else:
			c += 1
		y = lambda a, c: 1 if a == 0 and c % 2 == 1 else 0
	print(n - y(a, c))


n = int(input())
for i in range(n):
	(even, odd) = (0, 0)
	st = []
	k = int(input())
	for i in range(k):
		st.append(input())
		if len(st[i]) % 2 != 0:
			odd += 1
		else:
			even += 1
	if odd != 0:
		print(even + odd)
	else:
		num = 0
		for i in range(len(st)):
			f = 0
			for j in range(len(st[i])):
				if st[i][j] == '1':
					f += 1
			if f % 2 == 0:
				num += 1
		if (even - num) % 2 == 0:
			print(even)
		else:
			print(even - 1)


for _ in range(int(input())):
	n = int(input())
	numOdd = 0
	numEvenMisfit = 0
	flag = 0
	for i in range(n):
		s = list(map(int, list(input())))
		if len(s) % 2 != 0:
			flag = 1
			numOdd += 1
		elif sum(s) % 2 != 0:
			numEvenMisfit += 1
	if flag == 1:
		print(n)
	elif numEvenMisfit % 2 != 0:
		print(n - 1)
	else:
		print(n)


te = int(input())
while te > 0:
	te -= 1
	good = 0
	bad = 0
	odd = 0
	n = int(input())
	for u in range(n):
		s = list(input())
		if len(s) % 2 == 0:
			zeros = 0
			ones = 0
			for i in s:
				if i == '0':
					zeros += 1
				else:
					ones += 1
			if zeros % 2 != 0:
				bad += 1
			else:
				good += 1
		else:
			odd += 1
	ans = 0
	if odd > 0:
		ans = n
	elif odd == 0 and bad % 2 == 1:
		ans = n - 1
	else:
		ans = n
	print(ans)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	m = []
	for i in range(n):
		a = list(map(int, input()))
		m.append(a)
	for i in range(n):
		z = 0
		m[i].sort()
		for j in range(len(m[i])):
			if m[i][j] == 0:
				z += 1
		for j in range(z // 2):
			m[i].pop(0)
			m[i].append(0)
			z -= 2
		if z == 1:
			m[i].pop(0)
			m[i].insert(len(m[i]) // 2, 0)
	ans = 0
	for i in range(n):
		p = len(m[i])
		for k in range(p // 2):
			f = 0
			if m[i][k] != m[i][p - k - 1] or k == p - k - 1:
				if m[i][k] == 1:
					l = k
				else:
					l = p - k - 1
				for j in range(n):
					if i == j:
						continue
					else:
						le = len(m[j])
						g1 = 0
						if le % 2 == 1:
							g1 += 1
						for h in range(le // 2 + g1):
							if m[j][h] != m[j][le - h - 1]:
								f = 1
								if m[j][h] == 0:
									v = h
								else:
									v = le - h - 1
								break
							if le - h - 1 == h:
								v = h
								if m[j][h] == 1:
									l = p - 1 - l
								f = 1
								break
						if f == 1:
							break
				if f == 1:
					o = m[i][l]
					m[i][l] = m[j][v]
					m[j][v] = o
		f = 0
		for k in range(p // 2):
			if m[i][k] != m[i][p - k - 1]:
				f = 1
				break
		if f == 0:
			ans += 1
	print(ans)


from math import *
from sys import *
from heapq import *
from collections import defaultdict
from itertools import permutations
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def graph_as_tree_1_root():
	n = int(input())
	dict = defaultdict(list)
	for _ in range(n - 1):
		(x, y) = list(map(int, input().split()))
		dict[x].append(y)
		dict[y].append(x)
	tree = [[1]]
	temp = [1]
	vall = 0
	seen = set([i for i in range(2, n + 1)])
	lol = []
	while len(seen) > 0:
		lol = list(seen)
		tt = []
		for x in temp:
			aa = []
			for val in dict[x]:
				if val in seen:
					aa += [val]
					seen.remove(val)
			dict[x] = aa
			tt += aa
		tree.append(tt)
		temp = tt
		vall += 1
	for x in lol:
		dict[x] = []
	print(tree, dict)

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b //= 2
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def alldivisors(n):
	list = []
	arr = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				arr += [i]
			else:
				arr += [i]
				list.append(n // i)
	arr += list[::-1]
	return arr

def primefactorisation(n):
	potentional_p = 3
	itog_list = defaultdict(int)
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			itog_list[n] += 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			itog_list[potentional_p] += 1
		potentional_p += 2
	return itog_list

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = []
		zero = 0
		one = 0
		for __ in range(n):
			s = input()
			zero += s.count('0')
			one += s.count('1')
			arr.append(len(s))
		tod = 0
		for x in arr:
			if x % 2 == 1:
				tod += 1
		if tod % 2 == 1 and zero % 2 == 0 and (one % 2 == 1):
			print(n)
		elif tod % 2 == 1 and zero % 2 == 1 and (one % 2 == 0):
			print(n)
		elif tod == 0 and zero % 2 == 1 and (one % 2 == 1):
			print(n - 1)
		else:
			print(n)
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


I = input
for _ in [0] * int(I()):
	n = int(I())
	a = [I() for _ in [0] * n]
	print(n - (all((len(s) % 2 ^ 1 for s in a)) & ''.join(a).count('1')))


n = int(input())
for _ in range(n):
	q = int(input())
	S = []
	for __ in range(q):
		S.append(input())
	res = 0
	cnt = 0
	for s in S:
		c0 = s.count('0')
		c1 = s.count('1')
		if c0 % 2 == 1 and c1 % 2 == 1:
			res -= 1
			cnt += 1
		elif (c0 + c1) % 2 == 1:
			res = 0
			break
	if res >= 0:
		res = 0
	else:
		res = -1
	if cnt % 2 == 0:
		res = 0
	print(len(S) + res)


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def bo(i):
	return ord(i) - ord('a')
from copy import *
from bisect import *
from itertools import permutations
t = fi()
while t > 0:
	t -= 1
	n = fi()
	l = []
	d = [0, 0]
	for i in range(n):
		s = si()
		if len(s) & 1 == 0:
			l.append(len(s))
		d[0] += s.count('0')
		d[1] += s.count('1')
	flag = 0
	for i in range(len(l)):
		if d[0] % 2 and d[1] % 2:
			flag = 1
			break
		elif d[0] % 2 == 1:
			d[0] -= 1
		else:
			d[1] -= 1
	print(n - flag * int(len(l) == n))


for _ in range(int(input())):
	n = int(input())
	zero = 0
	od = 0
	for i in range(n):
		s = input()
		if len(s) % 2:
			od = 1
		zero += s.count('0')
	if od or zero % 2 == 0:
		print(n)
	else:
		print(n - 1)


q = int(input())
for case in range(q):
	n = int(input())
	length = []
	count_1 = 0
	count_0 = 0
	for line in range(n):
		s = input()
		length.append(len(s))
		for c in s:
			if c == '1':
				count_1 += 1
			else:
				count_0 += 1
	length.sort()
	pali = 0
	sum_c = count_1 + count_0
	odd_num = count_1 % 2 + count_0 % 2
	if n > 1:
		for l in length[:-1]:
			if l % 2 == 1:
				if odd_num > 0:
					odd_num -= 1
				else:
					odd_num += 1
	if odd_num == 2:
		print(n - 1)
	else:
		print(n)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = []
	for i in range(n):
		a.append(list(map(int, list(input()))))
	count0 = 0
	count1 = 0
	lengths = []
	for i in range(n):
		lengths.append(len(a[i]))
		count0 += a[i].count(0)
		count1 += a[i].count(1)
	l = sorted(lengths)
	flag = [0] * n
	for i in range(n):
		if l[i] % 2 == 0:
			if l[i] <= count0:
				flag[i] = 1
				count0 -= l[i]
			elif l[i] <= count1:
				flag[i] = 1
				count1 -= l[i]
			else:
				temp0 = count0 // 2
				temp0 *= 2
				temp1 = count1 // 2
				temp1 *= 2
				if l[i] <= temp0 + temp1:
					count0 -= temp0
					l[i] -= temp0
					count1 -= l[i]
					flag[i] = 1
	for i in range(n):
		if l[i] & 1:
			if l[i] <= count0:
				flag[i] = 1
				count0 -= l[i]
			elif l[i] <= count1:
				flag[i] = 1
				count1 -= l[i]
			else:
				(count0, count1) = (min(count0, count1), max(count0, count1))
				if l[i] <= count1 + count0:
					l[i] -= count1
					count1 = 0
					count0 -= l[i]
					flag[i] = 1
	print(flag.count(1))


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	return [[default for j in range(m)] for i in range(n)]

def arr3D(n, m, r, default=0):
	return [[[default for k in range(r)] for j in range(m)] for i in range(n)]

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

class DSU:

	def __init__(self, length):
		self.length = length
		self.parent = [-1] * self.length

	def getParent(self, node, start):
		if node >= self.length:
			return False
		if self.parent[node] < 0:
			if start != node:
				self.parent[start] = node
			return node
		return self.getParent(self.parent[node], start)

	def union(self, node1, node2):
		parent1 = self.getParent(node1, node1)
		parent2 = self.getParent(node2, node2)
		if parent1 == parent2:
			return False
		elif self.parent[parent1] <= self.parent[parent2]:
			self.parent[parent1] += self.parent[parent2]
			self.parent[parent2] = parent1
		else:
			self.parent[parent2] += self.parent[parent1]
			self.parent[parent1] = parent2
		return True

	def getCount(self, node):
		return -self.parent[self.getParent(node, node)]

def exact(num):
	if abs(num - round(num)) <= 10 ** (-9):
		return round(num)
	return num

def solve(n, lst):
	ones = 0
	zeros = 0
	length = []
	for i in lst:
		currOnes = i.count('1')
		ones += currOnes
		zeros += len(i) - currOnes
		length.append(len(i))
	length = sorted(length)
	cnt = 0
	for i in length:
		if zeros + ones >= i:
			can = False
			(bestA, bestB) = (0, 0)
			for j in range(ones + 1):
				k = i - j
				if k <= zeros and (j % 2 == 0 or k % 2 == 0):
					bestA = j
					bestB = k
					can = True
					if (bestA != 0 or bestB != 0) and ((ones - bestA) % 2 == 0 or (zeros - bestB) % 2 == 0):
						break
			if can:
				ones -= bestA
				zeros -= bestB
			else:
				break
		else:
			break
		cnt += 1
	return cnt
for _ in range(int(input())):
	n = int(input())
	lst = []
	for i in range(n):
		lst.append(input())
	print(solve(n, lst))


from functools import reduce
from sys import stdin
from bisect import bisect_left, bisect_right

def main():
	n = int(stdin.readline())
	(o, e) = (0, 0)
	odd_l = False
	for _ in range(n):
		st = stdin.readline().strip()
		if len(st) % 2 != 0:
			odd_l = True
		o += len([x for x in st if x == '1'])
		e += len([x for x in st if x == '0'])
	if o % 2 == 0 or odd_l:
		print(n)
	else:
		print(n - 1)
[main() for _ in range(int(input()))]


for i in range(int(input())):
	n = int(input())
	(b, g, o) = (0, 0, 0)
	for i in range(n):
		s = input()
		if len(s) % 2:
			o += 1
		if s.count('0') % 2 == 0:
			g += 1
		else:
			b += 1
	if o == 0 and b % 2:
		n -= 1
	print(n)


t = int(input())
for j in range(t):
	n = int(input())
	z = 0
	o = 0
	ans = n
	c = 0
	f = 0
	for i in range(n):
		x = input()
		if len(x) % 2 != 0:
			c += 1
			f = 1
		else:
			z += x.count('0')
			o += x.count('1')
	if f == 0:
		if o % 2 != 0 and z % 2 != 0:
			ans = n - 1
	print(ans)


for q in range(int(input())):
	n = int(input())
	ae = True
	cnt = [0, 0]
	for i in range(n):
		wo = input()
		if len(wo) & 1:
			ae = False
		for w in wo:
			cnt[int(w)] += 1
	if ae and cnt[0] & 1 and cnt[1] & 1:
		print(n - 1)
	else:
		print(n)


from sys import stdin
t = int(stdin.readline().strip())
for c in range(t):
	n = int(stdin.readline().strip())
	o = 0
	z = 0
	flag = False
	for i in range(n):
		s = stdin.readline().strip()
		o += s.count('1')
		z += s.count('0')
		if len(s) % 2 != 0:
			flag = True
	if flag:
		print(n)
	elif o % 2 != 0 or z % 2 != 0:
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	oddlen = 0
	evengood = 0
	evenbad = 0
	n = int(input())
	for i in range(n):
		s = input()
		if len(s) & 1:
			oddlen += 1
		elif s.count('0') & 1:
			evenbad += 1
		else:
			evengood += 1
	if oddlen == 0 and evenbad & 1:
		print(n - 1)
	else:
		print(n)


q = int(input())
while q:
	q -= 1
	n = int(input())
	k = 0
	so = 0
	for i in range(n):
		t = input()
		if not len(t) % 2:
			so += sum([c == '1' for c in t])
			continue
		k += 1
	if not k and so % 2:
		print(n - 1)
	else:
		print(n)


import math
import sys

def cinfloat():
	n = float(input())
	return n

def cinints():
	return [int(x) for x in input().split()]

def cinint():
	n = int(input())
	return n

def solve():
	n = cinint()
	o = 0
	be = 0
	c0 = 0
	for i in range(n):
		s = input()
		if len(s) % 2 == 0:
			c0 = s.count('0')
			c1 = s.count('1')
			if c0 % 2 == 1 and c1 % 2 == 1:
				be += 1
		else:
			o += 1
	if o >= 1:
		print(n)
	elif be % 2 == 0:
		print(n)
	else:
		print(n - 1)

def main():
	t = 1
	t = cinint()
	for i in range(t):
		solve()
main()


for cases in range(int(input())):
	n = int(input())
	zero = 0
	one = 0
	tot = 0
	for i in range(n):
		s = input()
		zero += s.count('0')
		one += s.count('1')
		tot += len(s) // 2
	if zero // 2 + one // 2 >= tot:
		print(n)
	else:
		print(n - 1)


import bisect
import functools
import math
import sys
from collections import defaultdict
from itertools import groupby
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def main():
	t = ri()
	for _ in range(t):
		n = ri()
		tot_len = 0
		num_odd = 0
		ones = 0
		for i in range(n):
			s = input()
			tot_len += len(s)
			if len(s) % 2 == 1:
				num_odd += 1
			ones += s.count('1')
		if num_odd == 0 and ones % 2 == 1:
			print(n - 1)
		else:
			print(n)
main()


def solve(list_palavras):
	qtd0 = 0
	qtd1 = 0
	qtd_len_par = 0
	qtd_len_impar = 0
	for p in palavras:
		qtd0 += p.count('0')
		qtd1 += p.count('1')
		if len(p) % 2 == 0:
			qtd_len_par += 1
		else:
			qtd_len_impar += 1
	if qtd0 % 2 == qtd1 % 2 == 0:
		return len(list_palavras)
	elif qtd0 % 2 == qtd1 % 2 == 1:
		if qtd_len_impar >= 2:
			return len(list_palavras)
		else:
			return len(list_palavras) - 1
	else:
		return len(list_palavras)
q = int(input())
for _ in range(q):
	n = int(input())
	palavras = [input() for i in range(n)]
	print(solve(palavras))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	(eveneven, evenodd, odd) = [0] * 3
	strings = []
	for _ in range(n):
		strings.append(input())
		if len(strings[-1]) % 2 == 1:
			odd = odd + 1
		elif Counter(strings[-1])['1'] % 2 == 1:
			evenodd = evenodd + 1
		else:
			eveneven = eveneven + 1
	palindromes = n
	if evenodd & 1:
		if odd == 0:
			palindromes = n - 1
	print(palindromes)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	cnt = 0
	c_0 = 0
	c_1 = 0
	cnt = n
	ok = False
	for i in range(0, n):
		s = str(input())
		for j in range(0, len(s)):
			if s[j] == '0':
				c_0 += 1
			else:
				c_1 += 1
		if len(s) % 2 == 1:
			ok = True
	if not ok:
		if c_0 % 2 == 1 or c_1 % 2 == 1:
			cnt -= 1
	print(cnt)


for _ in range(int(input())):
	t = int(input())
	ss = ''
	f = 0
	for _ in range(t):
		s = input()
		if len(s) % 2 != 0:
			f = 1
		ss += s
	n = ss.count('1')
	m = ss.count('0')
	if f == 1:
		print(t)
	elif n % 2 == 0 and m % 2 == 0:
		print(t)
	else:
		print(t - 1)


for _ in range(int(input())):
	n = int(input())
	l = 0
	c0 = c1 = 0
	for i in range(n):
		s = input()
		l += len(s) // 2
		c0 += s.count('0')
		c1 += s.count('1')
	if c0 // 2 + c1 // 2 >= l:
		print(n)
	else:
		print(n - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	odds = 0
	cc = dict({'0': 0, '1': 0})
	for _i in range(n):
		a = list(input())
		if len(a) % 2 == 1:
			odds += 1
		for char in a:
			cc[char] += 1
	if odds >= 1:
		print(n)
	elif cc['1'] % 2 == 1:
		print(n - 1)
	else:
		print(n)


t = int(input())
for nt in range(t):
	n = int(input())
	l = []
	flag = False
	for i in range(n):
		s = input()
		if len(s) % 2 == 1:
			flag = True
		l.append(s)
	if flag:
		print(n)
	else:
		one = 0
		zero = 0
		for i in l:
			for j in i:
				if j == '0':
					zero += 1
				else:
					one += 1
		if zero % 2 == 1 or one % 2 == 1:
			print(n - 1)
		else:
			print(n)


for _ in range(int(input())):
	n = int(input())
	l = []
	o = z = 0
	for i in range(n):
		s = input()
		l.append(len(s))
		for j in s:
			if j == '1':
				o += 1
			else:
				z += 1
	l.sort()
	p = o // 2 + z // 2
	s = o % 2 + z % 2
	ans = 0
	for i in l:
		if i == 1:
			if s > 0:
				s -= 1
				ans += 1
			else:
				p -= 1
				s = 1
				ans += 1
		elif i % 2 == 0:
			if p * 2 >= i:
				p -= i // 2
				ans += 1
			else:
				break
		elif s > 0:
			s -= 1
			p -= i // 2
			ans += 1
		else:
			p -= 1
			s = 1
			p -= i // 2
			ans += 1
	print(ans)


def sv():
	N = int(input())
	tot0 = 0
	allEven = True
	for n in range(N):
		s = input()
		if len(s) % 2:
			allEven = False
		tot0 += sum((1 for c in s if c == '0'))
	print(N - 1 if allEven and tot0 % 2 else N)
TC = int(input())
for tc in range(TC):
	sv()


t = int(input())
for _ in range(t):
	n = int(input())
	be = 0
	bo = 0
	a1 = 0
	for i in range(n):
		s = input()
		no = s.count('0')
		n1 = s.count('1')
		if no % 2 == 0 and n1 % 2 == 0:
			be += 1
		elif no % 2 != 0 and n1 % 2 != 0:
			bo += 1
		else:
			a1 += 1
	if bo % 2 == 0:
		ans = be + a1 + bo
	elif a1 > 0:
		ans = be + a1 + bo
	else:
		ans = be + a1 + bo - 1
	print(ans)


import math
for _ in range(int(input())):
	n = int(input())
	c = 0
	se = 0
	ec = 0
	for i in range(n):
		s = list(input())
		if len(s) % 2 == 1:
			c += 1
		elif s.count('0') % 2 == 1:
			se += 1
		else:
			ec += 1
	if se % 2 == 1:
		if c > 0:
			print(n)
		else:
			print(ec + 2 * (se // 2))
	else:
		print(c + ec + 2 * (se // 2))


for _ in range(int(input())):
	n = int(input())
	od = 0
	ev = 0
	ans = 0
	for i in range(n):
		a = input()
		ans += 1
		if len(a) % 2 == 0 and a.count('0') % 2 != 0:
			ev += 1
		elif len(a) % 2 != 0:
			od += 1
	print(ans - 1) if ev % 2 != 0 and od == 0 else print(ans)


q = int(input())
for i in range(q):
	inp = list()
	n = int(input())
	for j in range(n):
		xx = input()
		inp.append(xx)
	nz = 0
	no = 0
	todd = 0
	teven = 0
	for j in range(len(inp)):
		if len(inp[j]) % 2 == 0:
			teven += 1
		else:
			todd += 1
		for k in range(len(inp[j])):
			if inp[j][k] == '0':
				nz += 1
			else:
				no += 1
	ans = 0
	if nz % 2 == 0 and no % 2 == 0:
		ans = n
	elif nz % 2 == 1 and no % 2 != 1:
		ans = n
	elif no % 2 == 1 and nz % 2 != 1:
		ans = n
	elif todd >= 2:
		ans = n
	else:
		ans = n - 1
	print(ans)


def I():
	return list(map(int, input().split()))
for t1 in range(int(input())):
	s = []
	badStrings = 0
	oddStrings = 0
	n = int(input())
	for t2 in range(n):
		s.append(input())
		if len(s[t2]) % 2 == 0:
			z = s[t2].count('0')
			o = s[t2].count('1')
			if o % 2 != 0 and z % 2 != 0:
				badStrings += 1
		else:
			oddStrings += 1
	if badStrings % 2 != 0 and (not oddStrings):
		print(n - 1)
	else:
		print(n)


for i in range(int(input())):
	alleven = True
	minus = False
	m = int(input())
	strings = []
	for j in range(m):
		strings.append(input())
	for current in strings:
		if len(current) % 2:
			alleven = False
			print(m)
			break
		elif current.count('0') % 2:
			minus = not minus
	if alleven:
		print(m - minus)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * n
	for i in range(n):
		a[i] = input()
		a[i] = list(a[i])
	count = 0
	count_e1 = 0
	count_e2 = 0
	count_odd = 0
	for j in range(len(a)):
		if len(a[j]) % 2 == 1:
			count += 1
			count_odd += 1
		elif a[j].count('0') % 2 == 0:
			count += 1
			count_e1 += 1
		else:
			count_e2 += 1
	if count_e2 % 2 == 0:
		count += count_e2
	elif count_odd >= 1:
		count += count_e2
	else:
		count += count_e2 - 1
	print(count)


from sys import stdin
for _ in range(int(input())):
	n = int(stdin.readline().rstrip())
	se = so = 0
	ones = 0
	smallest_odd = 999999999
	for i in range(n):
		s = stdin.readline().rstrip()
		z = s.count('1')
		ones += z
		x = len(s)
		if x % 2:
			smallest_odd = min(smallest_odd, x)
			so += x
		else:
			se += x
	if so == 0:
		if ones % 2:
			print(n - 1)
		else:
			print(n)
	else:
		print(n)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list((input() for i in range(n)))
	(EE, EO, OE, OO) = (0, 0, 0, 0)
	c = list(((i.count('0'), i.count('1')) for i in s))
	for i in c:
		if i[0] % 2 == 0 and i[1] % 2 == 0:
			EE += 1
		if i[0] % 2 == 0 and i[1] % 2 == 1:
			EO += 1
		if i[0] % 2 == 1 and i[1] % 2 == 0:
			OE += 1
		if i[0] % 2 == 1 and i[1] % 2 == 1:
			OO += 1
	if EO + OE > 0:
		print(n)
	else:
		print(EE + OO // 2 * 2)


from collections import Counter
q = int(input())
for __ in range(q):
	n = int(input())
	c = Counter({'1': 0, '0': 0})
	contain_odd_length = False
	for i in range(n):
		s = input()
		c += Counter(s)
		contain_odd_length |= bool(len(s) % 2)
	if contain_odd_length:
		print(n)
	elif bool(c['0'] % 2):
		print(n - 1)
	else:
		print(n)


import sys
input = sys.stdin.readline

def main():
	Q = int(input())
	for _ in range(Q):
		N = int(input())
		ans = 0
		odd = 0
		for n in range(N):
			S = input().strip()
			if len(S) % 2 == 0:
				if S.count('1') % 2 == 1:
					odd += 1
			else:
				ans = -1
		if ans == -1:
			print(N)
			continue
		elif odd % 2 == 1:
			print(N - 1)
		else:
			print(N)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	s = []
	for i in range(n):
		s.append(input())
	ans = 0
	eo = 0
	c = 0
	for i in range(n):
		if len(s[i]) % 2 == 1:
			c = c + 1
			ans = ans + 1
		else:
			o = 0
			z = 0
			for j in range(len(s[i])):
				if s[i][j] == '1':
					o = o + 1
				else:
					z = z + 1
			if o % 2 == 1:
				eo = eo + 1
			else:
				ans = ans + 1
	ans = ans + 2 * (eo // 2)
	if eo - 2 * (eo // 2) <= c:
		ans = ans + eo - 2 * (eo // 2)
	print(ans)


import sys
readline = sys.stdin.readline
read = sys.stdin.read
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	n = ni()
	l = [ns() for _ in range(n)]
	t = sum((len(x) % 2 for x in l))
	c = sum((len(x) for x in l)) & 1
	o = sum((x.count('1') for x in l)) & 1
	w = o ^ c
	if t < 1 and o | w or t & 1 ^ c:
		n -= 1
	print(n)
	return
T = ni()
for _ in range(T):
	solve()


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
q = rint()
for _ in range(q):
	n = rint()
	s = [input() for _ in range(n)]
	c = [0] * 2
	for si in s:
		for ch in si:
			c[int(ch)] += 1
	o = c[0] % 2 == 1 or c[1] % 2 == 1
	if not o or any((len(si) % 2 == 1 for si in s)):
		print(n)
	else:
		print(n - 1)


import copy
t = int(input())
for i in range(t):
	d = {0: 0, 1: 0}
	n = int(input())
	arr = []
	for j in range(n):
		s = input()
		for x in s:
			if x == '1':
				d[1] += 1
			else:
				d[0] += 1
		arr += [len(s)]
	eve = []
	odd = []
	for x in arr:
		if x % 2 == 0:
			eve += [x]
		else:
			odd += [x]
	eve.sort()
	odd.sort()
	ansarr = []
	ori = copy.deepcopy(d)
	arr.sort()
	count = 0
	for x in arr:
		num = 0
		if x % 2 == 0:
			while num != x:
				if d[0] <= 1 and d[1] <= 1:
					break
				if d[1] >= d[0] and d[1] > 1:
					num += 2
					d[1] -= 2
				elif d[0] > d[1] and d[0] > 1:
					num += 2
					d[0] -= 2
			if num == x:
				count += 1
		else:
			if d[0] % 2 == 1:
				d[0] -= 1
				num += 1
			elif d[1] % 2 == 1:
				d[1] -= 1
				num += 1
			if num == 1:
				while num != x:
					if d[0] <= 1 and d[1] <= 1:
						break
					if d[1] >= d[0] and d[1] > 1:
						num += 2
						d[1] -= 2
					elif d[0] > d[1] and d[0] > 1:
						num += 2
						d[0] -= 2
				if num == x:
					count += 1
			else:
				if d[0] != 0:
					d[0] -= 1
					num += 1
				elif d[1] != 0:
					d[1] -= 1
					num += 1
				while num != x:
					if d[0] <= 1 and d[1] <= 1:
						break
					if d[1] >= d[0] and d[1] > 1:
						num += 2
						d[1] -= 2
					elif d[0] > d[1] and d[0] > 1:
						num += 2
						d[0] -= 2
				if num == x:
					count += 1
	print(count)


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = list()
	for i in range(n):
		s = list(input())
		l.append((s.count('1'), s.count('0')))
	(f, e, c) = (0, 0, 0)
	for i in range(n):
		f += l[i][0]
		e += l[i][1]
		if (l[i][0] + l[i][1]) % 2 == 0:
			c += 1
	if f % 2 == 1 and e % 2 == 1 and (c == n):
		print(n - 1)
	else:
		print(n)


Q = int(input())
for _ in range(Q):
	n = int(input())
	(zero, one) = (0, 0)
	odd = 0
	for _ in range(n):
		s = input()
		if len(s) % 2:
			odd = 1
		zero += s.count('0')
		one += s.count('1')
	if odd or zero % 2 == 0:
		print(n)
	else:
		print(n - 1)


import os
import sys
from io import BytesIO, IOBase

def solution(n, binary):
	balance = 0
	repair = []
	for i in range(n):
		if len(binary[i]) & 1:
			balance += 1
		else:
			(one, zero) = (binary[i].count('1'), binary[i].count('0'))
			if not (one % 2 == 0 and zero % 2 == 0):
				repair.append(binary[i])
	if len(repair) % 2 == 0:
		write(n)
	elif balance > 0:
		write(n)
	else:
		write(n - 1)

def main():
	for _ in range(r_int()):
		n = r_int()
		binary = []
		for _ in range(n):
			binary.append(input())
		solution(n, binary)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


t = int(input())
while t > 0:
	n = int(input())
	(o, be, ge) = (0, 0, 0)
	for i in range(n):
		s = input()
		cnt = 0
		if len(s) % 2 == 1:
			o += 1
		elif len(s) % 2 == 0:
			for j in s:
				if j == '0':
					cnt += 1
			if cnt % 2 == 0:
				ge += 1
			else:
				be += 1
	if o == 0 and be % 2 == 1:
		print(n - 1)
	else:
		print(n)
	t -= 1