It's autumn now, the time of the leaf fall.
Sergey likes to collect fallen leaves in autumn. In his city, he can find fallen leaves of maple, oak and poplar. These leaves can be of three different colors: green, yellow or red.
Sergey has collected some leaves of each type and color. Now he wants to create the biggest nice bouquet from them. He considers the bouquet nice iff all the leaves in it are either from the same type of tree or of the same color (or both). Moreover, he doesn't want to create a bouquet with even number of leaves in it, since this kind of bouquets are considered to attract bad luck. However, if it's impossible to make any nice bouquet, he won't do anything, thus, obtaining a bouquet with zero leaves.
Please help Sergey to find the maximal number of leaves he can have in a nice bouquet, which satisfies all the above mentioned requirements.
Please note that Sergey doesn't have to use all the leaves of the same color or of the same type. For example, if he has 20 maple leaves, he can still create a bouquet of 19 leaves.

-----Input-----
IThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows."
The first line of each test case contains three space-separated integers MG MY MR denoting the number of green, yellow and red maple leaves respectively.
The second line contains three space-separated integers OG OY OR denoting the number of green, yellow and red oak leaves respectively.
The third line of each test case contains three space-separated integers PG PY PR denoting the number of green, yellow and red poplar leaves respectively.

-----Output-----
For each test case, output a single line containing the maximal amount of flowers in nice bouquet, satisfying all conditions or 0 if it's impossible to create any bouquet, satisfying the conditions.

-----Constraints-----

- 1 ≤ T ≤ 10000
- Subtask 1 (50 points): 0 ≤ MG, MY, MR, OG, OY, OR, PG, PY, PR ≤ 5
- Subtask 2 (50 points): 0 ≤ MG, MY, MR, OG, OY, OR, PG, PY, PR ≤ 109

-----Example-----
Input:1
1 2 3
3 2 1
1 3 4

Output:7

-----Explanation-----
Example case 1. We can create a bouquet with 7 leaves, for example, by collecting all yellow leaves. This is not the only way to create the nice bouquet with 7 leaves (for example, Sergey can use all but one red leaves), but it is impossible to create a nice bouquet with more than 7 leaves.

Source: codechef | Difficulty: MEDIUM


Solutions:
for _ in range(int(input())):
	(Mg, My, Mr) = map(int, input().split(' '))
	(Og, Oy, Or) = map(int, input().split(' '))
	(Pg, Py, Pr) = map(int, input().split(' '))
	(M, O, P) = (Mg + My + Mr, Og + Oy + Or, Pg + Py + Pr)
	(g, y, r) = (Mg + Og + Pg, My + Oy + Py, Mr + Or + Pr)
	l = [M, O, P, g, y, r]
	for i in range(6):
		if l[i] % 2 == 0:
			l[i] -= 1
	l.append(0)
	print(max(l))


t = int(input())
while t > 0:
	(x1, x2, x3) = map(int, input().split(' '))
	(y1, y2, y3) = map(int, input().split(' '))
	(z1, z2, z3) = map(int, input().split(' '))
	list = []
	x = x1 + x2 + x3
	list.append(x)
	y = y1 + y2 + y3
	list.append(y)
	z = z1 + z2 + z3
	list.append(z)
	one = x1 + y1 + z1
	list.append(one)
	two = x2 + y2 + z2
	list.append(two)
	three = x3 + y3 + z3
	list.append(three)
	i = 0
	m = max(list)
	if m % 2 == 0:
		if m == 0:
			print(0)
		else:
			print(m - 1)
	else:
		print(m)
	t -= 1


for _ in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ma = 0
	if sum(m) > ma:
		ma = sum(m)
	if sum(o) > ma:
		ma = sum(o)
	if sum(p) > ma:
		ma = sum(p)
	for i in range(3):
		k = m[i] + o[i] + p[i]
		if k > ma:
			ma = k
	print(ma if ma % 2 else ma - 1 if ma > 0 else 0)


for _ in range(int(input())):
	(mg, my, mr) = map(int, input().split())
	(og, oy, o_r) = map(int, input().split())
	(pg, py, pr) = map(int, input().split())
	leaves = (mg + my + mr, og + oy + o_r, pg + py + pr, mg + og + pg, my + oy + py, mr + pr + o_r)
	leaves = max(leaves)
	if not leaves:
		print(0)
	elif leaves & 1:
		print(leaves)
	else:
		print(leaves - 1)


for _ in range(int(input())):
	(a1, a2, a3) = map(int, input().split())
	(b1, b2, b3) = map(int, input().split())
	(c1, c2, c3) = map(int, input().split())
	r = max(a1 + a2 + a3, b1 + b2 + b3, c1 + c2 + c3, a1 + b1 + c1, a2 + b2 + c2, a3 + b3 + c3)
	if r % 2 == 0:
		if r == 0:
			print(0)
		else:
			print(r - 1)
	else:
		print(r)


