Luntik has decided to try singing. He has $a$ one-minute songs, $b$ two-minute songs and $c$ three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.

He wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.

Please help Luntik and find the minimal possible difference in minutes between the concerts durations.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.

Each test case consists of one line containing three integers $a, b, c$ $(1 \le a, b, c \le 10^9)$ — the number of one-minute, two-minute and three-minute songs.


-----Output-----

For each test case print the minimal possible difference in minutes between the concerts durations.


-----Examples-----

Input
4
1 1 1
2 1 3
5 5 5
1 1 2
Output
0
1
0
1


-----Note-----

In the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to $0$.

In the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be $1 + 1 + 2 + 3 = 7$, the duration of the second concert will be $6$. The difference of them is $|7-6| = 1$.

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
import sys
import os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	sys.stderr = open('error.txt', 'w')
depth = 1000000
mod = 1000000007
lim = 10000005
sys.setrecursionlimit(depth)
linp = lambda : list(minp())
minp = lambda : map(int, input().split())
from math import inf, ceil, sqrt, log2, gcd
from collections import defaultdict, deque
dd = lambda x: defaultdict(lambda : x)
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for _ in range(int(input())):
	(a, b, c) = minp()
	s = a + 2 * b + 3 * c
	print(s & 1)


for ___ in range(int(input())):
	(a, b, c) = map(int, input().split())
	v1 = 0
	v2 = 0
	v1 += a // 2 * 3
	v2 += a // 2 * 3
	if a % 2 == 1:
		v1 += 3
	if v1 > v2 and b != 0:
		b -= 1
		v2 += 2
	v1 += b // 2 * 2
	v2 += b // 2 * 2
	if b % 2 == 1:
		v2 += 2
	if v1 < v2:
		t = v1
		v1 = v2
		v2 = t
	while c != 0 and v1 > v2:
		v2 += 1
		c -= 1
	d = v1 - v2
	if c == 0:
		print(d)
	elif d % 2 == c % 2:
		print(0)
	else:
		print(1)


import os
import sys
import math
from io import BytesIO, IOBase
f = 1

def solve():
	(a, b, c) = [int(x) for x in input().split()]
	print((1 * a + 2 * b + 3 * c) % 2)
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')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
if f == 1:
	t = int(input())
	while t:
		solve()
		t -= 1
else:
	solve()


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
a = []
(n, k) = (0, 0)
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07
x = 0
pref = []
lvl = []

def update_it(bit, i, val):
	n = len(bit)
	while i < n:
		bit[i] += val
		i += i & -i

def get_ans(bit, i):
	n = len(bit)
	tot = 0
	while i > 0:
		tot += bit[i]
		i -= i & -i
	return tot

def hnbhai(tc):
	(a, b, c) = sd()
	tot = 0
	rem = 0
	if c % 2 == 1:
		tot = 3
		rem = 3
		if b >= 1:
			b -= 1
			rem = 1
		if a % 2 == 1:
			rem = 0
	elif b % 2 == 1:
		rem = 2
		if a >= 1:
			rem = 1
			a -= 1
		if a % 2 == 1:
			rem = 0
	elif a % 2 == 1:
		rem = 1
	print(rem)
for _ in range(sb()):
	hnbhai(_ + 1)


t = int(input())
for i in range(t, 0, -1):
	(a, b, c) = map(int, input().split())
	if a == b and b == c:
		print('0')
	else:
		total = a * 1 + b * 2 + c * 3
		time = total // 2
		balance_time = total - time
		s = balance_time - time
		print(s)


