Once upon a time, there was a hero and an old saint. And like in any story with a hero and an old saint, the old saint asked the hero — three questions! 

But here's the twist: each question was a binary question, which means that the answer to each must be either a 'Yes' or a 'No', not none, not both. Our hero, who was not so wise in the ways of science, answered them arbitrarily and just hoped he is correct. The old saint, being so old, does not remember which answers were correct. The only thing that he remembers is - how many of them were 'Yes', and how many of them were 'No'. Our hero will pass the test if the old saint cannot distinguish his responses from the set of correct answers i.e. if the number of 'Yes' and 'No' in the responses matches that in the correct answers, regardless of their order.

You are given the answers to each of the three questions, and the responses of the hero to the same. Find whether the hero will be able to pass the old saint's test. 

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

- First line will contain T, the number of test cases. The description of the test cases follow.
- The first line of each test case consists of three space-separated integers A_{1} A_{2} A_{3}, representing the correct answers to the first, second, and third question respectively (0 for 'No', 1 for 'Yes').
- The second line of each test case consists of three space-separated integers B_{1} B_{2} B_{3}, representing the response of the hero to the first, second, and third question respectively (0 for 'No', 1 for 'Yes').

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

For each test case, print "Pass" (without quotes) if the hero passes the old saint's test, "Fail" (without quotes) otherwise.

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

$1 ≤ T ≤ 64$
$0 ≤ A_{i}, B_{i} ≤ 1$

----- Sample Input 1 ------ 
2
1 0 1
1 1 0
0 0 0
1 1 1
----- Sample Output 1 ------ 
Pass
Fail
----- explanation 1 ------ 
- In the first test case, since the number of $1s$ (Yes) is $2$, and the number of $0s$ (No) is $1$ among both the correct answers and the hero's answers, the old saint will fail to distinguish. Hence, the hero passes the test.
- In the second test case, the number of $1s$ (Yes) is $0$ among the correct answers but $3$ among the hero's responses. Similarly, the number of $0s$ don't match. Therefore, the old saint will be able to call the differences between the correct answer and the hero's response. Hence, the hero fails the test.

Difficulty: EASY
Tags: Mathematics

Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
t = int(input())
while t > 0:
	x = input().split()
	p = input().split()
	xc = 0
	pc = 0
	for i in x:
		i = int(i)
		if i == 1:
			xc += 1
		else:
			continue
	for j in p:
		j = int(j)
		if j == 1:
			pc += 1
		else:
			continue
	if pc == xc:
		print('Pass')
	else:
		print('Fail')
	t -= 1


import collections
T = int(input())
for i in range(T):
	n1 = list(map(int, input().split()))
	n2 = list(map(int, input().split()))
	n3 = 0
	n4 = 0
	for i in n1:
		if i == 1:
			n3 += 1
	for j in n2:
		if j == 1:
			n4 += 1
	if n3 == n4:
		print('Pass')
	else:
		print('Fail')


n = int(input())
for _ in range(n):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if A.count(1) == B.count(1):
		print('Pass')
	else:
		print('Fail')


n = int(input())
for _ in range(n):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans_A = 0
	ans_B = 0
	for ans in A:
		if ans == 1:
			ans_A += 1
	for ans in B:
		if ans == 1:
			ans_B += 1
	if ans_A == ans_B:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = a.count(1)
	y = b.count(1)
	if x == y:
		print('Pass')
	else:
		print('Fail')


for _testcase in range(int(input())):
	(a, b, c) = map(int, input().split())
	(d, e, f) = map(int, input().split())
	if a + b + c == d + e + f:
		print('Pass')
	else:
		print('Fail')


T = int(input())
for i in range(T):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	countOfA1 = A.count(1)
	countOfB1 = B.count(1)
	if countOfA1 == countOfB1:
		print('Pass')
	else:
		print('Fail')