for _ in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	pos_ans = [sum(m), sum(p), sum(o), m[0] + p[0] + o[0], m[1] + p[1] + o[1], m[2] + p[2] + o[2]]
	for i in range(6):
		if pos_ans[i] % 2 == 0:
			pos_ans[i] -= 1
	pos_ans.append(0)
	print(max(pos_ans))


t = int(input())
for _ in range(t):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	lis = []
	g = m[0] + o[0] + p[0]
	y = m[1] + o[1] + p[1]
	r = m[2] + o[2] + p[2]
	lis.append(sum(m))
	lis.append(sum(o))
	lis.append(sum(p))
	lis.append(g)
	lis.append(y)
	lis.append(r)
	if max(lis) == 0:
		print(0)
	elif max(lis) % 2 == 0:
		print(max(lis) - 1)
	elif max(lis) % 2 != 0:
		print(max(lis))


for i in range(int(input())):
	f = []
	o = []
	for i in range(3):
		a = list(map(int, input().split()))
		f.append(a)
		o.append(sum(a))
	for i in range(len(f)):
		b = f[0][i] + f[1][i] + f[2][i]
		o.append(b)
	r = max(o)
	if r % 2 == 0 and r > 0:
		print(r - 1)
	else:
		print(r)


n = int(input())
while n:
	(a, b, c) = map(int, input().split())
	(i, j, k) = map(int, input().split())
	(x, y, z) = map(int, input().split())
	l = []
	l.append(a + b + c)
	l.append(i + j + k)
	l.append(x + y + z)
	l.append(a + i + x)
	l.append(b + j + y)
	l.append(c + k + z)
	for q in range(len(l)):
		if l[q] % 2 == 0:
			l[q] = l[q] - 1
	l.append(0)
	print(max(l))
	n = n - 1


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	(d, e, f) = map(int, input().split())
	(g, h, i) = map(int, input().split())
	ans = 0
	for i in [sum([a, b, c]), sum([d, e, f]), sum([g, h, i]), sum([a, d, g]), sum([b, e, h]), sum([c, f, i])]:
		if i % 2 == 0:
			i -= 1
		ans = max(ans, i)
	print(ans)


get_int = lambda : int(input())
get_mint = lambda : list(map(int, input().split()))
for _ in range(get_int()):
	maple = get_mint()
	oak = get_mint()
	poplar = get_mint()
	leaves_from_same_tree = max([sum(maple), sum(oak), sum(poplar)])
	color_leaves = max([maple[i] + oak[i] + poplar[i] for i in range(3)])
	bouquet = max(leaves_from_same_tree, color_leaves)
	if bouquet == 0:
		print(0)
		continue
	if not bouquet % 2:
		bouquet -= 1
	print(bouquet)


for _ in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ms = m[0] + m[1] + m[2]
	os = o[0] + o[1] + o[2]
	ps = p[0] + p[1] + p[2]
	g = m[0] + o[0] + p[0]
	y = m[1] + p[1] + o[1]
	r = m[2] + p[2] + o[2]
	mx = max(ms, os, ps, g, y, r)
	print(max(mx - 1, 0) if mx % 2 == 0 else mx)


t = int(input())
while t != 0:
	(mg, my, mr) = map(int, input().split())
	(og, oy, orr) = map(int, input().split())
	(pg, py, pr) = map(int, input().split())
	bouquets = []
	bouquets.append(mg + my + mr)
	bouquets.append(og + oy + orr)
	bouquets.append(pg + py + pr)
	bouquets.append(mg + og + pg)
	bouquets.append(my + oy + py)
	bouquets.append(mr + orr + pr)
	j = 0
	while j < len(bouquets):
		if bouquets[j] % 2 == 0:
			bouquets[j] -= 1
		j += 1
	bouquets.append(0)
	print(max(bouquets))
	t -= 1


for _ in range(int(input())):
	li = []
	for _ in range(3):
		li.append(list(map(int, input().split())))
	(a, b, c) = (0, 0, 0)
	for i in li:
		a += i[0]
		b += i[1]
		c += i[2]
	ans = max(sum(li[0]), sum(li[1]), sum(li[2]), a, b, c)
	if ans < 1:
		print(0)
	else:
		if ans % 2 == 0:
			ans -= 1
		print(ans)


t = int(input())
for i in range(t):
	M = list(map(int, input().split()))
	O = list(map(int, input().split()))
	P = list(map(int, input().split()))
	s = 3
	mx = max(sum(M), sum(O), sum(P))
	for i in range(s):
		a = M[i] + O[i] + P[i]
		mx = max(mx, a)
	if mx % 2 == 0 and mx != 0:
		mx -= 1
	print(mx)


