Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

Solution (Python):
a = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]


for j in range(n):
    for p in range(3):
        for q in range(3):
            if(a[p][q] == b[j]):
                a[p][q] = 0

        '''
        try:
            pos = (y, row.index("G"))
            break
        except ValueError:
            pass
        '''
if (a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0):
    print("Yes")
elif(a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0):
    print("Yes")
elif(a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0):
    print("Yes")
elif(a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0):
    print("Yes")
elif(a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0):
    print("Yes")
elif(a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0):
    print("Yes")
elif(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
    print("Yes")
elif(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
A=[[],[],[]]
for i in range(3):
  A[i]=[int(_) for _ in input().split()]  
N=int(input())
b=[]
for i in range(N):
  b.append(int(input()))
import sys
for i in range(3):
  if (A[i][0] in b) and (A[i][1] in b) and (A[i][2] in b):
    print('Yes')
    sys.exit()
for i in range(3):
  if (A[0][i] in b) and (A[1][i] in b) and (A[2][i] in b):
    print('Yes')
    sys.exit()

if (A[0][0] in b) and (A[1][1] in b) and (A[2][2]in b) or \
      (A[2][0] in b) and (A[1][1] in b) and (A[2][0]in b):
  print('Yes')
  sys.exit()
print('No')

Solution (Python):
def main():
    bingo = [input().split(" ") for _ in range(3)]
    n = int(input())
    line = [[], [], []]
    v_line = [[], [], []]
    cross1 = []
    cross2 = []
    for _ in range(n):
        num = input()
        found = False
        for i in range(3):
            for j in range(3):
                if bingo[i][j] == num:
                    found = True
                    if i == j:
                        cross1.append((i, j))
                    if i == 0 and j == 2:
                        cross2.append((i, j))
                    if i == 2 and j == 0:
                        cross2.append((i, j))
                    if i == 1 and j == 1:
                        cross2.append((i, j))
                    line[i].append((i, j))
                    v_line[j].append((i, j))
                    continue
            if found:
                continue
    for l in line:
        if len(l) == 3:
            print("Yes")
            return
    for l in v_line:
        if len(l) == 3:
            print("Yes")
            return
    if len(cross1) == 3:
        print("Yes")
    elif len(cross2) == 3:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
import sys
Ar1 = list(map(int, input().split()))
Ar2 = list(map(int, input().split()))
Ar3 = list(map(int, input().split()))
N = int(input())
b = []

Ac1 = [Ar1[0], Ar2[0], Ar3[0]]
Ac2 = [Ar1[1], Ar2[1], Ar3[1]]
Ac3 = [Ar1[2], Ar2[2], Ar3[2]]

naname1 = [Ar1[0], Ar2[1], Ar3[2]]
naname2 = [Ar1[2], Ar2[1], Ar3[0]]

for i in range(N) :
  b.append(int(input()))

for lines in [Ar1, Ar2, Ar3, Ac1, Ac2, Ac3, naname1, naname2] :
  if lines[0] in b and lines[1] in b and lines[2] in b :
    print("Yes")
    sys.exit()
  else :
    next
    
print("No")

Solution (Python):
A = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())

N = int(input())
B = []

for i in range(N):
    B.append(int(input()))
     
for b in B:
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                A[i][j] = "x"
                
flag = False
            
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2]:
        flag = True
        break
    if A[0][i] == A[1][i] == A[2][i]:
        flag = True
        break
    
if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    flag = True
    
if flag == True:
    print("Yes")
else:
    print("No")

Solution (Python):
a=[0,0,0]
for i in range (3):
  a[i] = list(map(int,input().split()))
n = int(input())
for i in range(n):
  b = int(input())
  
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = 0

done = 0
for i in range(3):
  if (a[i][0] == a[i][1] == a[i][2] == 0 or a[0][i] == a[1][i] == a[2][i] == 0) and done == 0:
    done = 1
    print('Yes')

if done == 0 and (a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0) :
  print('Yes')
  done = 1