T = int(input())
for i in range(T):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	countOfA1 = A.count(1)
	countOfA0 = A.count(0)
	countOfB1 = B.count(1)
	countOfB0 = B.count(0)
	if countOfA1 == countOfB1 and countOfA0 == countOfB0:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for _ in range(t):
	(a1, a2, a3) = map(int, input().split())
	(b1, b2, b3) = map(int, input().split())
	lst_a = []
	lst_b = []
	lst_a.append(a1)
	lst_a.append(a2)
	lst_a.append(a3)
	lst_b.append(b1)
	lst_b.append(b2)
	lst_b.append(b3)
	c_a_1 = lst_a.count(1)
	c_a_0 = lst_a.count(0)
	c_b_1 = lst_b.count(1)
	c_b_0 = lst_b.count(0)
	if c_a_1 == c_b_1 and c_a_0 == c_b_0:
		print('Pass')
	else:
		print('Fail')


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


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


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print('Pass') if a.count(1) == b.count(1) else print('Fail')


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	(x, y, z) = map(int, input().split())
	p = a + b + c
	q = x + y + z
	if p == q:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	actual_ans = list(map(int, input().split(' ')))
	hero_ans = list(map(int, input().split(' ')))
	sum1 = 0
	for i in actual_ans:
		sum1 = sum1 + i
	sum2 = 0
	for j in hero_ans:
		sum2 = sum2 + j
	if sum1 == sum2:
		print('Pass')
	else:
		print('Fail')


for _ in range(int(input())):
	saint = list(map(int, input().split()))
	hero = list(map(int, input().split()))
	saint.sort()
	hero.sort()
	if saint == hero:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	(a1, a2, a3) = map(int, input().split())
	(b1, b2, b3) = map(int, input().split())
	c = 0
	d = 0
	if a1 == 1:
		c = c + 1
	if a2 == 1:
		c = c + 1
	if a3 == 1:
		c = c + 1
	if b1 == 1:
		d = d + 1
	if b2 == 1:
		d = d + 1
	if b3 == 1:
		d = d + 1
	if c == d:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	a1 = x.count(1)
	a2 = x.count(0)
	b1 = y.count(1)
	b2 = y.count(0)
	if a1 == b1 and a2 == b2:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	if b.count(1) == c.count(1):
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	(A1, A2, A3) = map(int, input().split())
	(B1, B2, B3) = map(int, input().split())
	if A1 + A2 + A3 == B1 + B2 + B3:
		print('Pass')
	else:
		print('Fail')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print('Pass') if sum(a) == sum(b) else print('Fail')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) == sum(b):
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	b = [int(b) for b in input().split()]
	c = [int(c) for c in input().split()]
	count_b = b.count(1)
	count_c = c.count(1)
	if count_b == count_c:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	(a1, a2, a3) = [int(x) for x in input().split()]
	(b1, b2, b3) = [int(y) for y in input().split()]
	count1 = 0
	for i in (a1, a2, a3):
		if i == 1:
			count1 = count1 + 1
		else:
			count1
	count2 = 0
	for j in (b1, b2, b3):
		if j == 1:
			count2 = count2 + 1
		else:
			count2
	if count1 == count2:
		print('Pass')
	else:
		print('Fail')


for tc in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a0 = a.count(0)
	a1 = a.count(1)
	b0 = b.count(0)
	b1 = b.count(1)
	if a1 == b1:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	if A == B:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for _ in range(t):
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if l1.count(1) == l2.count(1):
		print('Pass')
	else:
		print('Fail')