for t in range(int(input())):
	(mg, my, mr) = map(int, input().split())
	(og, oy, oR) = map(int, input().split())
	(pg, py, pr) = map(int, input().split())
	m = mg + my + mr
	o = og + oy + oR
	p = pg + py + pr
	g = mg + og + pg
	y = my + oy + py
	r = mr + oR + pr
	a = [m, o, p, g, y, r]
	if a == [0] * 6:
		print(0)
	elif max(a) % 2 == 0:
		print(max(a) - 1)
	else:
		print(max(a))


for _ in range(int(input())):
	(Mg, My, Mr) = map(int, input().split())
	(Og, Oy, Or) = map(int, input().split())
	(Pg, Py, Pr) = map(int, input().split())
	color1 = Mg + Og + Pg
	color2 = My + Oy + Py
	color3 = Mr + Or + Pr
	leaf1 = Mg + My + Mr
	leaf2 = Og + Oy + Or
	leaf3 = Pg + Py + Pr
	lst = []
	lst.extend((color3, color2, color1, leaf3, leaf2, leaf1))
	res = max(lst)
	if res % 2 != 0 or res == 0:
		print(res)
	else:
		print(res - 1)


t = int(input())
while t:
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	s = [sum(m), sum(o), sum(p), m[0] + o[0] + p[0], m[1] + o[1] + p[1], m[2] + o[2] + p[2]]
	print(max(s)) if max(s) % 2 != 0 else print(max(max(s) - 1, 0))
	t -= 1


t = int(input())
for i in range(t):
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a3 = list(map(int, input().split()))
	m = max(sum(a1), sum(a2), sum(a3))
	for j in range(3):
		m = max(m, a1[j] + a2[j] + a3[j])
	if m % 2 == 0 and m != 0:
		m -= 1
	print(m)


t = int(input())
while t:
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	tmax = max((sum(m), sum(o), sum(p)))
	cmax = max(m[0] + o[0] + p[0], m[1] + o[1] + p[1], m[2] + o[2] + p[2])
	ans = max(tmax, cmax)
	print(max(ans - (ans % 2 == 0), 0))
	t = t - 1


for _ in range(int(input())):
	l = []
	(mg, my, mr) = map(int, input().split(' '))
	(og, oy, ort) = map(int, input().split(' '))
	(pg, py, pr) = map(int, input().split(' '))
	l.append([mg, my, mr])
	l.append([og, oy, ort])
	l.append([pg, py, pr])
	t = []
	for i in range(3):
		s = 0
		for j in range(3):
			s = s + l[i][j]
		t.append(s)
	for i in range(3):
		s = 0
		for j in range(3):
			s = s + l[j][i]
		t.append(s)
	if max(t) == 0:
		print(0)
	elif max(t) % 2 == 0:
		print(max(t) - 1)
	else:
		print(max(t))


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ab = []
	ab.append(sum(a))
	ab.append(sum(b))
	ab.append(sum(c))
	ab.append(a[0] + b[0] + c[0])
	ab.append(a[1] + b[1] + c[1])
	ab.append(a[2] + b[2] + c[2])
	Max = max(ab)
	if Max % 2 != 0 or Max == 0:
		print(Max)
	else:
		print(Max - 1)


for _ in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	tm = sum(m[:3])
	to = sum(o[:3])
	tp = sum(p[:3])
	g = m[0] + o[0] + p[0]
	y = m[1] + o[1] + p[1]
	r = m[2] + o[2] + p[2]
	maxi = max(tm, to, tp, g, y, r)
	if maxi % 2 == 0:
		print(max(maxi - 1, 0))
	else:
		print(maxi)


for _ in range(int(input())):
	(mg, my, mr) = map(int, input().split(' '))
	(oog, ooy, oor) = map(int, input().split(' '))
	(pg, py, pr) = map(int, input().split(' '))
	var = [mg + my + mr, oog + ooy + oor, pg + py + pr, mg + oog + pg, my + ooy + py, mr + oor + pr]
	for i in range(len(var)):
		if var[i] % 2 == 0:
			var[i] -= 1
	var.append(0)
	print(max(var))


for _ in range(int(input())):
	(Mg, My, Mr) = list(map(int, input().split()))
	(Og, Oy, Or) = list(map(int, input().split()))
	(Pg, Py, Pr) = list(map(int, input().split()))
	x = max(Mg + My + Mr, Og + Oy + Or, Pg + Py + Pr, Mg + Og + Pg, My + Oy + Py, Mr + Or + Pr)
	if x % 2 == 0:
		if x == 0:
			print(0)
		else:
			print(x - 1)
	else:
		print(x)


def main():
	for _ in range(int(input())):
		(MG, MY, MR) = map(int, input().split())
		(OG, OY, OR) = map(int, input().split())
		(PG, PY, PR) = map(int, input().split())
		l = max([MG + MY + MR, OG + OY + OR, PG + PY + PR, MG + OG + PG, MY + OY + PY, MR + OR + PR])
		if l & 1:
			print(l)
		elif l == 0:
			print(0)
		else:
			print(l - 1)