if done == 0:
  print('No')

Solution (Python):
import itertools

A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A = list(itertools.chain.from_iterable(A))
N = int(input())
for n in range(N):
    b = int(input())
    A = [0 if a == b else a for a in A]

if A[0] == A[1] == A[2] == 0:
    print("Yes")
elif A[3] == A[4] == A[5] == 0:
    print("Yes")
elif A[6] == A[7] == A[8] == 0:
    print("Yes")
elif A[0] == A[3] == A[6] == 0:
    print("Yes")
elif A[1] == A[4] == A[7] == 0:
    print("Yes")
elif A[2] == A[5] == A[8] == 0:
    print("Yes")
elif A[0] == A[4] == A[8] == 0:
    print("Yes")
elif A[2] == A[4] == A[6] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    bingo_arr = [
        A[0], A[1], A[2],
        [A[0][0], A[1][0], A[2][0]], [A[0][1], A[1][1], A[2][1]], [A[0][2], A[1][2], A[2][2]],
        [A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]
    ]
    for bingo in bingo_arr:
        cnt = 0
        for i in bingo:
            if i in b:
                cnt += 1
                if cnt == 3:
                    print(YES)
                    return
                continue
    print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):

table = [input().split() for l in range(3)]
N = int(input())
array = [input() for i in range(N)]
bingo = ""

for k in range(3):
    for j in range(3):
        if table[k][j] in array:
            table[k][j] = 0

        table[k][j] = int(table[k][j])

for l in range(3):
    if table[l][0] + table[l][1] + table[l][2] == 0:
        bingo = "Yes"

for l in range(3):
    if table[0][l] + table[1][l] + table[2][l] == 0:
        bingo = "Yes"

if table[0][0] + table[1][1] + table[2][2] == 0 or table[2][0] + table[1][1] + table[2][0] ==0:
        bingo = "Yes"

if bingo == "":
    bingo = "No"

print(bingo)

Solution (Python):
a = [ list(map(int,input().split())) for _ in range(3) ]
n = int(input())
b = [ int(input()) for _ in range(n) ]

import numpy as np
a = np.array(a)











for i in range(n):
    if b[i] in a:
        r = np.where(a==b[i])
        a[r[0][0],r[1][0]] = 0
    else:
        pass





if a[0,0]==0 and a[2,2]==0 and a[1,1]==0:
    print("Yes")
elif a[0,1]==0 and a[2,1]==0 and a[1,1]==0:
    print("Yes")
elif a[0,2]==0 and a[2,0]==0 and a[1,1]==0:
    print("Yes")
elif a[1,0]==0 and a[1,2]==0 and a[1,1]==0:
    print("Yes")
elif a[0,0]==0 and a[1,0]==0 and a[2,0]==0:
    print("Yes")
elif a[0,2]==0 and a[1,2]==0 and a[2,2]==0:
    print("Yes")
elif a[0,0]==0 and a[0,1]==0 and a[0,2]==0:
    print("Yes")
elif a[2,0]==0 and a[2,1]==0 and a[2,2]==0:
    print("Yes")
else:
    print("No")

Solution (Python):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
card = {
    0: {0: a11, 1: a12, 2: a13},
    1: {0: a21, 1: a22, 2: a23},
    2: {0: a31, 1: a32, 2: a33}
}
n = int(input())
marks = [[0,0,0], [0,0,0], [0,0,0]]
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if card[j][k] == b:
                marks[j][k] = 1
if sum(marks[0]) == 3:
    print("Yes")
elif sum(marks[1]) == 3:
    print("Yes")
elif sum(marks[2]) == 3:
    print("Yes")
elif sum([marks[0][0],marks[1][0],marks[2][0]]) == 3:
    print("Yes")
elif sum([marks[0][1],marks[1][1],marks[2][1]]) == 3:
    print("Yes")
elif sum([marks[0][2],marks[1][2],marks[2][2]]) == 3:
    print("Yes")