for i in range(0, int(input())):
	(a1, a2, a3) = map(int, input().split())
	(b1, b2, b3) = map(int, input().split())
	a = [a1, a2, a3]
	b = [b1, b2, b3]
	c = 0
	c1 = 0
	c2 = 0
	c3 = 0
	for j in a:
		if j == 1:
			c = c + 1
		else:
			c1 = c1 + 1
	for k in b:
		if k == 1:
			c2 = c2 + 1
		else:
			c3 = c3 + 1
	if c == c2 and c1 == c3:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	(a, b, c) = map(lambda x: int(x), input().split())
	(d, e, f) = map(lambda x: int(x), input().split())
	if a + b + c == d + e + f:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if l1.count(1) == l2.count(1) and l1.count(0) == l2.count(0):
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	(x, y, z) = map(int, input().split())
	count = 0
	coint = 0
	if a == 1:
		count += 1
	if b == 1:
		count += 1
	if c == 1:
		count += 1
	if x == 1:
		coint += 1
	if y == 1:
		coint += 1
	if z == 1:
		coint += 1
	if coint == count:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	correct = list(map(int, input().split()))
	answers = list(map(int, input().split()))
	correct_no = correct.count(0)
	answers_no = answers.count(0)
	print('Pass') if correct_no == answers_no else print('Fail')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	d = 0
	for j in range(3):
		if a[j] == 1:
			c += 1
		if b[j] == 1:
			d += 1
	if c == d:
		print('Pass')
	else:
		print('Fail')


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split(' '))
	(x, y, z) = map(int, input().split(' '))
	k = [a, b, c]
	l = [x, y, z]
	m = 0
	n = 0
	for i in k:
		if i == 0:
			m += 1
		else:
			n += 1
	for j in l:
		if j == 0:
			m -= 1
		else:
			n -= 1
	if m == 0 and n == 0:
		print('Pass')
	else:
		print('Fail')


a = int(input())
for i in range(a):
	(p, q, r) = map(int, input().split())
	(p1, q1, r1) = map(int, input().split())
	if p + q + r == p1 + q1 + r1:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for z in range(t):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	print('Pass' if A.count(1) == B.count(1) else 'Fail')


t = int(input())
for _ in range(t):
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	count1 = 0
	count2 = 0
	for i in range(len(arr1)):
		if arr1[i] == 0:
			count1 += 1
	for j in range(len(arr2)):
		if arr2[j] == 0:
			count2 += 1
	if count1 == count2:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a.count(0) == b.count(0):
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(0, t):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = a.count(1)
	y = a.count(0)
	p = b.count(1)
	q = b.count(0)
	if x == p and y == q:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	a = lst1.count(1)
	b = lst2.count(1)
	if a == b:
		print('Pass')
	else:
		print('Fail')


a = int(input())
for i in range(a):
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	zeros = x.count(0)
	ones = x.count(1)
	zeros_ = y.count(0)
	ones_ = y.count(1)
	if zeros == zeros_ and ones == ones_:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	s1 = input()
	s2 = input()
	if s1.count('0') == s2.count('0'):
		print('Pass')
	else:
		print('Fail')


T = int(input())
for i in range(T):
	A = input().split()
	A1 = int(A[0])
	A2 = int(A[1])
	A3 = int(A[2])
	B = input().split()
	B1 = int(B[0])
	B2 = int(B[1])
	B3 = int(B[2])
	count1 = count2 = 0
	if A1 == 0:
		count1 = count1 + 1
	if A3 == 0:
		count1 = count1 + 1
	if A2 == 0:
		count1 = count1 + 1
	if B1 == 0:
		count2 = count2 + 1
	if B2 == 0:
		count2 = count2 + 1
	if B3 == 0:
		count2 = count2 + 1
	if count2 == count1:
		print('Pass')
	else:
		print('Fail')


for _ in range(int(input())):
	s = input()
	y = input()
	x = s.count('1')
	z = y.count('1')
	if x == z:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(0, t):
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = 0
	d = 0
	c1 = 0
	d1 = 0
	for i in a:
		if i == 0:
			c += 1
		else:
			d += 1
	for j in b:
		if j == 0:
			c1 += 1
		else:
			d1 = d1 + 1
	if c == c1 and d == d1:
		print('Pass')
	else:
		print('Fail')


t = int(input())
for i in range(t):
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	p = 0
	q = 0
	r = 0
	s = 0
	for j in x:
		if j == 0:
			p += 1
		else:
			q += 1
	for k in y:
		if k == 0:
			r += 1
		else:
			s += 1
	if p == r:
		print('Pass')
	else:
		print('Fail')


