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. The Old Saint And Three Questions solution codechef
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 The Old Saint And Three Questions solution codechef
- First line will contain TT, 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 A1A1 A2A2 A3A3, representing the correct answers to the first, second, and third question respectively (00 for ‘No’, 11 for ‘Yes’).
- The second line of each test case consists of three space-separated integers B1B1 B2B2 B3B3, representing the response of the hero to the first, second, and third question respectively (00 for ‘No’, 11 for ‘Yes’).
For each test case, print “Pass” (without quotes) if the hero passes the old saint’s test, “Fail” (without quotes) otherwise.
Sample Input 1 The Old Saint And Three Questions solution codechef
2 1 0 1 1 1 0 0 0 0 1 1 1
Sample Output 1
- In the first test case, since the number of 1s1s (Yes) is 22, and the number of 0s0s (No) is 11 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 1s1s (Yes) is 00 among the correct answers but 33 among the hero’s responses. Similarly, the number of 0s0s 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.