elif sum([marks[0][0],marks[1][1],marks[2][2]]) == 3:
    print("Yes")
elif sum([marks[2][0],marks[1][1],marks[0][2]]) == 3:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
lst = []
nums = []
for _ in range(3):
    l = []
    l = list(map(int, input().split()))
    lst.append(l)
    array = np.array(lst)
 
n = int(input())
for _ in range(n):
    nums.append(int(input()))

for h in range(3):
    for w in range(3):
        if array[h][w] in nums:
            array[h][w] = 0

i = 0
for h in range(3):
    if sum(array[:, h]) == 0:
        i = 1
for w in range(3):
    if sum(array[w]) == 0:
        i = 1
if sum(np.diag(np.fliplr(array))) == 0:
    i = 1
if sum(np.diag(array)) == 0:
    i = 1

if i == 1:
    print("Yes")
else:
    print('No')

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
  if b[i] in A1:
    if len(list(set(A1))) == 1:
      A1 = [0] * 3
    else:
      A1[A1.index(b[i])] = 0
  elif b[i] in A2:
    if len(list(set(A2))) == 1:
      A2 = [0] * 3
    else:
      A2[A2.index(b[i])] = 0
  elif b[i] in A3:
    if len(list(set(A3))) == 1:
      A3 = [0] * 3
    else:
      A3[A3.index(b[i])] = 0


if A1[0] == 0 and A1[0] == A2[0] == A3[0]:
  ans = "Yes"
elif A1[1] == 0 and A1[1] == A2[1] == A3[1]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[2] == A3[2]:
  ans = "Yes"
elif A1[0] == 0 and A1[0] == A2[1] == A3[2]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[1] == A3[0]:
  ans = "Yes"
elif A1 == [0] * 3 or A2 == [0] * 3 or A3 == [0] * 3:
  ans = "Yes"
else:
  ans = "No"

print(ans)

Solution (Python):
A = [None]*3
A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))
N = int(input())
B = [None]*N
for i in range(N):
    B[i] = int(input())

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B[i] == A[j][k]:
                A[j][k] = -1


S1 = 0
S2 = 0
for i in range(3):
    S1 += A[i][i]
    S2 += A[i][2-i]
if S1 == -3 or S2 == -3:
    print("Yes")
    quit()

for i in range(3):
    if sum(A[i]) == -3:
        print("Yes")
        break
    if A[0][i] + A[1][i] + A[2][i] ==-3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
l = [list(map(int, input().split())) for _ in range(3)]
l_ans = [[0, 0, 0] for _ in range(3)]
n = int(input())

for ans in range(n):
  ans = int(input())
  for i in range(3):
    for j in range(3):
      if l[i][j] == ans:
        l_ans[i][j] = 1

flag = 0
for i in l_ans:
  if sum(i) == 3:
    flag += 1

for i in range(3):
  temp = 0
  for j in range(3):
    temp += l_ans[j][i]
  if temp == 3:
    flag += 1

temp = 0
for i in range(3):
  temp += l_ans[i][i]
if temp == 3:
  flag += 1

temp = 0
for i in range(3):
  temp += l_ans[i][2 - i]
if temp == 3:
  flag += 1

if flag >= 1:
  print("Yes")
else:
  print("No")

Solution (Python):
mat = [list(map(int, input().split())) for _ in range(3)]
d = {}
for idx, i in enumerate(mat):
    for idx2, j in enumerate(i):
        d[j] = [idx, idx2]

n = int(input())
mat2 = [[0]*3 for _ in range(3)]

for _ in range(n):
    b = int(input())
    if d.get(b) is None:
        pass
    else:
        i, j = d.get(b)
        mat2[i][j] = 1
        if sum([mat2[i][di] for di in range(3)])== 3:
            print('Yes')
            exit()
        
        if sum([mat2[di][j] for di in range(3)])== 3:
            print('Yes')
            exit()
        
        if sum([mat2[di][di] for di in range(3)])==3:
            print('Yes')
            exit()
        
        if mat2[2][0] + mat2[1][1] + mat2[0][2] == 3:
            print('Yes')
            exit()

