CodechefMay 20, 2025

Chefland Games

Hazrat Ali

Codechef

Each referee has to point out whether he considers the ball to be inside limits or outside limits. The ball is considered to be IN if and only if all the referees agree that it was inside limits.

Given the decision of the 44 referees, help Chef determine whether the ball is considered inside limits or not.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • Each test case consists of a single line of input containing 44 integers R1,R2,R3,R4R1,R2,R3,R4 denoting the decision of the respective referees.

Here RR can be either 00 or 11 where 00 would denote that the referee considered the ball to be inside limits whereas 11 denotes that they consider it to be outside limits.

Output Format

For each test case, output IN if the ball is considered to be inside limits by all referees and OUT otherwise.

The checker is case-insensitive so answers like inIn, and IN would be considered the same.

Constraints

  • 1≤T≤20
  • 0≤R1,R2,R3,R4≤1

Sample 1:

Input
 
4
1 1 0 0
0 0 0 0
0 0 0 1
1 1 1 1
 
 
Output
OUT
IN
OUT
OUT

Solution
for _ in range(int(input())):
    r1,r2,r3,r4 = map(int, input().split(' '))
   
    if r1 == 1 or r2 == 1 or r3==1 or r4 == 1:
        print("OUT")
    else:
        print('IN')
       


 

Comments