main()


from math import sqrt, ceil, floor, gcd, log2
import sys
from sys import stdin, stdout
from collections import Counter, defaultdict, OrderedDict, deque
from itertools import combinations, groupby
from time import time
from heapq import heappop, heappush, heapify
t = int(input())
for _ in range(t):
	(g, y, r) = (0, 0, 0)
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	g = m[0] + o[0] + p[0]
	y = m[1] + o[1] + p[1]
	r = m[2] + o[2] + p[2]
	tm = sum(m)
	to = sum(o)
	tp = sum(p)
	if not g % 2:
		g -= 1
	if not y % 2:
		y -= 1
	if not r % 2:
		r -= 1
	if not tm % 2:
		tm -= 1
	if not to % 2:
		to -= 1
	if not tp % 2:
		tp -= 1
	ans = [g, r, y, tm, to, tp]
	if max(ans) >= 0:
		print(max(ans))
	else:
		print(0)


for _ in range(int(input())):
	maple = list(map(int, input().split()))
	oak = list(map(int, input().split()))
	poplar = list(map(int, input().split()))
	possible = []
	possible.append(sum(maple))
	possible.append(sum(oak))
	possible.append(sum(poplar))
	for num in range(0, 3):
		possible.append(maple[num] + oak[num] + poplar[num])
	thing = max(possible)
	if thing % 2 != 0 or thing == 0:
		print(thing)
	else:
		print(thing - 1)


t = int(input())
for _ in range(t):
	list_final = []
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	list_final.append(sum(m))
	list_final.append(sum(o))
	list_final.append(sum(p))
	list_final.append(m[0] + o[0] + p[0])
	list_final.append(m[1] + o[1] + p[1])
	list_final.append(m[2] + o[2] + p[2])
	temp = max(list_final)
	if temp % 2 == 0 and temp != 0:
		print(temp - 1)
	else:
		print(temp)


for _ in range(int(input())):
	(mg, my, mr) = map(int, input().split())
	(og, oy, Or) = map(int, input().split())
	(pg, py, pr) = map(int, input().split())
	(ag, ay, ar) = (mg + og + pg, my + oy + py, mr + Or + pr)
	(am, ao, ap) = (mg + my + mr, og + oy + Or, pg + py + pr)
	(max1, max2) = (max(ag, ay, ar), max(am, ao, ap))
	maxi = max(max1, max2)
	if maxi % 2 != 0:
		print(maxi)
	elif maxi != 0:
		print(maxi - 1)
	else:
		print(0)


for _ in range(int(input())):
	(Mg, My, Mr) = map(int, input().split())
	(Og, Oy, Or) = map(int, input().split())
	(Pg, Py, Pr) = map(int, input().split())
	odd = 0
	even = 0
	if (Mg + My + Mr) % 2 != 0:
		if Mg + My + Mr > odd:
			odd = Mg + My + Mr
	elif Mg + My + Mr > even:
		even = Mg + My + Mr
	if (Og + Oy + Or) % 2 != 0:
		if Og + Oy + Or > odd:
			odd = Og + Oy + Or
	elif Og + Oy + Or > even:
		even = Og + Oy + Or
	if (Pg + Py + Pr) % 2 != 0:
		if Pg + Py + Pr > odd:
			odd = Pg + Py + Pr
	elif Pg + Py + Pr > even:
		even = Pg + Py + Pr
	if (Mg + Og + Pg) % 2 != 0:
		if Mg + Og + Pg > odd:
			odd = Mg + Og + Pg
	elif Mg + Og + Pg > even:
		even = Mg + Og + Pg
	if (My + Oy + Py) % 2 != 0:
		if My + Oy + Py > odd:
			odd = My + Oy + Py
	elif My + Oy + Py > even:
		even = My + Oy + Py
	if (Mr + Or + Pr) % 2 != 0:
		if Mr + Or + Pr > odd:
			odd = Mr + Or + Pr
	elif Mr + Or + Pr > even:
		even = Mr + Or + Pr
	if even - 1 >= odd:
		print(even - 1)
	elif odd >= even - 1:
		print(odd)
	else:
		print(0)


for _ in range(int(input())):
	l = []
	for i in range(3):
		l.append(list(map(int, input().split())))
	G = Y = R = 0
	for i in l:
		G += i[0]
		Y += i[1]
		R += i[2]
	sol = max(sum(l[0]), sum(l[1]), sum(l[2]), G, Y, R)
	if sol != 0 and sol % 2 == 0:
		print(sol - 1)
	else:
		print(sol)