print('No')

Solution (Python):
dp = [[0]*3 for i in range(3)]
L = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
L = [a,b,c]
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

flag = 0 

for i in range(3):
    for j in range(3):
        if L[i][j] in l:
            dp[i][j] = 1

for i in range(3):
    if sum(dp[i]) ==3:
        flag = 1

for j in range(3):
    s = 0
    for i in range(3):
        s+= dp[i][j]
    if s == 3:
        flag = 1
s = 0
t = 0
for i in range(3):
    s+=  dp[i][i]
    t+= dp[i][2-i]
if s==3 or t == 3:
    flag = 1
    
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
a=[]
b=[]
nums=[]
ans="No"

for i in range(3):
    l=list(map(int,input().split()))
    a.append(l)

n=int(input())

for i in range(n):
    s=int(input())
    b.append(s)

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]=0
                num=10*(j+1)+k+1
                nums.append(num)

nums.sort()


if a[0][0]==a[0][1]==a[0][2]==0:
    ans="Yes"
if a[1][0]==a[1][1]==a[1][2]==0:
        ans="Yes"
if a[2][0]==a[2][1]==a[2][2]==0:
    ans="Yes"
if a[0][0]==a[1][0]==a[2][0]==0:
    ans="Yes"
if a[0][1]==a[1][1]==a[2][1]==0:
        ans="Yes"
if a[0][2]==a[1][2]==a[2][2]==0:
    ans="Yes"
        
if 11 in nums and 22 in nums and 33 in nums:
    ans="Yes"

if 13 in nums and 22 in nums and 31 in nums:
    ans="Yes"
    
print(ans)

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = A1 + A2 + A3

N = int(input())


for i in range(N):
    b = int(input())
    
    for index in range(len(A)):
        a = A[index]
        if a == b:
            A[index] = 0     

def isExistTatePair():
    for i in range(3):
        sum = 0
        for j in range(3):
            sum += A[3 * j + i]
        if sum == 0:
            return True
    return False

def isExistYokoPair():
    for i in range(3):
        sum = 0
        for j in range(3):
            sum += A[3 * i + j]
        if sum == 0:
            return True
    return False

def isExistNanamePair():
    sum = 0
    for i in range(3):
        sum += A[3 * i + i]
    if sum == 0:
        return True
    
    sum = 0
    for i in range(3):
        sum += A[3 * (i + 1) - (i + 1)]
    if sum == 0:
        return True
    return False

isExistPair = isExistTatePair() or isExistYokoPair() or isExistNanamePair()
print('Yes' if isExistPair else 'No')

Solution (Python):
A = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = -1

def solve():
    for a in A:
        if len(set(a)) == 1:
            return True
    for a in zip(*A):
        if len(set(a)) == 1:
            return True

    return len({A[0][0], A[1][1], A[2][2]}) == 1 or len({A[0][2], A[1][1], A[2][0]}) == 1

if solve():
    print("Yes")
else:
    print("No")

Solution (Python):






b=[[0,0,0],[0,0,0],[0,0,0]]

m={}
for i in range(3):
    t=list(map(int,input().split()))
    k=0
    for j in t:
        m[j]=(i,k)
        k+=1
n=int(input())
for i in range(n):
    t=int(input())
    if t in m:
        
        b[m[t][0]][m[t][1]]=1
for i in b:
    ans=1
    for j in i:
        ans*=j
    if ans==1:
        print('Yes')
        exit()
for i in range(3):
    ans=1
    for j in range(3):
        ans*=b[j][i]
    if ans==1:
        print('Yes')
        exit()
if b[0][0]*b[1][1]*b[2][2]==1:
    print('Yes')
    exit()
if b[0][2]*b[1][1]*b[2][0]==1:
    print('Yes')
    exit()
