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):

t = [[int(j) for j in input().split()] for i in range(3)]
l = sum(t, [])
N = int(input())
for _ in range(N):
    i = int(input())
    for j in range(9):
        if i == l[j]:
            l[j] = 0
a, b, c, d, e, f, g, h, i = l
if (a == 0 and d == 0 and g == 0) \
or (b == 0 and e == 0 and h == 0) \
or (c == 0 and f == 0 and i == 0) \
or (a == 0 and b == 0 and c == 0) \
or (d == 0 and e == 0 and f == 0) \
or (g == 0 and h == 0 and i == 0) \
or (a == 0 and e == 0 and i == 0) \
or (c == 0 and e == 0 and g == 0):
    print('Yes')
else:
    print('No')

Solution (Python):
t = [[int(j) for j in input().split()] for i in range(3)]
l = sum(t, [])
N = int(input())
for _ in range(N):
    i = int(input())
    for j in range(9):
        if i == l[j]:
            l[j] = 0
a, b, c, d, e, f, g, h, i = l
if (a == 0 and d == 0 and g == 0) \
or (b == 0 and e == 0 and h == 0) \
or (c == 0 and f == 0 and i == 0) \
or (a == 0 and b == 0 and c == 0) \
or (d == 0 and e == 0 and f == 0) \
or (g == 0 and h == 0 and i == 0) \
or (a == 0 and e == 0 and i == 0) \
or (c == 0 and e == 0 and g == 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())
n = int(input())
b = [int(input()) for i in range(n)]
c = 0
if a11 in b and a12 in b and a13 in b:
    c += 1
if a21 in b and a22 in b and a23 in b:
    c += 1
if a31 in b and a32 in b and a33 in b:
    c += 1
if a11 in b and a21 in b and a31 in b:
    c += 1
if a12 in b and a22 in b and a32 in b:
    c += 1
if a13 in b and a23 in b and a33 in b:
    c += 1
if a11 in b and a22 in b and a33 in b:
    c += 1
if a13 in b and a22 in b and a31 in b:
    c += 1
if c > 0:
    print("Yes")
else:
    print("No")

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

n = int(input())
b = [0] * n
for i in range(n):
    b[i] = int(input()) 


ans = [[0 for i in range(3)]  for j in range(3)]

for i in range(3):
    for j in range(3):
        for h in range(n):
            if a[i][j] == b[h]:
                ans[i][j] = 1

hantei = False
for i in range(3):
    if ans[i] == [1,1,1]:
        hantei = True
    if ans[0][i] == 1 and ans[1][i] == 1 and ans[2][i] == 1:
        hantei = True

if ans[0][0] == 1 and ans[1][1] == 1 and ans[2][2] == 1:
    hantei = True

if ans[0][2] == 1 and ans[1][1] == 1 and ans[2][0] == 1:
    hantei = True

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

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


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

Solution (Python):
import numpy as np
A = np.array(sum((input().split() for _ in range(3)), []), dtype=np.int8)
N = int(input())
for _ in range(N):
    np.multiply(A, A != int(input()), out=A)
A.resize(3, 3)
print("YNeos"[np.trace(A) and np.trace(np.rot90(A)) and A.sum(axis=0).all() and A.sum(axis=1).all()::2])

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

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
             a[i][j] = 0

import numpy as np 

arr = np.array(a)

answer = "No"
if (0 in arr.sum(axis=0)) or (0 in arr.sum(axis=1)):
    answer = "Yes"
elif arr.diagonal().sum() == 0 or np.fliplr(arr).diagonal().sum() == 0: 
    answer = "Yes"

print(answer)

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

i = 0
while i<N:
  b = int(input())
  j=0
  while j<3:
    k=0
    while k<3:
      if A[j][k]==b:
        A[j][k]=0
      k+=1
    j+=1
  i+=1

flag = False
i = 0
while i<3:
  if A[i][0]+A[i][1]+A[i][2] == 0:
    flag = True
    break
  if A[0][i]+A[1][i]+A[2][i] == 0:
    flag = True
    break
  i += 1

if A[0][0]+A[1][1]+A[2][2] == 0:
  flag = True
if A[2][0]+A[1][1]+A[0][2] == 0:
  flag = True

if flag == True:
  print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))