t = int(input())
for _ in range(t):
	x = []
	y1 = []
	y2 = []
	y3 = []
	for i in range(3):
		ax = list(map(int, input().split()))
		(a1, a2, a3) = ax
		x.append(sum(ax))
		y1.append(a1)
		y2.append(a2)
		y3.append(a3)
	x.append(sum(y1))
	x.append(sum(y2))
	x.append(sum(y3))
	mx = max(x)
	if mx % 2 == 0 and mx != 0:
		print(mx - 1)
	else:
		print(mx)


for _ in range(int(input())):
	M = list(map(int, input().split()))
	O = list(map(int, input().split()))
	P = list(map(int, input().split()))
	m = 0
	for i in range(3):
		t = M[i] + O[i] + P[i]
		m = max(m, t)
	f = max(sum(M), sum(O), sum(P), m)
	if f % 2 == 0 and f != 0:
		f -= 1
	print(f)


for i in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	l = []
	l.append(0)
	l.append(sum(m))
	l.append(sum(o))
	l.append(sum(p))
	s1 = m[0] + o[0] + p[0]
	l.append(s1)
	s2 = m[1] + o[1] + p[1]
	l.append(s2)
	s3 = m[2] + o[2] + p[2]
	l.append(s3)
	for j in range(len(m)):
		l.append(m[j])
	for j in range(len(o)):
		l.append(o[j])
	for j in range(len(p)):
		l.append(p[j])
	r = max(l)
	if r == 0:
		print(0)
	elif r % 2 == 0:
		print(r - 1)
	else:
		print(r)


from sys import stdin, stdout
stdint = lambda : int(stdin.readline())
mul = lambda : map(int, stdin.readline().strip().split())
for _ in range(stdint()):
	(m_g, m_y, m_r) = mul()
	(o_g, o_y, o_r) = mul()
	(p_g, p_y, p_r) = mul()
	maxVal = max(m_g + m_y + m_r, o_g + o_y + o_r, p_g + p_y + p_r)
	maxVal = max(maxVal, m_g + o_g + p_g, m_y + o_y + p_y, m_r + o_r + p_r)
	if maxVal and maxVal % 2 == 0:
		maxVal -= 1
	print(maxVal)


for _ in range(int(input())):
	a = []
	b = [0, 0, 0]
	maxcol = 0
	maxrow = 0
	maxcol1 = 0
	maxrow1 = 0
	for i in range(3):
		b = [0, 0, 0]
		b = list(map(int, input().split()))
		maxrow = sum(b)
		if maxrow % 2 == 0:
			maxrow = maxrow - 1
		maxrow1 = max(maxrow1, maxrow)
		a.append(b)
	for k in range(3):
		maxcol = 0
		for l in range(3):
			maxcol += a[l][k]
		if maxcol % 2 == 0:
			maxcol = maxcol - 1
		maxcol1 = max(maxcol1, maxcol)
	print(max(maxcol1, maxrow1))


for i in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = max(sum(a), sum(b), sum(c), a[0] + b[0] + c[0], a[1] + b[1] + c[1], a[2] + b[2] + c[2])
	if l % 2 == 0:
		if l == 0:
			print('0')
		else:
			print(l - 1)
	else:
		print(l)


t = int(input())
for i in range(t):
	M = [int(x) for x in input().split()]
	O = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	A = []
	count = 0
	for j in range(3):
		count += M[j]
	A.append(count)
	count = 0
	for j in range(3):
		count += O[j]
	A.append(count)
	count = 0
	for j in range(3):
		count += P[j]
	A.append(count)
	count = 0
	A.append(M[0] + O[0] + P[0])
	A.append(M[1] + O[1] + P[1])
	A.append(M[2] + O[2] + P[2])
	if max(A) % 2 == 0 and max(A) != 0:
		print(max(A) - 1)
	elif max(A) == 0:
		print(0)
	else:
		print(max(A))


for _ in range(int(input())):
	leaf_arr = []
	m = 0
	for i in range(3):
		a = [int(j) for j in input().split()]
		leaf_arr.append(a)
		b = sum(a)
		if b % 2:
			m = max(m, b)
		else:
			m = max(m, b - 1)
	for i in range(3):
		s = 0
		for j in range(3):
			s += leaf_arr[j][i]
		if s % 2:
			m = max(s, m)
		else:
			m = max(s - 1, m)
	print(m)


for _ in range(int(input())):
	M = list(map(int, input().split()))
	O = list(map(int, input().split()))
	P = list(map(int, input().split()))
	max_color = 0
	for i in range(3):
		temp = M[i] + O[i] + P[i]
		max_color = max(max_color, temp)
	maximal_flowers = max(sum(M), sum(O), sum(P), max_color)
	if maximal_flowers % 2 == 0 and maximal_flowers != 0:
		maximal_flowers -= 1
	print(maximal_flowers)