print('No')

Solution (Python):
import numpy as np
bingo=[]
for i in range(3):
    bingo.append(list(map(int,input().split())))
bingo=np.array(bingo)

n=int(input())
for i in range(n):
    a=int(input())
    bingo[bingo==a]=0

bin=False
for i in range(3):
    bin = bingo[i].sum()==0 or bin
    bin = bingo[:,i].sum()==0 or bin

bin = (bingo[0,0]+bingo[1,1]+bingo[2,2])==0 or bin
bin = (bingo[2,0]+bingo[1,1]+bingo[0,2])==0 or bin

if(bin):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
a1 = list(map(str,input().split()))
a2 = list(map(str,input().split()))
a3 = list(map(str,input().split()))
M=int(input())
N = "N"
if M <= 2:
    print('No')
    sys.exit()

Num=[] 
while True:
    try:
        Num.append(input())

    except:
        break;

A1= ["N" if Num.count(i)!=0 else i for i in a1]
A2= ["N" if Num.count(i)!=0 else i for i in a2]
A3= ["N" if Num.count(i)!=0 else i for i in a3]

if A1[0] == N and A1[1] == N and A1[2] == N :
    print("Yes")
elif A2[0] == N and A2[1] == N and A2[2] == N :
    print("Yes")
elif A3[0] == N and A3[1] == N and A3[2] == N :
    print("Yes")
elif A1[0] == N and A2[0] == N and A3[0] == N :
    print("Yes")
elif A1[1] == N and A2[1] == N and A3[2] == N :
    print("Yes")
elif A1[2] == N and A2[2] == N and A3[2] == N :
    print("Yes")
elif A1[0] == N and A2[1] == N and A3[2] == N :
    print("Yes")
elif A1[2] == N and A2[1] == N and A3[0] == N :
    print("Yes")
else:
    print("No")

Solution (Python):
def bingo(A, B):
  for i in range(3):
    if A[i][0] == "o" and A[i][1] == "o" and A[i][2] == "o":
      return True
    elif A[0][i] == "o" and A[1][i] == "o" and A[2][i] == "o":
      return True
    
  if A[0][0] == "o" and A[1][1] == "o" and A[2][2] == "o":
    return True
  elif A[0][2] == "o" and A[1][1] == "o" and A[2][0] == "o":
    return True
    
  return False

A = []
for i in range(3):
  A.append(list(map(int, input().split())))
           
N = int(input())
B = []
for i in range(N):
  B.append(int(input()))

for b in B:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = "o"

if bingo(A, B):
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np


def main():
    A0 = [int(x) for x in input().split()]
    A1 = [int(x) for x in input().split()]
    A2 = [int(x) for x in input().split()]
    A = [A0,A1,A2]

    Ainv = dict()
    for i in range(3):
        for j in range(3):
            Ainv[A[i][j]] = (i,j)

    N = int(input())
    rows = [0]*3
    cols = [0]*3
    cross = [0]*2
    for _ in range(N):
        b = int(input())
        if b not in Ainv:
            continue
        row, col = Ainv[b]
        rows[row]+=1
        cols[col]+=1
        if row==col:
            cross[0] += 1
        if row+col==2:
            cross[1] += 1
        if any([rows[row]==3, cols[col]==3, cross[0]==3, cross[1]==3]):
            print("Yes")
            return
    print("No")
    return



if __name__ == '__main__':
    main()

Solution (Python):
A = []
for _ in range(3):
  a,b,c = map(int,input().split())
  A.append([a,b,c])
B = [[1]*3 for i in range(3)]
N = int(input())
for _ in range(N):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == A[i][j]:
        B[i][j] = 0
Answer = 'No'
for i in range(3):
  if sum(B[0])*sum(B[1])*sum(B[2])==0:
    print('Yes')
    exit()
  if (B[0][0]+B[1][0]+B[2][0])*(B[0][1]+B[1][1]+B[2][1])*(B[0][2]+B[1][2]+B[2][2])==0:
    print('Yes')
    exit()
  if (B[0][0]+B[1][1]+B[2][2])*(B[2][0]+B[1][1]+B[0][2])==0:
    print('Yes')
    exit()