bingo = np.array([A_1, A_2, A_3])
N = int(input())
for i in range(N):
    bingo[bingo == int(input())] = 0

def check():
    for i in range(3):
        if bingo[i][0] == 0 and bingo[i][1] == 0 and bingo[i][2] == 0:
            return True
        if bingo[0][i] == 0 and bingo[1][i] == 0 and bingo[2][i] == 0:
            return True
    if bingo[0][0] == 0 and bingo[1][1] == 0 and bingo[2][2] == 0:
        return True
    if bingo[0][2] == 0 and bingo[1][1] == 0 and bingo[2][0] == 0:
        return True

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

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

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
ans = "No"
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    elif a[0][i] + a[1][i] + a[2][i] ==0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] ==0:
    ans = "Yes"
elif a[0][2] + a[1][1] + a[2][0] ==0:
    ans = "Yes"
print(ans)

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


for i in range(3):
    for j in range(3):
        for k in range(N):
            
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

if (result[0][0]==1 and result[0][1]==1 and result[0][2]==1) \
or (result[1][0]==1 and result[1][1]==1 and result[1][2]==1) \
or (result[2][0]==1 and result[2][1]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][0]==1 and result[2][0]==1) \
or (result[0][1]==1 and result[1][1]==1 and result[2][1]==1) \
or (result[0][2]==1 and result[1][2]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][1]==1 and result[2][2]==1) \
or (result[0][2]==1 and result[1][1]==1 and result[2][0]==1) :
    print('Yes')
else:
    print('No')

Solution (Python):

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

for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

if (result[0][0]==1 and result[0][1]==1 and result[0][2]==1) \
or (result[1][0]==1 and result[1][1]==1 and result[1][2]==1) \
or (result[2][0]==1 and result[2][1]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][0]==1 and result[2][0]==1) \
or (result[0][1]==1 and result[1][1]==1 and result[2][1]==1) \
or (result[0][2]==1 and result[1][2]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][1]==1 and result[2][2]==1) \
or (result[0][2]==1 and result[1][1]==1 and result[2][0]==1) :
    print('Yes')
else:
    print('No')

Solution (Python):
def check(T):
    column = any([all( [T[i][j] for j in range(3)] ) for i in range(3)])
    row = any([all( [T[j][i]for j in range(3)] ) for i in range(3)])
    diagonal = all( [T[i][i] for i in range(3)]) or all( [T[i][2-i] for i in range(3)])
    return row or column or diagonal

a = 3
grid =[[0]*a for i in range(a)]

d = {}
for i in range(3):
    row = list(map(int,input().split()))
    for j in range(3):
        d[row[j]] = (i,j)


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

    if p in d.keys():
        x,y = d[p]
        grid[x][y] = 1

print( "Yes" if check(grid) else "No")

Solution (Python):
listA = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == listA[j][k]:
                listA[j][k] = 0
for l in range(3):
    if listA[l].count(0) == 3:
        print('Yes')
        exit()
    elif listA[0][l] == 0 and listA[1][l] == 0 and listA[2][l] == 0:
        print('Yes')
        exit()
if listA[0][0] == 0 and listA[1][1] == 0 and listA[2][2] == 0:
    print('Yes')
elif listA[0][2] == 0 and listA[1][1] == 0 and listA[2][0] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n=3
a=[[0]*n for ii in range(n)]
for ii in range(n):
  a[ii][:]=map(int,input().split())
m=int(input())
b=[0]*m
for ii in range(m):
  b[ii]=int(input())

c=[[1 if jj in b else 0 for jj in ii] for ii in a]

for ii in range(n):
  if sum(c[ii])==3:
    print("Yes")
    exit()
  if sum([c[jj][ii] for jj in range(n)])==3:
    print("Yes")
    exit()
if sum([c[jj][jj] for jj in range(n)])==3:
  print("Yes")
  exit()
if sum([c[jj][n-1-jj] for jj in range(n)])==3:
  print("Yes")
  exit()
print("No")

Solution (Python):
A = []
B = [[False for _ in range(3)] for __ in range(3) ]
for i in range(3):
    a = list(map(int, input().split()))
    A.append(a)

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = True

ansFlag = False

for i in range(3):
    ansi = True
    for j in range(3):
        if B[i][j] == False:
            ansi = False

    if ansi:
        ansFlag = True