t = int(input())
for i in range(t):
	(mg, my, mr) = map(int, input().split())
	(Og, Oy, Or) = map(int, input().split())
	(pg, py, pr) = map(int, input().split())
	a = []
	x1 = mg + my + mr
	y1 = Og + Oy + Or
	z1 = pg + py + pr
	x2 = mg + Og + pg
	y2 = my + Oy + py
	z2 = mr + Or + pr
	a.extend((x1, y1, z1, x2, y2, z2))
	b = max(a)
	if b % 2 != 0 or b == 0:
		print(b)
	else:
		print(b - 1)


for i in range(int(input())):
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	n = max(l1[0] + l2[0] + l3[0], l1[1] + l2[1] + l3[1], l1[2] + l2[2] + l3[2], sum(l1), sum(l2), sum(l3))
	if n == 0:
		print(0)
	elif n % 2 == 0:
		print(n - 1)
	else:
		print(n)


for _ in range(int(input())):
	(a, b, c) = list(map(int, input().split()))
	(p, q, r) = list(map(int, input().split()))
	(x, y, z) = list(map(int, input().split()))
	ans = max(a + b + c, p + q + r, x + y + z, a + p + x, b + q + y, c + r + z)
	if ans == 0:
		print(0)
	elif ans % 2 == 0:
		print(ans - 1)
	else:
		print(ans)


tests = int(input())
for i in range(tests):
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = list(map(int, input().split()))
	maximum = max(sum(arr1), sum(arr2), sum(arr3))
	for j in range(3):
		maximum = max(maximum, arr1[j] + arr2[j] + arr3[j])
	if maximum % 2 == 0 and maximum != 0:
		maximum -= 1
	print(maximum)


t = int(input())
for _ in range(t):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	l = max(sum(m), sum(o), sum(p), m[0] + o[0] + p[0], m[1] + o[1] + p[1], m[2] + o[2] + p[2])
	if l == 0:
		print(0)
	elif l % 2 == 0:
		print(l - 1)
	else:
		print(l)


t = int(input())
for i in range(t):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	res = [sum(m), sum(o), sum(p)]
	for i in range(3):
		res.append(m[i] + o[i] + p[i])
	ans = max(res)
	if ans % 2 == 0 and ans != 0:
		print(ans - 1)
	else:
		print(ans)


for _ in range(int(input())):
	i = list(map(int, input().split()))
	j = list(map(int, input().split()))
	k = list(map(int, input().split()))
	max1 = max(sum(i), sum(j), sum(k))
	sum1 = i[0] + j[0] + k[0]
	sum2 = i[1] + j[1] + k[1]
	sum3 = i[2] + j[2] + k[2]
	max2 = max(sum1, sum2, sum3)
	final_max = max(max1, max2)
	if final_max % 2 == 0:
		if final_max != 0:
			print(final_max - 1)
		else:
			print(0)
	else:
		print(final_max)


for _ in range(int(input())):
	(m1, m2, m3) = map(int, input().split())
	(o1, o2, o3) = map(int, input().split())
	(p1, p2, p3) = map(int, input().split())
	maxm = 0
	maxm = max(maxm, m1 + m2 + m3)
	maxm = max(maxm, o1 + o2 + o3)
	maxm = max(maxm, p1 + p2 + p3)
	maxm = max(maxm, m1 + o1 + p1)
	maxm = max(maxm, m2 + o2 + p2)
	maxm = max(maxm, m3 + o3 + p3)
	if maxm % 2 == 1:
		print(maxm)
	elif maxm == 0:
		print(0)
	else:
		print(maxm - 1)


t = int(input())
for i in range(t):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	l = []
	l.append(sum(m))
	l.append(sum(o))
	l.append(sum(p))
	l.append(m[0] + o[0] + p[0])
	l.append(m[1] + o[1] + p[1])
	l.append(m[2] + o[2] + p[2])
	a = max(l)
	if a == 0:
		print(0)
	elif a % 2 == 0:
		print(a - 1)
	else:
		print(a)


t = int(input())
for i in range(t):
	(mg, my, mr) = map(int, input().split())
	(og, oy, Or) = map(int, input().split())
	(pg, py, pr) = map(int, input().split())
	leaves = []
	colors = []
	v1 = mg + my + mr
	y1 = mg + og + pg
	if v1 % 2 == 0:
		v1 = v1 - 1
	leaves.append(v1)
	if y1 % 2 == 0:
		y1 = y1 - 1
	colors.append(y1)
	v2 = og + oy + Or
	y2 = my + oy + py
	if v2 % 2 == 0:
		v2 = v2 - 1
	leaves.append(v2)
	if y2 % 2 == 0:
		y2 = y2 - 1
	colors.append(y2)
	v3 = pg + py + pr
	y3 = mr + Or + pr
	if v3 % 2 == 0:
		v3 = v3 - 1
	leaves.append(v3)
	if y3 % 2 == 0:
		y3 = y3 - 1
	colors.append(y3)
	t1 = leaves + colors
	f = max(t1)
	if f <= 0:
		print(0)
	else:
		print(f)