print(Answer)

Solution (Python):
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))

n=int(input())
B=[]
for i in range(n):
    b=int(input())
    B.append(b)
for i in range(3):
    if A1[i] in B:
        A1.remove(A1[i])
        A1.insert(i,1)
    else:
        A1.remove(A1[i])
        A1.insert(i,0)
for i in range(3):
    if A2[i] in B:
        A2.remove(A2[i])
        A2.insert(i,1)
    else:
        A2.remove(A2[i])
        A2.insert(i,0)
for i in range(3):
    if A3[i] in B:
        A3.remove(A3[i])
        A3.insert(i,1)
    else:
        A3.remove(A3[i])
        A3.insert(i,0)
A=[A1,A2,A3]
if A1[0]==A1[1]==A1[2]==1 or A2[0]==A2[1]==A2[2]==1 or \
A3[0]==A3[1]==A3[2]==1 or A1[0]==A2[0]==A3[0]==1 or A1[1]==A2[1]==A3[1]==1 or \
A1[2]==A2[2]==A3[2]==1 or A1[0]==A2[1]==A3[2]==1 or A1[2]==A2[1]==A3[0]==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans_flag = True
ans_flag2 = True
ans = [[False, False, False], [False, False, False], [False, False, False]]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            ans[i][j] = True

for i in range(3):
    if ans[0][i] and ans[1][i] and ans[2][i]:
        print('Yes')
        sys.exit()
    if ans[i][0] and ans[i][1] and ans[i][2]:
        print('Yes')
        sys.exit()
    if not ans[i][i]:
        ans_flag = False
    if not ans[i][2-i]:
        ans_flag2 = False

if ans_flag or ans_flag2:
    print('Yes')
else:
    print('No')

Solution (Python):
a1 = list(map(lambda x: int(x), input().split()))
a2 = list(map(lambda x: int(x), input().split()))
a3 = list(map(lambda x: int(x), input().split()))
card = [a1, a2, a3]

n = int(input())

number = []
for num in range(0, n):
  b = int(input())
  number.append(b)

def bingo(bingolist):
  x = 0
  for n in bingolist:
    if n in number:
      x += 1
  if x == 3:
    print("Yes")
    exit()

bingo(a1)
bingo(a2)
bingo(a3)
for num in range(0, 3):
	bingo([a1[num], a2[num], a3[num]])

bingo([a1[0], a2[1], a3[2]])
bingo([a1[2], a2[1], a3[0]])
print("No")

Solution (Python):

A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
for k in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                A[i][j] = True
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == True:
        print("Yes")
        exit()
    elif A[0][i] == A[1][i] == A[2][i] == True:
        print("Yes")
        exit()
if A[0][0] == A[1][1] == A[2][2] == True:
    print("Yes")
    exit()
if A[0][2] == A[1][1] == A[2][0] == True:
    print("Yes")
    exit()
print("No")

Solution (Python):
A = [[],[],[]]
A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))

complete = [[False, False, False] for i in range(3)]

N = int(input())
for i in range(N):
    val = int(input())

    for y in range(3):
        for x in range(3):
            if A[y][x] == val: complete[y][x] = True

bingo = False
for y in range(3):
    if all(complete[y]): bingo = True

for x in range(3):
    if (all(complete[i][x] for i in range(3))): bingo = True

if all(complete[i][i] for i in range(3)): bingo = True
if all(complete[i][3-i-1] for i in range(3)): bingo = True

if bingo:
    print("Yes")
else:
    print("No")

Solution (Python):
x=[list(map(str,input().split())) for _ in range(3)]
N=int(input())
B=[input() for _ in range(N)]
flag=0
for i in range(3):
  for j in range(3):
    if x[i][j] in B:
      x[i][j]=True

