Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

In Olympics, the countries are ranked by the total number of medals won. You are given six integers G_{1}, S_{1}, B_{1}, and G_{2}, S_{2}, B_{2}, the number of gold, silver and bronze medals won by two different countries respectively. Determine which country is ranked better on the leaderboard.  It is guaranteed that there will not be a tie between the two countries.

------ Input Format ------ 

- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.

- The first and only line of each test case contains six space-separated integers G_{1}, S_{1}, B_{1}, and G_{2}, S_{2}, B_{2}.

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

For each test case, print "1" if the first country is ranked better or "2" otherwise. Output the answer without quotes.

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

$1 ≤ T ≤ 1000$
$0 ≤ G_{1}, S_{1}, B_{1}, G_{2}, S_{2}, B_{2} ≤ 30$

------ subtasks ------ 

Subtask #1 (100 points): Original constraints

----- Sample Input 1 ------ 
3
10 20 30 0 29 30
0 0 0 0 0 1
1 1 1 0 0 0

----- Sample Output 1 ------ 
1
2
1
----- explanation 1 ------ 
Test case $1$: Total medals for the first country are $10 + 20 + 30 = 60$ and that for the second country are $0 + 29 + 30 = 59$. So the first country is ranked better than the second country.

Test case $2$: Total medals for the first country are $0 + 0 + 0 = 0$ and that for the second country are $0 + 0 + 1 = 1$. So the second country is ranked better than the first country.

Difficulty: EASY
Tags: Complete search

Implementation

Ad-hoc
Skill types: Complete search

Starter code:

Solutions:
t = int(input())
for j in range(t):
	l = list((int(x) for x in input().split()))
	a = 0
	b = 0
	for i in range(6):
		if i < 3:
			a = a + l[i]
		else:
			b = b + l[i]
	if a > b:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	s = list(map(int, input().split()))
	t1 = sum(s[:3])
	t2 = sum(s[3:])
	if t1 > t2:
		print('1')
	else:
		print('2')


for i in range(int(input())):
	(a, b, c, d, e, f) = map(int, input().split())
	k = a + b + c
	l = d + e + f
	if k > l:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	(g1, s1, b1, g2, s2, b2) = map(int, input().split())
	a1 = g1 + s1 + b1
	a2 = g2 + b2 + s2
	if a1 > a2:
		print(1)
	else:
		print(2)


T = int(input())
for i in range(T):
	(G1, S1, B1, G2, S2, B2) = map(int, input().split())
	if G1 + S1 + B1 > G2 + S2 + B2:
		print('1')
	else:
		print('2')


for i in range(0, int(input())):
	(a, b, c, x, y, z) = map(int, input().split())
	s = a + b + c
	t = z + y + x
	if s > t:
		print('1')
	elif s < t:
		print('2')


t = int(input())
for i in range(t):
	(a, b, c, x, y, z) = map(int, input().split())
	d = a + b + c
	e = x + y + z
	if a + b + c > x + y + z:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	lst = list(map(int, input().split()))
	l = lst[0] + lst[1] + lst[2]
	o = lst[3] + lst[4] + lst[5]
	if l > o:
		print('1')
	else:
		print('2')


T = int(input())
for i in range(T):
	arr = list(map(int, input().split()))
	if sum(arr[:3]) > sum(arr[3:]):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(g1, s1, b1, g2, s2, b2) = map(int, input().split())
	if g1 + s1 + b1 > g2 + s2 + b2:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	(x1, y1, z1, x2, y2, z2) = map(int, input().split(' '))
	if x1 + y1 + z1 > x2 + y2 + z2:
		print(1)
	else:
		print(2)


n = int(input())
for i in range(n):
	(g1, s1, b1, g2, s2, b2) = list(map(int, input().split()))
	if g1 + s1 + b1 > g2 + s2 + b2:
		print('1')
	else:
		print('2')


for i in range(int(input())):
	(a, b, c, x, y, z) = map(int, input().split())
	p = a + b + c
	q = x + y + z
	if p > q:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(g1, s1, b1, g2, s2, b2) = map(int, input().split())
	r1 = g1 + s1 + b1
	r2 = g2 + s2 + b2
	if r2 < r1:
		print(1)
	else:
		print(2)


T = int(input())
for _ in range(T):
	(G1, S1, B1, G2, S2, B2) = map(int, input().split())
	sum1 = G1 + S1 + B1
	sum2 = G2 + S2 + B2
	if sum1 > sum2:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(g1, s1, b1, g2, s2, b2) = map(int, input().split())
	if g1 + b1 + s1 > g2 + b2 + s2:
		print('1')
	elif g1 + b1 + s1 < g2 + b2 + s2:
		print('2')