for tc in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	tree = max(sum(m), sum(o), sum(p))
	(g, y, r) = (0, 0, 0)
	g = m[0] + o[0] + p[0]
	y = m[1] + o[1] + p[1]
	r = m[2] + o[2] + p[2]
	leaf = max(g, y, r)
	maxi = max(tree, leaf)
	if maxi % 2 == 0:
		print(max(maxi - 1, 0))
	else:
		print(maxi)


t = input()
for c in range(0, int(t)):
	(MG, MY, MR) = map(int, input().split())
	(OG, OY, OR) = map(int, input().split())
	(PG, PY, PR) = map(int, input().split())
	l = max([MG + MY + MR, OG + OY + OR, PG + PY + PR, MG + OG + PG, MY + OY + PY, MR + OR + PR])
	if l & 1:
		print(l)
	elif l == 0:
		print(0)
	else:
		print(l - 1)


t = int(input())
for i in range(t):
	flowers = []
	output = []
	for i in range(3):
		a = list(map(int, input().split()))
		flowers.append(a)
		output.append(sum(a))
	for i in range(len(flowers)):
		b = flowers[0][i] + flowers[1][i] + flowers[2][i]
		output.append(b)
	r = max(output)
	if r % 2 == 0 and r > 0:
		print(r - 1)
	else:
		print(r)


for _ in range(int(input())):
	m = (m_g, m_y, m_r) = list(map(int, input().split()))
	o = (o_g, o_y, o_r) = list(map(int, input().split()))
	p = (p_g, p_y, p_r) = list(map(int, input().split()))
	a = max(sum(m), sum(o), sum(p))
	b = max(m_g + o_g + p_g, m_y + o_y + p_y, m_r + o_r + p_r)
	c = max(a, b)
	if c == 0:
		print(0)
	elif c % 2 == 0:
		print(c - 1)
	else:
		print(c)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = map(int, input().split())
	(a2, b2, c2) = map(int, input().split())
	m = max(a + b + c, a1 + b1 + c1, a2 + b2 + c2, a + a1 + a2, b + b1 + b2, c + c1 + c2)
	if m & 1:
		print(m)
	elif m > 0:
		print(m - 1)
	else:
		print(0)


tst = int(input())
for i in range(tst):
	(m1, m2, m3) = map(int, input().split())
	(o1, o2, o3) = map(int, input().split())
	(p1, p2, p3) = map(int, input().split())
	ms = m1 + m2 + m3
	os = o1 + o2 + o3
	ps = p1 + p2 + p3
	s1 = m1 + o1 + p1
	s2 = m2 + o2 + p2
	s3 = m3 + o3 + p3
	ans = max(ms, os, ps, s1, s2, s3)
	if ans == 0:
		ans = 0
	elif ans % 2 == 0:
		ans = ans - 1
	else:
		ans = ans
	print(ans)


for _ in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	arr = [m, o, p]
	total = []
	(g, y, r) = (0, 0, 0)
	for i in arr:
		total.append(sum(i))
		g += i[0]
		y += i[1]
		r += i[2]
	total.append(g)
	total.append(y)
	total.append(r)
	h = 0
	for i in range(6):
		if total[i] % 2 == 0:
			total[i] -= 1
		if h < total[i]:
			h = total[i]
	print(h)


for i in range(int(input())):
	(m_g, m_y, m_r) = map(int, input().split())
	(o_g, o_y, o_r) = map(int, input().split())
	(p_g, p_y, p_r) = map(int, input().split())
	t_m = m_g + m_y + m_r
	t_o = o_g + o_y + o_r
	t_p = p_g + p_y + p_r
	t_g = m_g + o_g + p_g
	t_y = m_y + o_y + p_y
	t_r = m_r + o_r + p_r
	a = max(t_m, t_o, t_p, t_r, t_y, t_g)
	if t_m == 0 and t_o == 0 and (t_p == 0) and (t_r == 0) and (t_y == 0) and (t_g == 0):
		print(0)
	elif a % 2 == 0:
		print(a - 1)
	else:
		print(a)


for _ in range(int(input())):
	flowers = []
	for _ in range(3):
		maple = list(map(int, input().split()))
		flowers.append(maple)
	output = []
	for i in range(len(flowers)):
		output.append(sum(flowers[i]))
		temp = flowers[0][i] + flowers[1][i] + flowers[2][i]
		output.append(temp)
	maxf = max(output)
	if maxf % 2 == 0 and maxf != 0:
		print(maxf - 1)
	else:
		print(maxf)


t = int(input(''))
for _ in range(t):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	x = [sum(m), sum(o), sum(p)]
	for i in range(3):
		x.append(m[i] + o[i] + p[i])
	m = max(x)
	if m % 2 == 0:
		if m == 0:
			print(0)
		else:
			print(m - 1)
	else:
		print(m)