for p in range(3):
  if x[p].count(True)==3:
    flag=1
lis=[]
lis2=[]
for a in range(3):
  for b in range(3):
    lis2.append(x[b][a])
  else:
    lis.append(lis2)
    lis2=[]

for q in range(3):
  if lis[q].count(True)==3:
    flag=1
if x[0][0]==True and x[1][1]==True and x[2][2]==True:
  flag=1
elif  x[0][2]==True and x[1][1]==True and x[2][0]==True:
  flag=1
if flag==1:
  print("Yes")
else:
  print("No")

Solution (Python):
def checkRows(grid):
    for row in grid:
        if all([n == True for n in row]):
            return True
    return False


def checkCols(grid):
    for j in range(3):
        if all([n == True for n in [grid[i][j] for i in range(3)]]):
            return True
    return False


def checkDiags(grid):
    return all([n == True for n in [grid[i][i] for i in range(3)]]) or \
           all([n == True for n in [grid[i][2 - i] for i in range(3)]])


if __name__ == '__main__':
    grid = [[0] * 3 for i in range(3)]
    idx = {}

    for i in range(3):
        grid[i] = [int(s) for s in input().strip().split()]
        for j in range(3):
            idx[grid[i][j]] = (i, j)

    n = int(input())
    bs = [-1] * n

    for i in range(n):
        bs[i] = int(input())
        if bs[i] in idx.keys():
            a, b = idx[bs[i]]
            grid[a][b] = True

    if checkRows(grid) or checkCols(grid) or checkDiags(grid):
        print("Yes")
    else:
        print("No")

Solution (Python):
A = [[] for i in range(3)]
A[0] = list(map(int, input().split(' ')))
A[1] = list(map(int, input().split(' ')))
A[2] = list(map(int, input().split(' ')))
bingo = [[0, 0, 0] for i in range(3)]
N = int(input())
for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            bingo[j][k] = 1 if A[j][k] == num else bingo[j][k]
            

flag = False
if (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    flag = True

if flag == False:
    for i in range(3):
        if (bingo[0][i] and bingo[1][i] and bingo[2][i]) or (bingo[i][0] and bingo[i][1] and bingo[i][2]):
            flag = True
            break

if flag:
    print('Yes')
else:
    print('No')

Solution (Python):

bi = {}
ans = []
count = 0
for i in range(3):
    l = list(map(int, input().split()))
    for j in range(1,3+1):
        count += 1
        bi[l[j-1]] = count


n = int(input())
for i in range(n):
    k = int(input())
    if k in bi:
        ans.append(bi[k])



if 5 in ans and 1 in ans and 9 in ans:
    print("Yes")
    exit()

if  3 in ans and 5 in ans and 7 in ans:
    print("Yes")
    exit()

count = 1
for i in range(3):
    if (count) in ans and (count+1) in ans and (count+2) in ans:
        print("Yes")
        exit()
    else:
        count += 3

count = 1
for i in range(1,4):
    if (count) in ans and (count+3) in ans and (count+6) in ans:
        print("Yes")
        exit()
    else:
        count += 1

print("No")

Solution (Python):
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]

s=[]
t=[]
cross_1=0
cross_2=0

ans="No"

for i in b:
    for j in range(3):
        if i in A[j]:
            s.append(j)
            t.append(A[j].index(i))
            if j==A[j].index(i):
                cross_1+=1
                if j==1:
                    cross_2+=1
            elif j==2-A[j].index(i):
                cross_2+=1
                
for k in range(3):
    if s.count(k)==3:
        ans="Yes"
for l in range(3):
    if t.count(l)==3:
        ans="Yes"
if cross_1==3:
    ans="Yes"
elif cross_2==3:
    ans="Yes"

print(ans)

Solution (Python):
import numpy as np

mat = []

for i in range(3):
	(a,b,c)= input().split(' ')
	mat.append((int(a),int(b),int(c)))

mat = np.array(mat).reshape(3,3)