for z in range(int(input())):
	(a, b, c) = map(int, input().split())
	a = 2 if a % 2 == 0 else 1
	b = 2 if b % 2 == 0 else 1
	c = 2 if c % 2 == 0 else 1
	if a == b and a == c:
		print(0)
	elif a == c and a != b:
		print(0)
	else:
		print(1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	k = a * 1 + b * 2 + c * 3
	print(k % 2)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print((a + c) % 2)


import sys
import string
from decimal import Decimal
from math import log

def inp():
	return int(input())

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

def inpstrlist():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(a, b, c) = invr()
	s = a + 2 * b + 3 * c
	if s % 2 == 0:
		print(0)
	else:
		print(1)


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	print((a[0] + a[1] * 2 + a[2] * 3) % 2)


import sys
from collections import Counter
import math
import heapq
from itertools import accumulate
from collections import defaultdict
from collections import Counter
from itertools import zip_longest
num_cases = int(sys.stdin.readline().strip())
for case in range(1, num_cases + 1):
	(A, B, C) = list(map(int, sys.stdin.readline().split()))
	(mock_a, n_a) = divmod(A, 2)
	(mock_b, n_b) = divmod(B, 2)
	(mock_c, n_c) = divmod(C, 2)
	two_signal = 0
	four_signal = 0
	if A >= 2 and B >= 2:
		two_signal = 1
	if A >= 2 and C >= 2:
		four_signal = 1
	if B >= 2 and C >= 2:
		two_signal = 1
	if A >= 2:
		two_signal = 1
	if B >= 2:
		four_signal = 1
	if n_a == n_b == n_c:
		print(0)
	elif n_a == 1 and n_b == 0 and (n_c == 0):
		print(1)
	elif n_a == 1 and n_b == 1 and (n_c == 0):
		print(1)
	elif n_a == 0 and n_b == 1 and (n_c == 1):
		print(1)
	elif n_a == 0 and n_b == 1 and (n_c == 0):
		if two_signal:
			print(0)
		else:
			print(2)
	elif n_a == 0 and n_b == 0 and (n_c == 1):
		if two_signal or four_signal:
			print(1)
		else:
			print(3)
	elif n_a == 1 and n_b == 0 and (n_c == 1):
		if two_signal or four_signal:
			print(0)
		else:
			print(2)


test = int(input())
while test:
	(a, b, c) = map(int, input().split())
	ans = a + 2 * b + 3 * c
	if ans % 2 == 0:
		print(0)
	else:
		print(1)
	test -= 1


from math import ceil
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print((a + 2 * b + 3 * c) % 2)


n = int(input())
g = []
for i in range(n):
	(a, b, c) = input().split()
	if (int(a) + int(b) * 2 + int(c) * 3) % 2 == 0:
		g.append(0)
	else:
		g.append(1)
print(*g, sep='\n')


def minDiff(a, b, c):
	duration = 1 * a + 2 * b + 3 * c
	return 0 if duration % 2 == 0 else 1
for t in range(int(input())):
	(a, b, c) = [int(x) for x in input().split()]
	print(minDiff(a, b, c))


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	bb = 2 * b
	cc = 3 * c
	total = a + bb + cc
	if total % 2 == 0:
		print('0')
	else:
		print('1')


(n, my_min) = (int(input()), 999)
for _ in range(n):
	(a, b, c) = map(int, input().split())
	if (a + b * 2 + c * 3) % 2 == 0:
		print(0)
	elif (a + b * 2 + c * 3) % 2 != 0:
		print(1)


n = int(input())
result = []
for i in range(n):
	vstup = list(map(int, input().strip().split()))
	sumicka = vstup[0] + vstup[1] * 2 + vstup[2] * 3
	result.append(str(sumicka % 2))
print('\n'.join(result))


test_case = int(input())
for i in range(test_case):
	x = input().split(' ')
	a = int(x[0])
	b = int(x[1])
	c = int(x[2])
	print(str((a + 2 * b + 3 * c) % 2))


import sys
DEBUG = 0
if DEBUG == 1:
	data = open('1.in', 'r')

def readline():
	if DEBUG == 1:
		return data.readline().strip('\r\n')
	else:
		try:
			return input().strip('\r\n')
		except EOFError:
			return ''

def readi():
	return [int(t) for t in readline().split()]
(tc,) = readi()
for _ in range(tc):
	(a, b, c) = readi()
	a %= 2
	b %= 2
	c %= 2
	if c == 1:
		if a == 1 and b == 1:
			print(0)
		elif b == 1:
			print(1)
		elif a == 1:
			print(0)
		else:
			print(1)
	elif c == 0:
		if a == 1 and b == 1:
			print(1)
		elif b == 1:
			print(0)
		elif a == 1:
			print(1)
		else:
			print(0)
if DEBUG == 1:
	data.close()


import math
import os
import sys
from sys import *
from decimal import *
from io import BytesIO, IOBase
import threading
from itertools import *
from collections import *
from array import *
import random
M = 10 ** 9 + 7
import heapq
import bisect
from functools import lru_cache
from queue import PriorityQueue
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')

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] == key:
			return mid
		if arr[mid] <= key:
			left = mid + 1
		else:
			right = mid - 1
	return -1

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def luckynumber(x, n, a):
	if x > 0:
		a.append(x)
	if x > 10 ** 9:
		return a
	elif x < 1000000000000.0:
		luckynumber(x * 10 + 4, n, a)
		luckynumber(x * 10 + 7, n, a)

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

def query1(l, r):
	if l >= r:
		return -1
	print('?', l + 1, r + 1)
	sys.stdout.flush()
	return int(input()) - 1

def answer(p):
	print('!', p + 1)
	sys.stdout.flush()
	exit()

def rse(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(n)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(n)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def lse(arr, n):
	stack = []
	ans = []
	for i in range(n):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	return ans

def mah(arr):
	max1 = 0
	p = rse(arr, len(arr))
	q = lse(arr, len(arr))
	for i in range(len(arr)):
		a = (p[i] - q[i] - 1) * arr[i]
		max1 = max(a, max1)
	return max1

def maxSumIS(arr, n):
	msis = arr.copy()
	for i in range(1, n):
		for j in range(i):
			if arr[i] > arr[j] and msis[i] < msis[j] + arr[i]:
				msis[i] = msis[j] + arr[i]
	c = max(msis)
	p = 5
	return c

def binarysearch2(arr, target):
	lo = 0
	hi = len(arr) - 1
	while lo <= hi:
		mid = (lo + hi) // 2
		if arr[mid] == target:
			if mid != len(arr) - 1:
				if arr[mid + 1] != target:
					return mid
				else:
					lo += 1
			else:
				return mid
			continue
		if arr[mid] > target:
			hi = mid - 1
		else:
			lo = mid + 1

def nge(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) > 0:
				if stack[-1][0] < arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def alperm(nums, path, result):
	if not nums:
		result.add(tuple(path))
		return
	for i in range(0, len(nums)):
		alperm(nums[:i] + nums[i + 1:], path + [nums[i]], result)
	return result

def minsum(arr, n, m, res, l):
	if n == 1 and m == 1:
		res += arr[0][0]
		l.append(res)
	else:
		if n != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n - 1, m, p, l)
		if m != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n, m - 1, p, l)
	return min(l)

def find_shortest_path(graph, start, end, path):
	path = path + [start]
	if start == end:
		return path
	if start not in graph:
		return None
	shortest = None
	for node in graph[start]:
		if node not in path:
			newpath = find_shortest_path(graph, node, end, path)
			if newpath:
				if not shortest or len(newpath) < len(shortest):
					shortest = newpath
	return shortest

def test(n, d):
	a = random.randint(1, n - 2)
	p = pow(a, d, n)
	if p == 1 or p == n - 1:
		return True
	while d != n - 1:
		d *= 2
		p = pow(p, 2, n)
		if p == n - 1:
			return True
	return False

def isprime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	if n == 3:
		return True
	d = n - 1
	while d % 2 == 0:
		d //= 2
	for i in range(5):
		if test(n, d) == False:
			return False
	return True