T = int(input())
for t in range(T):
	saint = (s1, s2, s3) = [int(x) for x in input().split()]
	hero = (h1, h2, h3) = [int(x) for x in input().split()]
	s = []
	h = []
	for i in saint:
		s.append(i)
	s_one = s.count(1)
	s_zero = s.count(0)
	for j in hero:
		h.append(j)
	h_one = h.count(1)
	h_zero = h.count(0)
	if s_one == h_one and s_zero == h_zero:
		print('Pass')
	else:
		print('Fail')


for _ in range(int(input())):
	ali = list(map(int, input().split()))
	hli = list(map(int, input().split()))
	if ali.count(0) == hli.count(0) and ali.count(1) == hli.count(1):
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	(n, x, y) = map(int, input().split())
	(a, b, c) = map(int, input().split())
	if n + x + y == a + b + c:
		print('Pass')
	else:
		print('Fail')


t = int(input())
while t > 0:
	(count1, count2) = (0, 0)
	(a, b, c) = map(eval, input().split())
	(x, y, z) = map(eval, input().split())
	list1 = [a, b, c]
	list2 = [x, y, z]
	count1 = list1.count(1)
	count2 = list2.count(1)
	if count1 == count2:
		print('Pass')
	else:
		print('Fail')
	t = t - 1


Test = int(input())
for TestCases in range(Test):
	CorrectAnswers = map(int, input().split())
	ResponseAnswers = map(int, input().split())
	CorrectYesCount = 0
	ResponseYesCount = 0
	for Answers in CorrectAnswers:
		if Answers == 1:
			CorrectYesCount += 1
		else:
			pass
	for Response in ResponseAnswers:
		if Response == 1:
			ResponseYesCount += 1
	if ResponseYesCount == CorrectYesCount:
		print('Pass')
	else:
		print('Fail')


T = int(input())
for i in range(T):
	ones_in_crct_ans = 0
	zeros_in_crct_ans = 0
	ones_heros_ans = 0
	zeros_heros_ans = 0
	crct_ans = input().split()
	heors_ans = input().split()
	for i in crct_ans:
		if i == '1':
			ones_in_crct_ans += 1
	for i in heors_ans:
		if i == '1':
			ones_heros_ans += 1
	if ones_heros_ans == ones_in_crct_ans:
		print('Pass')
	else:
		print('Fail')


T = int(input())
for i in range(T):
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	ones_needed = 0
	zeroes_needed = 0
	actual_ones = 0
	actual_zeroes = 0
	for i in list1:
		if i == 1:
			ones_needed += 1
		else:
			zeroes_needed += 1
	for i in list2:
		if i == 1:
			actual_ones += 1
		else:
			actual_zeroes += 1
	if ones_needed == actual_ones and zeroes_needed == actual_zeroes:
		print('Pass')
	else:
		print('Fail')


for i in range(int(input())):
	answer = list(map(int, input().split(' ')))
	guess = list(map(int, input().split(' ')))
	if answer.count(1) == guess.count(1):
		print('Pass')
	else:
		print('Fail')


for _ in range(int(input())):
	a = [i for i in input().split() if int(i) == 1]
	d = [j for j in input().split() if int(j) == 1]
	print('Pass') if len(a) == len(d) else print('Fail')


try:
	t = int(input())
	for r in range(t):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		count1 = a.count(1)
		count2 = b.count(1)
		if count1 == count2:
			print('Pass')
		else:
			print('Fail')
except:
	pass


T = int(input())
for tc in range(T):
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	l1 = arr1.count(0)
	l2 = arr2.count(0)
	if l1 != l2:
		print('Fail')
	else:
		print('Pass')


for i in range(int(input())):
	s = list(map(int, input().split()))
	h = list(map(int, input().split()))
	if sum(s) == sum(h):
		print('Pass')
	else:
		print('Fail')


t = int(input())
for _ in range(t):
	x = list(map(int, input().split()))
	z = list(map(int, input().split()))
	if x.count(1) == z.count(1):
		print('Pass')
	else:
		print('Fail')


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	(e, f, g) = map(int, input().split())
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	k = []
	k.append(e)
	k.append(f)
	k.append(g)
	x = l.count(1)
	y = k.count(1)
	if x == y:
		print('Pass')
	else:
		print('Fail')