num = int(input())
ball=[]
for i in range(num):
  ball.append(int(input()))

ball = set(ball)

for h in range(3):
  x = set(mat[h,:])
  res = ball.intersection(x) == x
  if res:
    print('Yes')
    exit()

for w in range(3):
  x = set(mat[:, w])
  res = ball.intersection(x) == x
  if res:
    print('Yes')
    exit()

x = {mat[0,0],mat[1,1], mat[2,2]}
res = ball.intersection(x) == x
if res:
  print('Yes')
  exit()

x = {mat[2,0],mat[1,1], mat[0,2]}  
res = ball.intersection(x) == x
if res:
  print('Yes')
  exit()
  
print('No')

Solution (Python):
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
n = int(input())
b = [int(input()) for _ in range(n)]


if A_1[0] in b:
  if A_1[1] in b:
    if A_1[2] in b:
      print('Yes')
      exit(0)
      
if A_2[0] in b:
  if A_2[1] in b:
    if A_2[2] in b:
      print('Yes')
      exit(0)

if A_3[0] in b:
  if A_3[1] in b:
    if A_3[2] in b:
      print('Yes')
      exit(0)
  

for j in range(3):
  if A_1[j] in b:
    if A_2[j] in b:
      if A_3[j] in b:
        print('Yes')
        exit(0)

if A_1[0] in b:
  if A_2[1] in b:
    if A_3[2] in b:
      print('Yes')
      exit(0)
      
if A_1[2] in b:
  if A_2[1] in b:
    if A_3[0] in b:
      print('Yes')
      exit(0)

print('No')

Solution (Python):
e = list(map(int,input().split()))
f = list(map(int,input().split()))
g = list(map(int,input().split()))

c = [e[0],e[1],e[2],f[0],f[1],f[2],g[0],g[1],g[2]]
d = [0,0,0,0,0,0,0,0,0]

n=int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if c[j] == b:
            d[j] = 1

if (d[0]==1) and (d[1]==1) and (d[2]==1):
    print('Yes')
elif (d[3]==1) and (d[4]==1) and (d[5]==1):
    print('Yes')
elif (d[6]==1) and (d[7]==1) and (d[8]==1):
    print('Yes')
elif (d[0]==1) and (d[3]==1) and (d[6]==1):
    print('Yes')
elif (d[1]==1) and (d[4]==1) and (d[7]==1):
    print('Yes')
elif (d[2]==1) and (d[5]==1) and (d[8]==1):
    print('Yes')
elif (d[0]==1) and (d[4]==1) and (d[8]==1):
    print('Yes')
elif (d[2]==1) and (d[4]==1) and (d[6]==1):
    print('Yes')
else:
    print('No')

Solution (Python):
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
g,h,i = map(int, input().split())
aa = 0
bb = 0
cc = 0
dd = 0
ee = 0
ff = 0
gg = 0
hh = 0
ii = 0

j = int(input())

for k in range(j):
  l = int(input())
  if a == l:
    aa = 1
  elif b == l:
    bb = 1
  elif c == l:
    cc = 1
  elif d == l:
    dd = 1
  elif e == l:
    ee = 1
  elif f == l:
    ff = 1
  elif g == l:
    gg = 1
  elif h == l:
    hh = 1
  elif i == l:
    ii = 1
if aa == 1 and bb == 1 and cc == 1:
  print('Yes')
elif dd == 1 and ee == 1 and ff == 1:
  print('Yes')
elif gg == 1 and hh == 1 and ii == 1:
  print('Yes')
elif aa == 1 and dd == 1 and gg == 1:
  print('Yes')
elif bb == 1 and ee == 1 and hh == 1:
  print('Yes')
elif cc == 1 and ff == 1 and ii == 1:
  print('Yes')
elif aa == 1 and ee == 1 and ii == 1:
  print('Yes')
elif cc == 1 and ee == 1 and gg == 1:
  print('Yes')
else:
  print('No')