t = int(input())
for i in range(t):
	(a1, b1, c1, a2, b2, c2) = map(int, input().split())
	if a1 + b1 + c1 < a2 + b2 + c2:
		print('2')
	else:
		print('1')


for _ in range(int(input())):
	(g, s, b, G, S, B) = map(int, input().split())
	if g + s + b > G + S + B:
		print('1')
	else:
		print('2')


def code():
	cases = int(input())
	for _ in range(cases):
		(g1, s1, b1, g2, s2, b2) = map(int, input().split(' '))
		team_1_medals = g1 + s1 + b1
		team_2_medals = g2 + s2 + b2
		if team_1_medals > team_2_medals:
			print('1')
		else:
			print('2')
code()


for _ in range(int(input())):
	(a, b, c, d, e, f) = map(int, input().split())
	if a + b + c > d + e + f:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	(a, b, c, d, e, f) = map(int, input().split())
	x = a + b + c
	y = d + e + f
	if x > y:
		print('1')
	elif x < y:
		print('2')


for i in range(int(input())):
	(g1, s1, b1, g2, s2, b2) = map(int, input().split())
	Team1 = g1 + s1 + b1
	Team2 = g2 + s2 + b2
	if Team1 > Team2:
		print('1')
	else:
		print('2')


T = int(input())
for i in range(T):
	(g1, s1, b1, g2, s2, b2) = map(int, input().split())
	n1 = g1 + s1 + b1
	n2 = g2 + s2 + b2
	if n1 > n2:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	(n, k, x, y, z, a) = map(int, input().split())
	if n + k + x > y + z + a:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = sum(a[:3])
	c = sum(a[3:])
	if b > c:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	(x1, x2, x3, y1, y2, y3) = map(int, input().split())
	if x1 + x2 + x3 > y1 + y2 + y3:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	(g1, s1, b1, g2, s2, b2) = [int(i) for i in input().split()]
	c1 = g1 + s1 + b1
	c2 = g2 + s2 + b2
	if c1 > c2:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(g1, s1, b1, g2, s2, b2) = list(map(int, input().split()))
	a = g1 + s1 + b1
	b = g2 + s2 + b2
	if a > b:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	(g1, s1, b1, g2, s2, b2) = map(int, input().split(' '))
	s = g1 + b1 + s1
	d = g2 + b2 + s2
	if s > d:
		print('1')
	else:
		print('2')


for i in range(int(input())):
	(a1, a2, a3, b1, b2, b3) = map(int, input().split())
	if a1 + a2 + a3 > b1 + b2 + b3:
		print('1')
	else:
		print('2')


a = int(input())
for i in range(a):
	(m, n, o, p, q, r) = map(int, input().split())
	s = m + n + o
	t = p + q + r
	if s > t:
		print('1')
	else:
		print('2')


for i in range(int(input())):
	a = list(map(int, input().split()))
	if sum(a[0:3]) > sum(a[3:]):
		print('1')
	else:
		print('2')


for _ in range(int(input())):
	(a, b, c, x, y, z) = map(int, input().split())
	print(1) if a + b + c > x + y + z else print(2)


for _ in range(int(input())):
	(b, g, s, b1, g1, s1) = map(int, input().split())
	if b + g + s > b1 + g1 + s1:
		print('1')
	else:
		print('2')


n = int(input())
for i in range(n):
	(a, b, c, d, e, f) = map(int, input().split())
	x = a + b + c
	y = d + e + f
	if x > y:
		print(1)
	else:
		print(2)


n = int(input())
for i in range(n):
	c = 0
	d = 0
	l = list(map(int, input().split()))
	for j in range(0, len(l) // 2):
		c = c + l[j]
	for k in range(len(l) // 2, len(l)):
		d = d + l[k]
	if c > d:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	a = [int(i) for i in input().split()]
	if a[0] + a[1] + a[2] > a[3] + a[4] + a[5]:
		print(1)
	else:
		print(2)


class kishore:

	def first(self, t):
		for i in range(t):
			(g1, s1, b1, g2, s2, b2) = map(int, input().split())
			res1 = g1 + s1 + b1
			res2 = g2 + s2 + b2
			if res1 > res2:
				print('1')
			else:
				print('2')
t = int(input())
o = kishore()
o.first(t)


t = int(input())
for i in range(t):
	(a, b, c, d, e, f) = map(int, input().split())
	g = a + b + c
	h = d + e + f
	if g > h:
		print(1)
	else:
		print(2)