for i in range(3):
    ansi = True
    for j in range(3):
        if B[j][i] == False:
            ansi = False

    if ansi:
        ansFlag = True

ansi = True
for j in range(3):
    if B[2-j][j] == False:
        ansi = False

if ansi:
    ansFlag = True

ansi = True
for j in range(3):
    if B[j][2-j] == False:
        ansi = False

if ansi:
    ansFlag = True

ansi = True
for j in range(3):
    if B[j][j] == False:
        ansi = False

if ansi:
    ansFlag = True

ansi = True
for j in range(3):
    if B[2-j][2-j] == False:
        ansi = False

if ansi:
    ansFlag = True

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

Solution (Python):
a=[list(map(int,input().split())) for _ in range(3)]
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

ans=0
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    ans=1
  elif a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    ans=1

if a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
  ans=1
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
  ans=1

if ans==1:
  print('Yes')
else:
  print('No')

Solution (Python):
bingo=[list(input().split()) for i in range(3)]
n=int(input())
ans=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
    a=input()
    for j in range(3):
        for k,l in enumerate(bingo[j]):
            if a==l:
                ans[j][k]=1 
if (ans[0][0]==ans[0][1]==ans[0][2]==1)\
    or (ans[1][0]==ans[1][1]==ans[1][2]==1)\
        or (ans[2][0]==ans[2][1]==ans[2][2]==1) \
            or (ans[0][0]==ans[1][0]== ans[2][0]==1) \
                or (ans[0][1]==ans[1][1]==ans[2][1]==1) \
                    or (ans[0][2]==ans[1][2]==ans[2][2]==1) \
                        or (ans[0][0]==ans[1][1]==ans[2][2]==1) \
                            or (ans[0][2]==ans[1][1]==ans[2][0]==1):
    print("Yes")
else:
    print("No")

Solution (Python):
bingo=[list(input().split()) for i in range(3)]
n=int(input())
ans=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
    a=input()
    for j in range(3):
        for k,l in enumerate(bingo[j]):
            if a==l:
                ans[j][k]=1 
if (ans[0][0]==1 and ans[0][1]==1 and ans[0][2]==1) or (ans[1][0]==1 and ans[1][1]==1 and ans[1][2]==1) or (ans[2][0]==1 and ans[2][1]==1 and ans[2][2]==1) or (ans[0][0]==1 and ans[1][0]==1 and ans[2][0]==1) or (ans[0][1]==1 and ans[1][1]==1 and ans[2][1]==1) or (ans[0][2]==1 and ans[1][2]==1 and ans[2][2]==1) or (ans[0][0]==1 and ans[1][1]==1 and ans[2][2]==1) or (ans[0][2]==1 and ans[1][1]==1 and ans[2][0]==1):
    print("Yes")
else:
    print("No")

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

i = 10
call = []
try:
    for j in range(i):
        n = input()
        if (n == ''):
            break

        call.append(int(n))
except EOFError:
    pass

bingo = []

bingo.append(a)
bingo.append(b)
bingo.append(c)
bingo.append([a[0], b[0], c[0]])
bingo.append([a[1], b[1], c[1]])
bingo.append([a[2], b[2], c[2]])
bingo.append([a[0], b[1], c[2]])
bingo.append([a[2], b[1], c[0]])

ans = True
test = []
for ls in bingo:
    for num in ls:
        ans = ans and (num in call)

    if ans == True:
        print('Yes')
        exit(0)

    ans = True

print('No')

Solution (Python):
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
list3 = list(map(int, input().split()))
n = int(input())
num_list = []
for i in range(n):
    b = int(input())
    num_list.append(b)
for num in num_list:
    if num in list1:
        x = list1.index(num)
        list1.pop(x)
        list1.insert(x, 'bingo')
    if num in list2:
        x = list2.index(num)
        list2.pop(x)
        list2.insert(x, 'bingo')
    if num in list3:
        x = list3.index(num)
        list3.pop(x)
        list3.insert(x, 'bingo')
result = 'No'
if list1[0] == list1[1] == list1[2] == 'bingo':
    result = 'Yes'
if list2[0] == list2[1] == list2[2] == 'bingo':
    result = 'Yes'