def muin(a, m):
	(x, y, mo) = (1, 0, m)
	if m == 1:
		return 0
	while m > 0:
		(x, y) = (y, x - a // m * y)
		(a, m) = (m, a % m)
	if x < 0:
		return mo + x
	else:
		return x

def good(l, c):
	ch = chr(c)
	if len(l) == 1:
		return 1 if ch != l[0] else 0
	k = len(l) // 2
	lm = k - l[:k].count(ch) + good(l[k:], c + 1)
	rm = k - l[k:].count(ch) + good(l[:k], c + 1)
	return min(lm, rm)

def facto(fact):
	(fact[0], fact[1]) = (1, 1)
	for i in range(2, 10 ** 6 + 1):
		fact[i] = fact[i - 1] * i % M

def comb(n, r, fact):
	return fact[n] * pow(fact[n - r] * fact[r], M - 2, M) % M

def numberToBase(n, b):
	if n == 0:
		return 0
	digits = []
	while n:
		digits.append(n % b)
		n //= b
	return sum(digits)

def main():
	t = 1
	t = int(input())
	for tc in range(1, t + 1):
		(a, b, c) = sep()
		if a == b and b == c:
			print(0)
		else:
			m = a + b * 2 + c * 3
			print(m % 2)
main()


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	r = 0
	if c % 2 != 0:
		r = 3
	if r == 3:
		if b > 0:
			r = 1
			b -= 1
	if b % 2 != 0:
		r = abs(r - 2)
	if r > 0:
		if a >= r:
			a -= r
			r = 0
		else:
			r -= a
			a = 0
	if a % 2 != 0:
		r = abs(r - 1)
	print(abs(r))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	res = a + 2 * b + 3 * c
	print(res % 2)


for _ in range(int(input())):
	lst = [int(i) for i in input().split()]
	x = lst[0] * 1 + lst[1] * 2 + lst[2] * 3
	if x % 2 == 0:
		print(0)
	else:
		print(1)


t = int(input())
while t:
	(a, b, c) = input().split()
	total = int(a) + 2 * int(b) + 3 * int(c)
	if total % 2 == 0:
		print(0, '\n')
	else:
		print(1, '\n')
	t -= 1


try:
	cases = int(input())
	while cases > 0:
		(d, e, f) = map(int, input().split())
		summ = (d + e * 2 + f * 3) % 2
		if summ != 0:
			print('1')
		else:
			print('0')
except:
	pass


for _ in range(int(input())):
	n = list(map(int, input().split()))
	total = n[0] + 2 * n[1] + 3 * n[2]
	print(0 if total % 2 == 0 else 1)


t = int(input())
o = 0
while o != t:
	o += 1
	(a, b, c) = map(int, input().split())
	b = b * 2
	c = c * 3
	s = a + b + c
	print(s % 2)


n = int(input())
for i in range(n):
	z = 0
	(a, b, c) = map(int, input().split())
	c %= 2
	if c > 0:
		z = 3
	if b > 0:
		if z == 3:
			z = 1
			b -= 1
		elif b % 2 > 0:
			z = 2
	m = min(a, z)
	if m > 0:
		a -= m
		z -= m
	if a % 2 > 0:
		z += 1
	print(z)


for i in range(int(input())):
	s = tuple(map(lambda t: t[0] * t[1], zip(map(int, input().split()), (1, 2, 3))))
	print(sum(s) % 2)


l1 = []
T = int(input())
for i in range(T):
	x = input()
	(a, b, c) = map(int, x.split())
	mina = a
	minb = 2 * b
	minc = 3 * c
	if (mina + minb + minc) % 2 == 0:
		s = 0
	else:
		s = 1
	l1.append(s)
for a in l1:
	print(a)


import sys
input = sys.stdin.readline
print = sys.stdout.write
a = int(input())
for i in range(a):
	(q, w, e) = map(int, input().split())
	thing = q + w * 2 + e * 3
	if thing % 2 == 0:
		print('0\n')
	else:
		print('1\n')


t = int(input())
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	a1 = int(a) * 1
	b1 = int(b) * 2
	c1 = int(c) * 3
	sum = a1 + b1 + c1
	print(sum % 2)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	temp = a * 1 + b * 2 + c * 3
	if temp % 2 == 0:
		print('0')
	else:
		print('1')


n = int(input())
for _ in range(n):
	(a, b, c) = map(int, input().split())
	A = a
	B = b * 2
	C = c * 3
	total = A + B + C
	htotal = total // 2
	h2total = total - htotal
	print(abs(htotal - h2total))


for _ in range(int(input())):
	(virat, rohit, hardik) = map(int, input().split())
	if (virat + rohit * 2 + hardik * 3) % 2 == 0:
		print('0')
	else:
		print('1')


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	b *= 2
	c *= 3
	print((a + b + c) % 2)


from collections import Counter
import math
import bisect
from sys import stdin, stdout
input = stdin.readline
mod = 10 ** 9 + 7

def inp():
	return map(int, input().split())
for _ in range(int(input())):
	(a, b, c) = inp()
	k = a + 2 * b + 3 * c
	print(1 if k & 1 else 0)


from math import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

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

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	(a, b, c) = ma()
	a = 3 * a
	b = 2 * b
	if (a + b + c) % 2:
		print(1)
	else:
		print(0)


T = int(input())
for _ in range(T):
	(a, b, c) = map(int, input().split())
	b *= 2
	c *= 3
	sum = a + b + c
	if sum % 2:
		print(1)
	else:
		print(0)


for i in range(int(input())):
	(one, two, three) = (int(x) for x in input().split())
	print((one + 2 * two + 3 * three) % 2)


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


import math as m
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	aa = a % 2
	bb = b % 2
	cc = c % 2
	if aa + bb + cc == 3:
		print(0)
		continue
	if aa + bb + cc == 0:
		print(0)
		continue
	if aa == 0 and bb == 1 and (cc == 0):
		print(0)
		continue
	if aa == 1 and bb == 0 and (cc == 0):
		print(1)
		continue
	if aa == 0 and bb == 0 and (cc == 1):
		print(1)
		continue
	if aa == 1 and bb == 0 and (cc == 1):
		print(0)
		continue
	if aa == 1 and bb == 1 and (cc == 0):
		print(1)
		continue
	if aa == 0 and bb == 1 and (cc == 1):
		print(1)
		continue


import sys, math
input = sys.stdin.readline
INF = int(1000000000.0) + 7

def solve():
	(a, b, c) = map(int, input().split())
	s = a + 2 * b + 3 * c
	if s % 2:
		print(1)
	else:
		print(0)
t = int(input())
while t:
	t -= 1
	solve()


for s in [*open(0)][1:]:
	(a, b, c) = map(int, s.split())
	print(a + c & 1)


import sys
inp = sys.stdin.readline()
test = int(inp.strip('\n'))
result = ''
for i in range(test):
	inp = sys.stdin.readline()
	(a, b, c) = list(map(int, inp.strip('\n').split()))
	total = a + b * 2 + c * 3
	if total % 2 == 0:
		sys.stdout.write('0\n')
	else:
		sys.stdout.write('1\n')


from sys import stdin, stdout, setrecursionlimit
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
from heapq import *
mod = 10 ** 9 + 7
inf = 1 << 60
for _ in range(int(input())):
	(a, b, c) = mp()
	tot_time = a + 2 * b + c * 3
	req = (tot_time + 1) // 2
	rem = req
	useable_3 = min(rem // 3, c)
	cur_sum = 0
	cur_sum += useable_3 * 3
	rem -= cur_sum
	useble_2 = min(rem // 2, b)
	cur_sum += useble_2 * 2
	rem = req
	rem -= cur_sum
	useble_1 = min(a, rem)
	cur_sum += useble_1
	print(abs(tot_time - 2 * cur_sum))


import bisect
import collections
import copy
import enum
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(3001)
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	s = 3 * c + 2 * b + a
	half = s // 2
	h1 = half
	s1 = 0
	t1 = half // 3
	s1 += min(t1, c) * 3
	h1 -= min(t1, c) * 3
	c -= min(t1, c)
	t2 = h1 // 2
	s1 += min(t2, b) * 2
	h1 -= min(t2, b) * 2
	b -= min(t2, b)
	s1 += min(h1, a)
	h1 -= min(h1, a)
	a -= min(h1, a)
	ans = s - s1 - s1
	if c:
		ans = min(ans, abs(s - s1 - 3 - s1 - 3))
	if b:
		ans = min(ans, abs(s - s1 - 2 - s1 - 2))
	print(ans)


import sys
input = sys.stdin.readline

def solve():
	(a, b, c) = map(int, input().split())
	ans = 0
	if a % 2 ^ 1:
		ans += 1
	if b % 2 ^ 1:
		ans += 2
	if c % 2 ^ 1:
		ans += 3
	print(ans - 2 * (ans // 2))
t = int(input())
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test_case = inp()
current_test = 0
while current_test < test_case:
	current_test += 1
	(a, b, c) = invr()
	s = a + b * 2 + c * 3
	d = s % 2
	print(d)


def absDiff(a, b, c):
	if a % 2 == 0 and b % 2 == 0 and (c % 2 == 0):
		return 0
	if c % 2 == 0:
		if b % 2 == 0:
			if a % 2 == 0:
				return 0
			return 1
		if a >= 2 and (a - 2) % 2 == 0:
			return 0
		if a == 0:
			return 2
		return 1
	if b >= 1 and (b - 1) % 2 == 0:
		if a >= 1 and (a - 1) % 2 == 0:
			return 0
		return 1
	if b == 0:
		if a >= 3 and (a - 3) % 2 == 0:
			return 0
		if a < 3:
			return 3 - a
		return 1
	if a >= 1 and (a - 1) % 2 == 0:
		return 0
	return 1
num = int(input())
for _ in range(num):
	(a, b, c) = [int(x) for x in input().split(' ')]
	print(absDiff(a, b, c))


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


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(a, b, c) = I()
	(x, y, z) = (a % 2, b % 2, c % 2)
	an = x * 1 + y * 2 + z * 3
	print(an % 2)


n = int(input())
for i in range(n):
	num = input()
	l = num.split(' ')
	for j in range(len(l)):
		l[j] = int(l[j])
	if (l[0] * 1 + l[1] * 2 + l[2] * 3) % 2 == 0:
		print(0)
	else:
		print(1)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	print((a + c) % 2)


n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	print((x[0] + x[1] * 2 + x[2] * 3) % 2)


t = int(input())
for _ in range(t):
	songs = list(map(int, input().split()))
	a = songs[0]
	b = songs[1]
	c = songs[2]
	mid = (a + b * 2 + c * 3) // 2
	if mid == (a + b * 2 + c * 3) / 2:
		print(0)
	else:
		print(1)


t = int(input())
while t != 0:
	total = 0
	(a, b, c) = map(int, input().split())
	total = total + a * 1 + b * 2 + c * 3
	d = total % 2
	print(d)
	t = t - 1


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp_vars_int = lambda : map(int, input().split())
inp_list_int = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(a, b, c) = inp_vars_int()
	full = a + 2 * b + 3 * c
	print(full % 2)


import sys
input = sys.stdin.readline

def cast(cre, typ):
	return type(typ)(map(cre, typ))

def inp_lis(cre):
	if cre == str:
		return input().split()
	elif cre == bool:
		return cast(bool, cast(int, input().split()))
	else:
		return cast(cre, input().split())

def repl(str_, idx=-1, char=''):
	leng = len(str_)
	return str_[:idx] + char + str_[(leng + idx) % leng + 1:]

def solution():
	for t in range(int(input())):
		song = inp_lis(int)
		tot = 0
		for i in range(len(song)):
			tot += song[i] * (i + 1)
		if tot / 2 > tot // 2:
			print('1')
		else:
			print('0')
	return
solution()


from sys import stdin
n = int(stdin.readline())
for i in range(n):
	(a, b, c) = map(int, stdin.readline().split())
	print((a + 2 * b + 3 * c) % 2)


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	if (a + 2 * b + 3 * c) % 2 == 0:
		print(0)
	else:
		print(1)
	t -= 1


n = int(input())
list1 = []
for i in range(n):
	list1.append([int(x) for x in input().split()])
for i in list1:
	print((i[0] + i[2]) % 2)


import sys

def input():
	return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]
mod = 998244353
inf = 1 << 64

def main():
	t = int(input())
	for i in range(t):
		(a, b, c) = map(int, input().split())
		sums = a + 2 * b + 3 * c
		if sums % 2 == 0:
			print(0)
		else:
			print(1)
	return 0
main()


testCases = int(input())
for i in range(0, testCases):
	(a, b, c) = [int(s) for s in input().split(' ')]
	totalLen = a + b * 2 + c * 3
	firstCon = abs(totalLen // 2)
	secondCon = totalLen - firstCon
	print(abs(firstCon - secondCon))


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	n = a * 1 + b * 2 + c * 3
	print(n % 2)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	b = 2 * b
	c = 3 * c
	res = abs(c - b - a)
	print(res % 2)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	(a, b, c) = M()
	if (a + 2 * b + 3 * c) % 2 == 1:
		print(1)
	else:
		print(0)


testcases = int(input())
for i in range(testcases):
	(x, y, z) = map(int, input().split())
	mindiff = (x * 1 + y * 2 + z * 3) % 2
	print(mindiff)


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	y *= 2
	z *= 3
	print((x + y + z) % 2)


from sys import stdin, stdout
print = stdout.write
input = stdin.readline

def solve_test():
	(a, b, c) = (int(x) for x in input().split())
	(a, b, c) = (a % 2, b % 2, c % 2)
	return f'{(a + b * 2 + c * 3) % 2}'

def main(args=None):
	tests = int(input())
	for _ in range(tests):
		print(f'{solve_test()}\n')
main()


n = int(input())
for _ in range(n):
	s = list(map(int, input().lstrip().split()))
	a = s[0]
	b = s[1]
	c = s[2]
	total = int(a) + 2 * int(b) + 3 * int(c)
	if total % 2 == 1:
		print('1')
	else:
		print('0')


Sat = int(input())
for i in range(Sat):
	(A, B, C) = map(int, input().split())
	if (A + B * 2 + C * 3) % 2 == 0:
		print('0')
	else:
		print('1')


t = int(input())
for test in range(t):
	(one, two, three) = map(int, input().split())
	diff = 0
	diff += three % 2 * 3
	if two > 0:
		if diff != 0:
			diff = 1
		else:
			diff = two % 2 * 2
	while one > 0:
		if diff == 0:
			diff = one % 2
			break
		one -= 1
		diff -= 1
	print(diff)


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
from itertools import permutations
from operator import itemgetter
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')
pi = 3.1415926535
mod = 10 ** 9 + 7
for _ in range(int(input())):
	a = list(map(int, input().split()))
	t = a[0] + 2 * a[1] + 3 * a[2]
	if t % 2:
		print(1)
	else:
		print(0)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b and b == c:
		print('0')
	else:
		time = a + b * 2 + c * 3
		mid = time // 2
		time_total = time - mid
		print(abs(time_total - mid))


import math
t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split())
	print((a + 2 * b + 3 * c) % 2)


n = int(input())
ls = []
for i in range(n):
	st = input()
	list = st.split()
	count = 1
	summ = 0
	for j in list:
		summ += int(j) * count
		count += 1
	ls.append(summ % 2)
for i in ls:
	print(i)


def case():
	(a, b, c) = map(int, input().split())
	ans = 0
	if (a + b * 2 + c * 3) % 2:
		print(1)
	else:
		print(0)

def main():
	T = int(input())
	for _ in range(T):
		case()
main()


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	(col, col2) = (c // 2 * 3 + (3 if c % 2 == 1 else 0), c // 2 * 3)
	while col > col2 and b:
		col2 += 2
		b -= 1
	(col, col2) = (max(col, col2), min(col, col2))
	col += b // 2 * 2
	col2 += b // 2 * 2 + (2 if b % 2 == 1 else 0)
	while col > col2 and a:
		col2 += 1
		a -= 1
	while col < col2 and a:
		col += 1
		a -= 1
	(col, col2) = (max(col, col2), min(col, col2))
	col += a // 2
	col2 += a // 2 + (1 if a % 2 == 1 else 0)
	print(abs(col - col2))


def fun(a, b, c):
	x = a + 2 * b + 3 * c
	return 1 if x % 2 == 1 else 0
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	ans = fun(a, b, c)
	print(ans)


T = input()
for t in range(int(T)):
	ss = input().split(' ')
	a = int(ss[0])
	b = int(ss[1])
	c = int(ss[2])
	t1 = 0
	t2 = 0
	t3 = 0
	if a % 2 == 1:
		t1 = 1
	if b % 2 == 1:
		t2 = 1
	if c % 2 == 1:
		t3 = 1
	if t1 and t2 and t3:
		print(0)
	elif t1 and t2:
		print(1)
	elif t1 and t3:
		if a > 2 or b >= 2:
			print(0)
		else:
			print(2)
	elif t2 and t3:
		print(1)
	elif t1:
		print(1)
	elif t2:
		if a >= 2:
			print(0)
		else:
			print(2)
	elif t3:
		if a >= 2 or b >= 2:
			print(1)
		else:
			print(3)
	else:
		print(0)


t = int(input())
for h in range(t):
	(a, b, c) = map(int, input().split())
	z = a + 2 * b + 3 * c
	if z % 2 == 0:
		print(0)
	else:
		print(1)


n = int(input())
for _ in range(n):
	(a, b, c) = [int(i) % 2 for i in input().split()]
	if a == 1 and b == 1 and (c == 0):
		print(1)
	elif a == 0 and b == 1 and (c == 1):
		print(1)
	elif a == 1 and b == 0 and (c == 0):
		print(1)
	elif a == 0 and b == 0 and (c == 1):
		print(1)
	else:
		print(0)


n = int(input())
ret = []
for i in range(n):
	(a, b, c) = map(int, input().split())
	c %= 2
	if c == 1 and b > 0 and (a > 0):
		c -= 1
		a -= 1
		b -= 1
	elif c == 1 and b == 0 and (a >= 3):
		a -= 3
		c -= 1
	elif c == 1 and b >= 2 and (a == 0):
		a += 1
		b -= 2
		c -= 0
	elif c == 1 and b == 0 and (a == 0):
		ret.append(3)
		continue
	b %= 2
	if b == 1 and a >= 2:
		a -= 2
		b -= 1
	ret.append(a % 2)
for i in ret:
	print(i)


for _ in range(int(input())):
	a = list(map(int, input().split(' ')))
	print((a[0] + a[2]) % 2)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	a1 = a % 2
	b1 = b % 2
	c1 = c % 2
	s = str(a1) + str(b1) + str(c1)
	if s == '110' or s == '011' or s == '100' or (s == '001'):
		print(1)
	else:
		print(0)


N = int(input())
i = 0
while i < N:
	a = input().split()
	print(int(a[0]) + int(a[1]) * 2 + int(a[2]) * 3 - 2 * ((int(a[0]) + int(a[1]) * 2 + int(a[2]) * 3) // 2))
	i += 1


t = int(input())
while t:
	t -= 1
	(a, b, c) = list(map(int, input().split()))
	one = a
	two = b * 2
	three = c * 3
	total = one + two + three
	print(total % 2)


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	num = x + 2 * y + 3 * z
	if num % 2:
		print(1)
	else:
		print(0)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	s2 = a // 2 + 2 * (b // 2) + 3 * (c // 2)
	s1 = a + 2 * b + 3 * c - s2
	aa = min((a + 1) // 2, 3)
	bb = min((b + 1) // 2, 3)
	cc = min((c + 1) // 2, 3)
	mn = s1 - s2
	for i in range(aa + 1):
		for j in range(bb + 1):
			for z in range(cc + 1):
				x = i + j * 2 + z * 3
				mn = min(mn, abs(s1 - s2 - 2 * x))
	print(mn)


import sys
input = sys.stdin.readline

def solve():
	(a, b, c) = map(int, input().split())
	S = a + 2 * b + 3 * c
	T = S // 2
	ans = 0
	ans += 3 * min(T // 3, c)
	T -= 3 * min(T // 3, c)
	ans += 2 * min(T // 2, b)
	T -= 2 * min(T // 2, b)
	ans += 1 * min(T // 1, a)
	T -= 1 * min(T // 2, a)
	return abs(S - ans - ans)
for _ in range(int(input())):
	print(solve())


t = int(input())
for item in range(0, t):
	(a, b, c) = map(int, input().split())
	print((a * 1 + b * 2 + c * 3) % 2)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	(a, b, c) = (l[0], l[1], l[2])
	print((a + 2 * b + 3 * c) % 2)


import sys, collections, math, bisect, heapq, random
input = sys.stdin.readline
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	v = a + 2 * b + 3 * c
	print(v & 1)


import math
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	summ = 3 * c
	summ += 2 * b
	summ += a
	if summ % 2:
		print(1)
	else:
		print(0)


n = int(input())
mat = []
while n != 0:
	n -= 1
	lst = list(input().split(' '))
	lst = list(map(int, lst))
	s = lst[0] + lst[1] * 2 + lst[2] * 3
	if s % 2 == 0:
		mat.append('0')
	else:
		mat.append('1')
for i in mat:
	print(i)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	su = a + 2 * b + 3 * c
	n = a + b + c
	if a == b and b == c:
		print(0)
	elif su % 2 == 0:
		print(0)
	else:
		print(1)


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

def solve():
	(a, b, c) = read_nums()
	print((a + 2 * b + 3 * c) % 2)

def main():
	(t,) = read_nums()
	for _ in range(t):
		solve()
main()


def possible(d, a, b, c):
	c = min(c, d // 3)
	d -= 3 * c
	b = min(b, d // 2)
	d -= 2 * b
	a = min(a, d)
	d -= a
	return d == 0

def solve_case():
	(a, b, c) = map(int, input().split())
	s = a + 2 * b + 3 * c
	min_diff = 4
	for diff in range(4):
		mid = s // 2 + diff
		if possible(mid, a, b, c):
			min_diff = min(min_diff, abs(s - 2 * mid))
	print(min_diff)
T = int(input())
for t in range(T):
	solve_case()


def solve():
	songs = [int(x) for x in input().split()]
	durations = [1, 2, 3]
	concert_duration = sum((s * d for (s, d) in zip(songs, durations)))
	if concert_duration & 1 == 0:
		return 0
	if songs[0] > 0:
		return 1
	return 1
for _ in range(int(input())):
	print(solve())


t = int(input())
for _ in range(t):
	(x, y, z) = tuple(map(int, input().split()))
	d = 0
	if z % 2:
		d = 3
	if d and y:
		d = 1
	elif not y % 2:
		d = 0
	else:
		d = 2
	d = d - x
	if d < 0:
		d %= 2
	print(d, '\n')


t = int(input())
for _ in range(t):
	(a, b, c) = [int(i) for i in input().split()]
	print((a + 2 * b + 3 * c) % 2)


t = int(input())
for slkdj in range(t):
	l = [int(i) for i in input().split()]
	for i in range(3):
		l[i] *= i + 1
	print(sum(l) % 2)


import os
import sys
from io import BytesIO, IOBase
_str = str
str = lambda x=b'': x if type(x) is bytes else _str(x).encode()
BUFSIZE = 8192

def sigma1(a):
	return sum(a)

def sigma2(a):
	return sum([i * i for i in a])

def sigma3(a):
	return sum([i * i * i for i in a])

def prodofpairs(a):
	return (sigma1(a) ** 2 - sigma2(a)) // 2

def prodoftriplets(a):
	return (sigma1(a) ** 3 - 3 * sigma1(a) * sigma2(a) + 2 * sigma3(a)) // 6
from collections import Counter, defaultdict
from math import gcd
from collections import deque

def bfs(graph, start=0):
	used = [False] * len(graph)
	used[start] = True
	q = [start]
	for v in q:
		for w in graph[v]:
			if not used[w]:
				used[w] = True
				q.append(w)

def layers(graph, start=0):
	used = [False] * len(graph)
	used[start] = True
	(q, ret) = ([start], [])
	level = [0] * len(graph)
	while q:
		nq = []
		ret.append(q)
		for v in q:
			for w in graph[v]:
				if not used[w]:
					used[w] = True
					nq.append(w)
					level[w] = 1 + level[v]
		q = nq
	return level
import math

def findMaxGCD(arr, n, k):
	high = max(arr)
	divisors = [0] * (high + 1)
	for i in range(n):
		for j in range(1, int(math.sqrt(arr[i])) + 1):
			if arr[i] % j == 0:
				divisors[j] += 1
				if j != arr[i] // j:
					divisors[arr[i] // j] += 1
	for i in range(high, 0, -1):
		if divisors[i] >= k:
			return i

def xdist(a, b):
	if b[0] >= a[0] >= b[2] or b[0] <= a[0] <= b[2]:
		return 0
	return min(abs(a[0] - b[0]), abs(a[0] - b[2]))

def ydist(a, b):
	if b[1] >= a[1] >= b[3] or b[1] <= a[1] <= b[3]:
		return 0
	return min(abs(a[1] - b[1]), abs(a[1] - b[3]))

def countdistx(i, j, k, obj):
	m = 0
	for i1 in range(k):
		m += xdist([i, j], obj[i1])
	return m

def countdisty(i, j, k, obj):
	m = 0
	for i1 in range(k):
		m += ydist([i, j], obj[i1])
	return m
from bisect import bisect_left

def dp(i, n, cost, a):
	if cost == 0:
		return 0
	if cost < 0:
		return float('Inf')
	l = [float('Inf')]
	for j in range(i, n + 1):
		k = bisect_left(a, a[j] + cost, j)
		if k <= n and a[k] == a[j] + cost:
			l.append(k - j)
	return min(l)

def isp(x):
	for i in range(2, int(math.sqrt(x)) + 1):
		if x % i == 0:
			return False
	return True
from bisect import bisect_right
from sys import stdout

def main():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		if (a + 2 * b + 3 * c) % 2 == 0:
			print(0)
		else:
			print(1)
main()

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')


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


for _ in range(int(input())):
	(a, b, c) = [int(x) for x in input().split()]
	t = a + b * 2 + c * 3
	r = min(t // 6, c)
	rem = t // 2 - r * 3
	q = min(rem // 2, b)
	rem = rem - q * 2
	p = min(rem, a)
	print(abs(2 * (p + 2 * q + 3 * r) - t))


t = int(input())
for _ in range(t):
	(a, b, c) = list(map(int, input().split()))
	s = a * 1 + b * 2 + c * 3
	if s % 2 == 0:
		print(0)
	elif s % 2 == 1:
		if a:
			print(1)
		elif b:
			print(2)
		else:
			print(3)


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')
from collections import Counter, defaultdict
import math
import heapq
import bisect

def nck(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - i + 1) // i
	return res
for _ in range(int(input())):
	(one, two, three) = map(int, input().split())
	if one == two and two == three:
		print(0)
	else:
		one += 2 * two
		one += 3 * three
		avg = one // 2
		lefty = one - avg
		print(abs(lefty - avg))


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b and b == c:
		print(0)
	else:
		t = a * 1 + b * 2 + c * 3
		avgg = int(t / 2)
		remt = int(t - avgg)
		print(int(abs(remt - avgg)))


import math
t = int(input())
for tc in range(t):
	(a, b, c) = map(int, input().split())
	if (a * 1 + b * 2 + c * 3) % 2 == 0:
		print(0)
	else:
		print(1)


import math

def intlist():
	return [int(i) for i in input().split(' ')]

def stringlsit():
	return input().split(' ')

def yes(t):
	if t:
		return 'YES'
	return 'NO'

def printjoin(l):
	l = [str(i) for i in l]
	return ' '.join(l)

def solve():
	(a, b, c) = intlist()
	return (a + b * 2 + c * 3) % 2
t = input()
for tt in range(int(t)):
	print(solve())


def solution(a, b, c):
	new_c = c % 2
	new_a = a % 2
	new_b = b % 2
	if new_c > 0:
		if new_b > 0:
			if new_a > 0:
				return 0
			else:
				return 1
		elif new_a > 0:
			return 2
		else:
			return 3
	elif new_b > 0:
		if new_a > 0:
			return 1
		else:
			return 2
	elif new_a > 0:
		return 1
	else:
		return 0
t = int(input())
ans = []
for i in range(t):
	(a, b, c) = map(int, input().split())
	ans.append(solution(a, b, c) % 2)
for i in ans:
	print(i)


def calc(mult, count, k1, k2):
	diffCount = (abs(k2 - k1) // mult + 1) * mult
	diff = (abs(k2 - k1) // mult + 1) * mult
	k1 += (count - diffCount) // 2
	k2 += (count - diffCount) // 2
	if k1 < k2:
		k1 += diff
		k2 += (count - diffCount) % 2 * mult
	else:
		k2 += diff
		k1 += (count - diffCount) % 2 * mult
	return (k1, k2)
t = int(input())
res = []
for index in range(t):
	a = list(map(int, input().split()))
	(k1, k2) = (0, 0)
	for i in range(3):
		(k1, k2) = calc(3 - i, a[i], k1, k2)
	res.append(abs(k1 - k2))
for index in range(t):
	print(res[index])


def main():
	import sys
	input = sys.stdin.readline
	M = int(1000000000.0 + 7)
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		if (a + c) % 2 == 0:
			print(0)
		else:
			print(1)
main()


import sys, os, io
import math
from collections import defaultdict

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

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	(a, b, c) = li()
	x = a + 2 * b + 3 * c
	print(x % 2)
t = 1
t = ii()
for _ in range(t):
	solve()


for _ in range(int(input())):
	(m1, m2, m3) = map(int, input().split())
	rem = 3 * (m3 % 2)
	if rem == 0:
		rem = 2 * (m2 % 2)
	elif m2 != 0:
		rem -= 2
		m2 -= 1
	d = min(m1, rem)
	m1 -= d
	rem -= d
	rem += m1 % 2
	print(rem)


n = int(input())
for i in range(n):
	line = input().split()
	a = int(line[0])
	b = int(line[1])
	c = int(line[2])
	c = c % 2
	s = 0
	if c == 1:
		s = (a - 1) % 2
	else:
		s = a % 2
	print(s)


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	(a, b, c) = rns()
	print(sum([a, 2 * b, 3 * c]) % 2)


def minimalDifferenceBetweenConcerts(a, b, c):
	_sum = 1 * a + 2 * b + 3 * c
	if _sum % 2 == 0:
		return 0
	else:
		return 1
N = int(input())
for _ in range(N):
	(a, b, c) = list(map(int, input().split(' ')))
	result = minimalDifferenceBetweenConcerts(a, b, c)
	print(result)


import sys
inp = sys.stdin.readline

def solve():
	(a, b, c) = map(int, inp().split())
	d = [0, 0, 0]
	e = [0, 0, 0]
	s = a + b * 2 + c * 3
	x = s // 2
	left = x
	w = min(left // 3, c)
	left -= w * 3
	d[2] = w
	e[2] = c - w
	w = min(left // 2, b)
	left -= w * 2
	d[1] = w
	e[1] = b - w
	w = min(left, a)
	left -= w
	d[0] = w
	e[0] = a - w
	z = abs(d[0] + d[1] * 2 + d[2] * 3 - (e[0] + e[1] * 2 + e[2] * 3))
	if z == 2:
		if d[2] > 0 and e[1] > 1:
			d[2] -= 1
			e[2] += 1
			e[1] -= 2
			d[1] += 2
	z = abs(d[0] + d[1] * 2 + d[2] * 3 - (e[0] + e[1] * 2 + e[2] * 3))
	print(z)

def main():
	for i in range(int(inp())):
		solve()
main()


t = int(input(''))
for i in range(t):
	numbers = list(map(int, input('').split(' ')))
	if (numbers[0] + numbers[1] * 2 + numbers[2] * 3) % 2 == 0:
		print(0)
	else:
		print(1)


def comp(a, b, c):
	s = a + 2 * b + 3 * c
	even = False
	evenv = 1
	if s % 2 == 0:
		even = True
		evenv = 0
	if b == 0:
		if c % 2 == 0:
			return evenv
		else:
			return max(evenv, 3 - a)
	elif b == 1:
		if c % 2 == 1:
			return evenv
		else:
			return max(evenv, 2 - a)
	elif c == 0:
		if b % 2 == 0:
			return evenv
		else:
			return max(evenv, 2 - a)
	else:
		return evenv
T = int(input())
for testcase in range(1, T + 1):
	(a, b, c) = list(map(int, input().split()))
	print(comp(a, b, c))


n = int(input())
for _ in range(n):
	bits = input().strip().split()
	a = int(bits[0])
	b = int(bits[1])
	c = int(bits[2])
	s = a + 2 * b + 3 * c
	if s % 2 == 0:
		print(0)
	else:
		print(1)


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

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

def getliststr():
	return list(stdin.readline().split())

def getint():
	return int(stdin.readline().strip())

def getstr():
	return stdin.readline().strip()

def pr(s):
	stdout.write(str(s) + '\n')

def prlist(l):
	stdout.write(' '.join(list(map(str, l))) + '\n')
from sys import stdin, stdout
for _ in range(getint()):
	(a, b, c) = getmapint()
	pr((a + 2 * b + 3 * c) % 2)


t = int(input())
cases = []
for i in range(t):
	(a, b, c) = map(int, input().split())
	cases.append((a, b, c))
for (a, b, c) in cases:
	target = a + b * 2 + c * 3
	one = target // 2
	need_three = one // 3
	if need_three <= c:
		one -= 3 * need_three
	else:
		one -= c * 3
	need_two = one // 2
	if need_two <= b:
		one -= 2 * need_two
	else:
		one -= b * 2
	one -= min(a, one)
	if target % 2 != 0:
		one += 1
	print(one)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	t1 = a + b * 2
	t2 = c * 3
	if (a + b * 2 + c * 3) % 2 == 0:
		print('0')
	else:
		print((a + b * 2 + c * 3) % 2)


w = int(input())
l = []
p = [[1, 1, 1], [1, 2, 1], [2, 1, 1], [1, 1, 2], [2, 2, 1], [1, 2, 2], [2, 1, 2], [2, 2, 2]]
ans = [0, 0, 1, 1, 1, 1, 0, 0]
for i in range(w):
	t = list(map(int, input().split()))
	l.append(t)
for i in l:
	for j in range(len(i)):
		if i[j] % 2 == 0:
			i[j] = 2
		else:
			i[j] = 1
	print(ans[p.index(i)])


n = int(input())
for _ in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	if (a + 2 * b + 3 * c) % 2 == 0:
		print(0)
	else:
		print(1)


w = int(input())
i = 0
while i < w:
	b = input().split(' ')
	c = int(b[0])
	d = int(b[1]) * 2
	e = int(b[2]) * 3
	if (c + d + e) % 2 == 0:
		print(0)
	else:
		print(1)
	i = i + 1


import collections as cc
import bisect as bi
import itertools
import math as mt
import sys
q = lambda x: print('?', *x, flush=True)
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(a, b, c) = I()
	if (a * 1 + b * 2 + c * 3) % 2 == 0:
		print(0)
	else:
		print(1)


for i in range(int(input())):
	l = list(map(int, input().split()))
	L = l[0] + l[1] * 2 + l[2] * 3
	if L % 2 == 0:
		print(0)
	else:
		print(1)


from sys import stdin

def read_input():
	(a, b, c) = map(int, stdin.readline().split())
	return (a, b, c)

def solve(a, b, c):
	if c % 2 == 0:
		if (a + 2 * b) % 2 == 1:
			answer = 1
		elif a == 0 and b == 1:
			answer = 2
		else:
			answer = 0
	elif a == 0 and b == 0:
		answer = 3
	elif a == 1 and b == 0:
		answer = 2
	elif (a + 2 * b) % 2 == 1:
		answer = 0
	else:
		answer = 1
	return answer

def main():
	t = int(stdin.readline())
	for _ in range(t):
		input = read_input()
		answer = solve(*input)
		print(answer)
main()