t = int(input())
for i in range(t):
	a = 0
	l1 = []
	(xi, xj, xk) = map(int, input().split(' '))
	(yi, yj, yk) = map(int, input().split(' '))
	(zi, zj, zk) = map(int, input().split(' '))
	l1.append(xi + xj + xk)
	l1.append(yi + yj + yk)
	l1.append(zi + zj + zk)
	l1.append(xi + yi + zi)
	l1.append(xj + yj + zj)
	l1.append(xk + yk + zk)
	m = max(l1)
	if m % 2 == 0:
		if m == 0:
			print(0)
		else:
			print(m - 1)
	else:
		print(m)


for i in range(int(input())):
	m = list(map(int, input().split()))
	o = list(map(int, input().split()))
	p = list(map(int, input().split()))
	total_leaves = []
	total_leaves.append(sum(m))
	total_leaves.append(sum(o))
	total_leaves.append(sum(p))
	max1 = []
	ma = max(total_leaves)
	if ma % 2 != 0:
		max1.append(ma)
	else:
		max1.append(ma - 1)
	colour_leaves = []
	colour_leaves.append(m[0] + o[0] + p[0])
	colour_leaves.append(m[1] + o[1] + p[1])
	colour_leaves.append(m[2] + o[2] + p[2])
	ma1 = max(colour_leaves)
	if ma1 % 2 != 0:
		max1.append(ma1)
	else:
		max1.append(ma1 - 1)
	mo = max(max1)
	if mo > 0:
		print(mo)
	else:
		print(0)


t = int(input())
for i in range(t):
	m = input().split()
	o = input().split()
	p = input().split()
	M = [int(i) for i in m]
	O = [int(j) for j in o]
	P = [int(k) for k in p]
	g = M[0] + O[0] + P[0]
	y = M[1] + O[1] + P[1]
	r = M[2] + O[2] + P[2]
	m1 = sum(M)
	o1 = sum(O)
	p1 = sum(P)
	list1 = [g, y, r, m1, o1, p1]
	f = max(list1)
	if f % 2 == 0 and f != 0:
		print(f - 1)
	else:
		print(f)


t = int(input())
for _ in range(t):
	(Mg, My, Mr) = map(int, input().split())
	(Pg, Py, Pr) = map(int, input().split())
	(Og, Oy, Or) = map(int, input().split())
	ans = max(Mg + My + Mr, Pg + Py + Pr, Og + Oy + Or, 0)
	ans = max(Mg + Pg + Og, My + Py + Oy, Mr + Pr + Or, ans)
	if ans % 2 == 0 and ans != 0:
		print(ans - 1)
	else:
		print(ans)


for t in range(int(input())):
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	max = 0
	g = l1[0] + l2[0] + l3[0]
	y = l1[1] + l2[1] + l3[1]
	r = l1[2] + l2[2] + l3[2]
	if g % 2 == 0:
		g -= 1
	if y % 2 == 0:
		y -= 1
	if r % 2 == 0:
		r -= 1
	if max < g:
		max = g
	if max < r:
		max = r
	if max < y:
		max = y
	m = l1[0] + l1[1] + l1[2]
	o = l2[0] + l2[1] + l2[2]
	p = l3[0] + l3[1] + l3[2]
	if m % 2 == 0:
		m -= 1
	if o % 2 == 0:
		o -= 1
	if p % 2 == 0:
		p -= 1
	if max < m:
		max = m
	if max < o:
		max = o
	if max < p:
		max = p
	print(max)


for i in range(int(input())):
	max1 = []
	a1 = []
	a1.append(list(map(int, input().split())))
	a1.append(list(map(int, input().split())))
	a1.append(list(map(int, input().split())))
	for i in a1:
		if sum(i) % 2 == 0:
			max1.append(sum(i) - 1)
		else:
			max1.append(sum(i))
	for i in range(3):
		if (a1[0][i] + a1[1][i] + a1[2][i]) % 2 == 0:
			max1.append(a1[0][i] + a1[1][i] + a1[2][i] - 1)
		else:
			max1.append(a1[0][i] + a1[1][i] + a1[2][i])
	if max(max1) > 0:
		print(max(max1))
	else:
		print(0)


for _ in range(int(input())):
	a = []
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a3 = list(map(int, input().split()))
	a.append(a1)
	a.append(a2)
	a.append(a3)
	x = max(sum(a[0]), sum(a[1]), sum(a[2]))
	y = max(a1[0] + a2[0] + a3[0], a1[1] + a2[1] + a3[1], a1[2] + a2[2] + a3[2])
	z = max(x, y)
	if z == 0:
		print('0')
	elif z % 2 == 0:
		print(z - 1)
	else:
		print(z)