if list3[0] == list3[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[0] == list3[0] == 'bingo':
    result = 'Yes'
if list1[1] == list2[1] == list3[1] == 'bingo':
    result = 'Yes'
if list1[2] == list2[2] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[2] == list2[1] == list3[0] == 'bingo':
    result = 'Yes'

print(result)

Solution (Python):
a=[input().split() for i in range(3)]
N=int(input())
B=list(map(int,[input() for i in range(1,N+1)]))

A1=list(map(int,a[0]))
A2=list(map(int,a[1]))
A3=list(map(int,a[2]))

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

Solution (Python):
A =  [[int(x) for x in input().split()] for i in range(3)]
n = int(input())

bingo = [[False]*3 for i in range(3)]
num = [[-1]*2 for i in range(101)]
for i in range(3):
    for j in range(3):
        num[A[i][j]][0] = i
        num[A[i][j]][1] = j

for i in range(n):
    index = int(input())
    x,y = num[index]
    if(x==-1 or y==-1):
        continue
    bingo[x][y]=True

isOk = False

for i in range(3):
    cnt = 0
    for j in range(3):
        if(bingo[i][j]):
            cnt+=1
        if(cnt==3):
            isOk = True
            break


for i in range(3):
    cnt = 0
    for j in range(3):
        if(bingo[j][i]):
            cnt+=1
        if(cnt==3):
            isOk = True
            break


if(bingo[0][0] and bingo[1][1] and bingo[2][2]):
    isOk = True

if(bingo[2][0] and bingo[1][1] and bingo[0][2]):
    isOk = True

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

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

for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
    if (
        A[0] + A[1] + A[2] == 0
        or A[3] + A[4] + A[5] == 0
        or A[6] + A[7] + A[8] == 0
        or A[0] + A[3] + A[6] == 0
        or A[1] + A[4] + A[7] == 0
        or A[2] + A[5] + A[8] == 0
        or A[0] + A[4] + A[8] == 0
        or A[2] + A[4] + A[6] == 0
    ):
        print("Yes")
        break
else:
    print("No")

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

ans = 0

for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
    if (
        A[0] + A[1] + A[2] == 0
        or A[3] + A[4] + A[5] == 0
        or A[6] + A[7] + A[8] == 0
        or A[0] + A[3] + A[6] == 0
        or A[1] + A[4] + A[7] == 0
        or A[2] + A[5] + A[8] == 0
        or A[0] + A[4] + A[8] == 0
        or A[2] + A[4] + A[6] == 0
    ):
        print("Yes")
        break
else:
    print("No")

Solution (Python):
A=[]
for i in range(3):
    P=list(map(int,input().split()))
    A.append(P)
N=int(input())
b=[]
for i in range(N):
    p=int(input())
    b.append(p)
    
for i in range(N):
    for j in range(3):
        if b[i] in  A[j]:
            q= A[j].index(b[i])
            A[j][q]='O'

if A[0].count('O')==3:
    print('Yes')
elif A[1].count('O')==3:
    print('Yes')
elif A[2].count('O')==3:
    print('Yes')
elif A[0][0]==A[1][0] and A[1][0]==A[2][0]:
    print('Yes')
elif A[0][1]==A[1][1] and A[1][1]==A[2][1]:
    print('Yes')
elif A[0][2]==A[1][2] and A[1][2]==A[2][2]:
    print('Yes')
elif A[0][0]==A[1][1] and A[1][1]==A[2][2]:
    print('Yes')
elif A[0][2]==A[1][1] and A[1][1]==A[2][0]:
    print('Yes')
else:
    print('No')

Solution (Python):
A = [[int(x) for x in input().split()] for i in range(3)]
n = int(input())
B = set(int(input()) for i in range(n))
res = False
for row in A:
    if all(x in B for x in row):
        res = True
for j in range(3):
    if all(A[i][j] in B for i in range(3)):
        res = True
if all(A[i][i] in B for i in range(3)):
    res = True
if all(A[i][2 - i] in B for i in range(3)):
    res = True
print("Yes" if res else "No")

Solution (Python):
import numpy as np

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

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -1
            
flag = False
for i in a:
    if sum(i)==-3:
        flag = True
for i in a.T:
    if sum(i)==-3:
        flag = True
if a.trace() == -3 or  sum([a[0][2], a[1][1], a[2][0]]) == -3:
    flag = True
    
if flag:
    print('Yes')
else:
    print('No')

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


for i in range(3):
    for j in range(3):
        for k in range(N):
            
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

if (result[0][0]==1 and result[0][1]==1 and result[0][2]==1) \
or (result[1][0]==1 and result[1][1]==1 and result[1][2]==1) \
or (result[2][0]==1 and result[2][1]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][0]==1 and result[2][0]==1) \
or (result[0][1]==1 and result[1][1]==1 and result[2][1]==1) \
or (result[0][2]==1 and result[1][2]==1 and result[2][2]==1) \
or (result[0][0]==1 and result[1][1]==1 and result[2][2]==1) \
or (result[0][2]==1 and result[1][1]==1 and result[2][0]==1) :
    print('Yes')
else:
    print('No')

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

N = int(input())
b = []
for i in range(N):
    b.append(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

judge = 'No'
for i in range(3):
    if a[0][i] == 1 and a[1][i] == 1 and a[2][i] == 1:
        judge = "Yes"
    elif a[i][0] == 1 and a[i][1] == 1 and a[i][2] == 1:
        judge = "Yes"
if a[0][0] == 1 and a[1][1] == 1 and a[2][2] == 1:
    judge = 'Yes'
elif a[0][2] == 1 and a[1][1] == 1 and a[2][0] == 1:
    judge = 'Yes'

print(judge)

Solution (Python):
a = [] 
for i in range(3):
    a.extend(input().split())
n = int(input())
for i in range(n):
    c = input()
    if c in a:
        a[a.index(c)] = '0'
if (a[0] == a[1] == a[2] or a[3] == a[4] == a[5] or a[6] == a[7] == a[8] or
    a[0] == a[3] == a[6] or a[1] == a[4] == a[7] or a[2] == a[5] == a[8] or
        a[0] == a[4] == a[8] or a[2] == a[4] == a[6]):
    print('Yes')
else:
    print('No')

Solution (Python):
a = [[int(i) for i in input().split()] for j in range(3)]
n = int(input())
for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b==a[j][k]:
        a[j][k] = 0
ans = 'No'
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    ans = 'Yes'
for i in range(3):
  if a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    ans = 'Yes'
if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
  ans = 'Yes'
if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
  ans = 'Yes'
print(ans)

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

c = [[0]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                c[i][j] = 1


for i in range(3):
  if c[i][0] and c[i][1] and c[i][2]:
    print('Yes')
    exit()
  if c[0][i] and c[1][i] and c[2][i]:
    print('Yes')
    exit()
if c[0][0] and c[1][1] and c[2][2]:
  print('Yes')
  exit()
if c[0][2] and c[1][1] and c[2][0]:
  print('Yes')
  exit()

print('No')

Solution (Python):
def main():
    a1_lis = list(map(int, input().split()))
    a2_lis = list(map(int, input().split()))
    a3_lis = list(map(int, input().split()))

    n = int(input())
    b_lis = []
    for _ in range(n):
        b_lis.append(int(input()))
    
    if a1_lis[0] in b_lis and a1_lis[1] in b_lis and a1_lis[2] in b_lis:
        print('Yes')
        exit()
    if a2_lis[0] in b_lis and a2_lis[1] in b_lis and a2_lis[2] in b_lis:
        print('Yes')
        exit()
    if a3_lis[0] in b_lis and a3_lis[1] in b_lis and a3_lis[2] in b_lis:
        print('Yes')
        exit()
    if a1_lis[0] in b_lis and a2_lis[0] in b_lis and a3_lis[0] in b_lis:
        print('Yes')
        exit()
    if a1_lis[1] in b_lis and a2_lis[1] in b_lis and a3_lis[1] in b_lis:
        print('Yes')
        exit()
    if a1_lis[2] in b_lis and a2_lis[2] in b_lis and a3_lis[2] in b_lis:
        print('Yes')
        exit()



    if a1_lis[0] in b_lis and a2_lis[1] in b_lis and a3_lis[2] in b_lis:
        print('Yes')
        exit()
    
    if a3_lis[0] in b_lis and a2_lis[1] in b_lis and a1_lis[2] in b_lis:
        print('Yes')
        exit()
    else:
        print("No")
        


    


if __name__ == "__main__":
    main()

Solution (Python):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
 
for i in b:
  for j in range(3):
    for k in range(3):
      if i == a[j][k]:
        a[j][k] = 0
        
for i in range(3):
  if sum(a[i]) == 0:
    print('Yes')
    exit()
    
if a[0][0]+a[1][0]+a[2][0] == 0 or a[0][1]+a[1][1]+a[2][1] == 0 or a[0][2]+a[1][2]+a[2][2] == 0:
  print('Yes')
elif a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
  print('Yes')
else:
  print('No')

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

B = []
N = int(input())
for i in range(N):
  b = int(input())
  B.append(b)
  
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
  print('Yes')
elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
  print('Yes')
else:
  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')
      exit()
    if A[0][i] in B and A[1][i] in B and A[2][i] in B:
      print('Yes')
      exit()
  print('No')

Solution (Python):
import itertools
import math
import fractions
import functools


l = [list(map(int, input().split())),list(map(int, input().split())),list(map(int, input().split()))]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

ij = []
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == l[j][k]:
                ij.append([j,k])

for i in range(3):
    count = 0
    for j in range(3):
        for k in range(len(ij)):
            if ij[k] == [i,j]:
                count += 1
        if count >= 3:
            print("Yes")
            quit()

for i in range(3):
    count = 0
    for j in range(3):
        for k in range(len(ij)):
            if ij[k] == [j,i]:
                count += 1
        if count >= 3:
            print("Yes")
            quit()

count = 0
for i in range(3):
    for j in range(len(ij)):
        if ij[j] == [i,i]:
            count += 1
    if count >= 3:
        print("Yes")
        quit()

count = 0
for i in range(len(ij)):
    if ij[i] == [0,2] or ij[i] == [1,1] or ij[i] == [2,0]:
        count += 1
if count >= 3:
    print("Yes")
    quit()

print("No")

Solution (Python):
A = []
for i in range(3):
    temp = list(map(int, input().split()))
    A += temp
N = int(input())
bingo = [0]*9
for i in range(N):
    b = int(input())
    if b in A:
        bingo[A.index(b)] = 1
flag = bingo[0]*bingo[1]*bingo[2] + bingo[3]*bingo[4]*bingo[5] + bingo[6]*bingo[7]*bingo[8]
flag += bingo[0]*bingo[3]*bingo[6] + bingo[1]*bingo[4]*bingo[7] + bingo[2]*bingo[5]*bingo[8]
flag += bingo[0]*bingo[4]*bingo[8] + bingo[2]*bingo[4]*bingo[6]
if flag > 0:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
for _ in range(3):
  A += list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if C[0]*C[1]*C[2] == 1 or C[3]*C[4]*C[5]==1 or C[6]*C[7]*C[8] ==1 or C[0]*C[3]*C[6] ==1 or C[1]*C[4]*C[7]==1 or C[2]*C[5]*C[8] ==1 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

A = LI2(3)
N = I()
for _ in range(N):
    b = I()
    for i in range(3):
        for j in range(3):
            if b==A[i][j]:
                A[i][j]=0
for c in A:
    if sum(c)==0:
        print('Yes')
        break
else:
    for r in range(3):
        if A[0][r]+A[1][r]+A[2][r]==0:
            print('Yes')
            break
    else:
        if A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0:
            print('Yes')
        else:
            print('No')

Solution (Python):
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
a3 = [int(i) for i in input().split()]
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    elif b in a2:
        a2[a2.index(b)] = 0
    elif b in a3:
        a3[a3.index(b)] = 0
k = sum(a1) * sum(a2) * sum(a3)
for i in range(3):
    k *= a1[i] + a2[i] + a3[i]
k *= (a1[0] + a2[1] + a3[2]) * (a1[2] + a2[1] + a3[0])
if k == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = True
        else:
            a[i][j] = False
a += [[a[0][i], a[1][i], a[2][i]] for i in range(3)]
a += [[a[i][i] for i in range(3)]] + [[a[0][2], a[1][1], a[2][0]]]
bingo = False
for i in a:
    if all(i):
        bingo = True
        break
if bingo:
    print('Yes')
else:
    print('No')