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 = []
for i in range(3):
    x = list(map(int, input().split()))
    a.append(x)
n = int(input())

num = [[0] * 3 for _ in range(3)]
for i in range(n):
    x = int(input())
    for j in range(3):
        for k in range(3):
            if x == a[j][k]:
                num[j][k] = 1


ans = False
for i in range(3):
    cnt = 0
    for j in range(3):
        if num[i][j] == 1:
            cnt += 1
    if cnt == 3:
        ans = True

for i in range(3):
    cnt = 0
    for j in range(3):
        if num[j][i] == 1:
            cnt += 1
    if cnt == 3:
        ans = True

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

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

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = np.array([lr() for _ in range(3)])
N = ir()
B = np.zeros_like(A, np.bool)
for _ in range(N):
    b = ir()
    if np.any(A==b):
        i = np.where(A==b)
        B[i[0], i[1]] = True

bl = np.any([np.all(row) for row in B])
if np.any(np.all(B, axis=0)):
    bl = True
if np.all(np.diag(B)):
    bl = True
B = B[:, ::-1]
if np.all(np.diag(B)):
    bl = True
print('Yes' if bl else 'No')

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
for b in B:
    for x in range(3):
        for y in range(3) :
            if A[x][y] == b:
                A[x][y] = 0

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 \
or A[0][0] + A[0][1] + A[0][2] == 0 \
or A[1][0] + A[1][1] + A[1][2] == 0 \
or A[2][0] + A[2][1] + A[2][2] == 0 \
or 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,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
N=int(input())
L=[int(input()) for i in range(N)]
if a in L and b in L and c in L:
  print('Yes')
elif d in L and e in L and  f in L:
  print('Yes')
elif g in L and h in L and  i in L:
  print('Yes')
elif a in L and d in L and  g in L:
  print('Yes')
elif b in L and e in L and  h in L:
  print('Yes')
elif c in L and f in L and  i in L:
  print('Yes')
elif a in L and e in L and  i in L:
  print('Yes')
elif c in L and e in L and  g in L:
  print('Yes')
else:
  print('No')

Solution (Python):
a = [list(int(i) for i in input().split()) for i in range(3)]
f = [[0 for i in range(3)] for i in range(3)]
n = int(input())
b = []
flag = False

for i in range(n):
  b.append(int(input()))
  
for i in b:
  for j in range(3):
    for k in range(3):
      if i == a[j][k]:
        f[j][k] = 1

if sum(f[0]) == 3 or sum(f[1]) == 3 or sum(f[2]) == 3:
  flag = True

for i in range(3):
  tmp = []
  for j in range(3):
    tmp.append(f[j][i])
  if sum(tmp) == 3:
    flag = True
    
if f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
  flag = True

if f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
  flag = True

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

Solution (Python):


A = []
for _ in range(3):
    A.append([int(a) for a in input().split()])

N = int(input())
B = [[False] * 3 for _ in range(3)]
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

ans = 'No'
for i in range(3):
    if B[i][0] == B[i][1] == B[i][2] == True:
        ans = 'Yes'
    if B[0][i] == B[1][i] == B[2][i] == True:
        ans = 'Yes'
if B[0][0] == B[1][1] == B[2][2] == True:
    ans = 'Yes'
if B[0][2] == B[1][1] == B[2][0] == True:
    ans = 'Yes'

print(ans)

Solution (Python):



a = []
b = []
check_list = [False] * 9
for _ in range(3):
  a.extend(list(map(int, input().split())))
n = int(input())
for _ in range(n):
  b.append(int(input()))

for _b in b:
  if _b in a:
    check_list[a.index(_b)] = True

if check_list[0] and check_list[1] and check_list[2]\
  or check_list[3] and check_list[4] and check_list[5]\
  or check_list[6] and check_list[7] and check_list[8]\
  or check_list[0] and check_list[3] and check_list[6]\
  or check_list[1] and check_list[4] and check_list[7]\
  or check_list[2] and check_list[5] and check_list[8]\
  or check_list[0] and check_list[4] and check_list[8]\
  or check_list[2] and check_list[4] and check_list[6]:
  print('Yes')
else:
  print('No')

Solution (Python):
def main():
    num=[0]*9
    num[0],num[1],num[2]= map(int,input().split())
    num[3],num[4],num[5]= map(int,input().split())
    num[6],num[7],num[8]= map(int,input().split())

    n=int(input())
    li=[int(input()) for i in range(n)]
    flg = 0
    cnt = 0
    bg = [0]*9


    for i in num:
        if i in li:
            
            bg[cnt]=1

        cnt+=1

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

    

if __name__ == '__main__':
    main()

Solution (Python):
a1,a2,a3= map(int,input().split())
a4,a5,a6= map(int,input().split())
a7,a8,a9= map(int,input().split())
n=int(input())
b=[int(input()) for _ in range(n)]
bing = [(a1,a2,a3),(a4,a5,a6),(a7,a8,a9),
        (a1,a4,a7),(a2,a5,a8),(a3,a6,a9),
        (a1,a5,a9),(a3,a5,a7)]
for cs in bing:
    for c in cs:
        if not c in b:break
    else:
        print('Yes')
        break
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())
N=int(input())
L=[int(input()) for i in range(N)]
if a in L and b in L and c in L:
  print('Yes')
elif d in L and e in L and  f in L:
  print('Yes')
elif g in L and h in L and  i in L:
  print('Yes')
elif a in L and d in L and  g in L:
  print('Yes')
elif b in L and e in L and  h in L:
  print('Yes')
elif c in L and f in L and  i in L:
  print('Yes')
elif a in L and e in L and  i in L:
  print('Yes')
elif c in L and e in L and  g in L:
  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()))
B1 = [0,0,0]
B2 = [0,0,0]
B3 = [0,0,0]
N = int(input())
for i in range(N):
  x = int(input())
  if(x in A1):
    tmp = A1.index(x)
    B1[tmp] = 1
  if(x in A2):
    tmp = A2.index(x)
    B2[tmp] = 1
  if(x in A3):
    tmp = A3.index(x)
    B3[tmp] = 1
if(B1[0]==1 and B1[1]==1 and B1[2]==1):
  print("Yes")
  exit()
if(B2[0]==1 and B2[1]==1 and B2[2]==1):
  print("Yes")
  exit()
if(B3[0]==1 and B3[1]==1 and B3[2]==1):
  print("Yes")
  exit()
if(B1[0]==1 and B2[0]==1 and B3[0]==1):
  print("Yes")
  exit()
if(B1[1]==1 and B2[1]==1 and B3[1]==1):
  print("Yes")
  exit()
if(B1[2]==1 and B2[2]==1 and B3[2]==1):
  print("Yes")
  exit()
if(B1[0]==1 and B2[1]==1 and B3[2]==1):
  print("Yes")
  exit()
if(B1[2]==1 and B2[1]==1 and B3[0]==1):
  print("Yes")
  exit()
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 b:
      if A[i][j]==k:
         A[i][j]=0
  
flag=0
for i in range(3):
  if A[i].count(0)==3:
    flag=1
    
    break
  elif A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
    flag=1
    
    break    
else:
  if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    
    flag=1
  elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    
    flag=1
print('Yes' if flag==1 else 'No')

Solution (Python):



def is_bingo(A, B):
    is_called = []
    for i in range(3):
        is_called.append([True if A[i][j] in B else False for j in range(3)])
    for i in range(3):
        if not(False in [is_called[i][j] for j in range(3)]): return True
    for j in range(3):
        if not(False in [is_called[i][j] for i in range(3)]): return True
    if not(False in [is_called[i][j] for i in range(3) for j in range(3) if i + j == 2]): return True
    if not(False in [is_called[i][j] for i in range(3) for j in range(3) if i - j == 0]): return True
    return False

def main():
    A = []
    B = []
    for _ in range(3):
        A.append(list(map(int, input().split())))
    N = int(input())
    for _ in range(N):
        B.append(int(input()))
    if is_bingo(A, B):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    try:
        assert is_bingo([[84, 97, 66], [79, 89, 11], [61, 59, 7]], [89, 7, 87, 79, 24, 84, 30]) == True
        assert is_bingo([[41, 7, 46], [26, 89, 2], [78, 92, 8]], [5, 6, 45, 16, 57, 17]) == False
        assert is_bingo([[60, 88, 34], [92, 41, 43], [65, 73, 48]], [10, 60, 43, 88, 11, 48, 73, 65, 41, 92, 34]) == True
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()

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

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

for i in range(n):
    for j in range(9):
        if b[i]==A[j]:
            A[j]="atari"

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

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

Solution (Python):
A=[[int(i) for i in input().split(" ")]for k in range(3)]
N=int(input())
for i in range(N):
    b=int(input())
    for x,y in [(x,y) for x in range(3) for y in range(3) if A[x][y]==b]:
        A[x][y]=0

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

Solution (Python):
import numpy as np
a1 = np.zeros(3, dtype=int)
a2 = np.zeros(3, dtype=int)
a3 = np.zeros(3, dtype=int)

for i in range(3):
    a1[i], a2[i], a3[i] = map(int, input().split())

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

a = np.array([a1, a2, a3]).T.flatten()

for i in range(n):
    a[np.where(a == b[i])] = 0
a = a.reshape(3, -1)

print("Yes") if a[0].sum()==0 or a[1].sum()==0 or a[2].sum()==0 or a[:, 0].sum()==0 or a[:, 1].sum()==0 or a[:, 2].sum()==0 or np.diag(a).sum()==0 or np.diag(a[::-1]).sum()==0 else print("No")

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
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:
                a[i][j] = 0
ans = 'No'
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0: ans = 'Yes'
    if 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'
if a[0][2] + a[1][1] + a[2][0] == 0: ans = 'Yes'
print(ans)

Solution (Python):
a_list = [0]*3
a_list[0] = list(map(int,input().split()))
a_list[1] = list(map(int,input().split()))
a_list[2] = list(map(int,input().split()))
n = int(input())

for k in range(n):
    dum = int(input())
    for i in range(3):
        for j in range(3):
            if a_list[i][j] == dum:
                a_list[i][j] = 0

if a_list[0][0] == 0 and a_list[0][1] == 0 and a_list[0][2] == 0:
    print("Yes")
elif a_list[1][0] == 0 and a_list[1][1] == 0 and a_list[1][2] == 0:
    print("Yes")
elif a_list[2][0] == 0 and a_list[2][1] == 0 and a_list[2][2] == 0:
    print("Yes")
elif a_list[0][0] == 0 and a_list[1][0] == 0 and a_list[2][0] == 0:
    print("Yes")
elif a_list[0][1] == 0 and a_list[1][1] == 0 and a_list[2][1] == 0:
    print("Yes")
elif a_list[0][2] == 0 and a_list[1][2] == 0 and a_list[2][2] == 0:
    print("Yes")
elif a_list[0][0] == 0 and a_list[1][1] == 0 and a_list[2][2] == 0:
    print("Yes")
elif a_list[0][2] == 0 and a_list[1][1] == 0 and a_list[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())
b=[int(input()) for i in range (N)]
for t in b:
    if t in A1:
        A1[A1.index(t)]="
    elif t in A2:
        A2[A2.index(t)]="
    elif t in A3:
        A3[A3.index(t)]="
ans='No'
if len(set(A1))==1 or len(set(A2))==1 or len(set(A3))==1:
    ans='Yes'
if (A1[0]==A2[0]==A3[0]) or (A1[1]==A2[1]==A3[1]) or (A1[2]==A2[2]==A3[2]):
    ans='Yes'
if (A1[0]==A2[1]==A3[2]) or (A1[2]==A2[1]==A3[0]):
    ans='Yes'
print(ans)

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):
        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"
    if 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"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"

print(ans)

Solution (Python):
A = []
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
N = int(input())

B = [[False for i in range(0,3,1)]for i in range(0,3,1)]
for i in range(0,N):
    n = int(input())
    for j in range(0,3):
        for k in range(0,3):
            if n == A[j][k]:
                B[j][k]=True

if (B[0][0]and B[0][1]and B[0][2])or(B[1][0]and B[1][1]and B[1][2])or(B[2][0]and B[2][1]and B[2][2])or(B[0][0]and B[1][0]and B[2][0])or(B[0][1]and B[1][1]and B[2][1])or(B[0][2]and B[1][2]and B[2][2])or(B[0][0]and B[1][1]and B[2][2])or(B[2][0]and B[1][1]and B[0][2]):
    print("Yes")
else:
    print("No")

Solution (Python):
a0,a1,a2=map(int,input().split())
a3,a4,a5=map(int,input().split())
a6,a7,a8=map(int,input().split())
N=int(input())
b=[int(input()) for _ in range(N)]
A=[a0,a1,a2,a3,a4,a5,a6,a7,a8]

for i in range(N):
  for p in range(9):
    if b[i]==A[p]:
      A[p]=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")
else:
  print("No")

Solution (Python):
import numpy as np
A = np.zeros((3,3), dtype=int)
for i in range(3):
    A[i,:] = list(map(int, input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]

A = A.flatten()
for a in range(len(A)):

    for b in range(N):
        if A[a] == B[b]:
            A[a] = -1



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

Solution (Python):
d = {}

for i in range(3):
    a = input().split()
    for j in range(3):
        d[a[j]] = (i,j)
t = [[0 for _ in range(3)] for _ in range(3)]
n = int(input())
for i in range(n):
    b = input()
    if(b in d):t[d[b][0]][d[b][1]] = 1
for i in range(3):
    if(t[0][i] + t[1][i] + t[2][i] == 3):
        print('Yes')
        exit()
    if(t[i][0] + t[i][1] + t[i][2] == 3):
        print('Yes')
        exit()
if(t[0][0]+t[1][1]+t[2][2] == 3):
    print('Yes')
    exit()
if(t[0][2]+t[1][1]+t[2][0] == 3):
    print('Yes')
    exit()
print('No')

Solution (Python):
def solve():
    A = [list(map(int, input().split())) for _ in range(3)]
    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:
                    A[i][j] = -1
    
    for i in range(3):
        if A[i][0] == -1 and A[i][1] == -1 and A[i][2] == -1:
            return "Yes"
    for j in range(3):
        if A[0][j] == -1 and A[1][j] == -1 and A[2][j] == -1:
            return "Yes"
    if A[0][0] == -1 and A[1][1] == -1 and A[2][2] == -1:
        return "Yes"
    if A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1:
        return "Yes"
    return "No"

print(solve())

Solution (Python):



def solve(A,N,b) -> str:
    ans = [[0,0,0]for _ in range(3)]
    for bn in b:
        for n,a in enumerate(A):
            if(bn in a):
                ans[n][a.index(bn)] = 1
    for a in ans:
        if(sum(a) == 3):
            return "Yes"
    for a in zip(*ans):
        if(sum(a) == 3):
            return "Yes"
    if(ans[1][1] == 1):
            if(ans[0][0]==1 and ans[2][2]==1 or ans[0][2] == 1 and ans[2][0] == 1):
                return "Yes"
    else:
        return "No"


def main():
    A = []
    for _ in range(3):
        A.append(list(map(int,input().split())))
    N = int(input())
    b = [int(input())for _ in range(N)]
    
    print(solve(A,N,b[:]))


if __name__ == "__main__":
    main()

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

for i in range(3):
    for j in range(3):
        card[i][j] = "o" if card[i][j] in bingo else card[i][j]

ans = "No"
if card[0][0] == card[0][1] == card[0][2] \
    or card[1][0] == card[1][1] == card[1][2] \
    or card[2][0] == card[2][1] == card[2][2] \
    or card[0][0] == card[1][0] == card[2][0] \
    or card[0][1] == card[1][1] == card[2][1] \
    or card[0][2] == card[1][2] == card[2][2] \
    or card[0][0] == card[1][1] == card[2][2] \
    or card[0][2] == card[1][1] == card[2][0]:
    ans = "Yes"

print(ans)

Solution (Python):
x = [[0]*3 for _ in range(3)]
a = [[0]*3 for _ in range(3)]

for i in range(3):
    a[i][0],a[i][1],a[i][2] = list(map(int,input().split()))
N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                x[j][k] += 1

for i in range(3):
    if x[1][i]==x[2][i]==x[0][i]==1 \
    or x[i][1]==x[i][2]==x[i][0]==1 \
    or x[1][1]==x[2][2]==x[0][0]==1 \
    or x[0][2]==x[1][1]==x[2][0]==1:
        print('Yes')
        exit()

print('No')

Solution (Python):
x = [[0]*3 for _ in range(3)]
a = [[0]*3 for _ in range(3)]

for i in range(3):
    a[i][0],a[i][1],a[i][2] = 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 b == a[j][k]:
                x[j][k] += 1

for i in range(3):
    if x[1][i]==x[2][i]==x[0][i]==1 \
    or x[i][1]==x[i][2]==x[i][0]==1 \
    or x[1][1]==x[2][2]==x[0][0]==1 \
    or x[0][2]==x[1][1]==x[2][0]==1:
        print('Yes')
        exit()

print('No')

Solution (Python):
A_1=[int(x) for x in input().rstrip().split()]
A_2=[int(x) for x in input().rstrip().split()]
A_3=[int(x) for x in input().rstrip().split()]

N=int(input())
for i in range(N):
  b=int(input())
  if b in A_1:
    A_1[A_1.index(b)]=0
  if b in A_2:
    A_2[A_2.index(b)]=0
  if b in A_3:
    A_3[A_3.index(b)]=0


if A_1[0]==A_1[1]==A_1[2]==0:
  print("Yes")
elif A_1[0]==A_2[1]==A_3[2]==0:
  print("Yes")
elif A_1[0]==A_2[0]==A_3[0]==0:
  print("Yes")
elif A_2[0]==A_2[1]==A_2[2]==0:
  print("Yes")
elif A_3[0]==A_3[1]==A_3[2]==0:
  print("Yes")
elif A_1[1]==A_2[1]==A_3[1]==0:
  print("Yes")
elif A_1[2]==A_2[2]==A_3[2]==0:
  print("Yes")
elif A_1[2]==A_2[1]==A_3[0]==0:
  print("Yes")
else:
  print("No")

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

checker =[[ False for _ in range(3)] for _ in range(3)]

flag = False

for i in range(3):
    for j in range(3):
        for k in range(N):
            if card[i][j] ==  b[k]:
                checker[i][j] = True

for i in range(3):
    if all(checker[i]):
        flag = True
        print('Yes')
        exit()

for i in range(3):
    for j in range(3):
        if checker[j][i] == True:
            temp = True
        else:
            temp = False
            break
    if temp == True:
        print('Yes')
        exit()


if checker[0][0] == checker[1][1] == checker[2][2] == True:
    print('Yes')
    exit()

if checker[0][2] == checker[1][1] == checker[2][0] == True:
    print('Yes')
    exit()


print('No')

Solution (Python):
r1 = list(map(lambda x:int(x),input().split()))
r2 = list(map(lambda x:int(x),input().split()))
r3 = list(map(lambda x:int(x),input().split()))
n = int(input())
for i in range(n):
  called = int(input())
  for j in range(3):
    if called==r1[j]:
      r1[j] = 0      
    elif called==r2[j]:
      r2[j] = 0
    elif called==r3[j]:
      r3[j] = 0
if r1==[0,0,0] or r2==[0,0,0] or r3==[0,0,0]:
  print("Yes")
elif r1[0]==r2[0]==r3[0] or r1[1]==r2[1]==r3[1] or r1[2]==r2[2]==r3[2]:
  print("Yes")
elif r1[0]==r2[1]==r3[2] or r1[2]==r2[1]==r3[0]:
  print("Yes")
else:
  print("No")

Solution (Python):
a1,a2,a3=map(int,input().split())
a4,a5,a6=map(int,input().split())
a7,a8,a9=map(int,input().split())
a=[]
d=0
a+=[a1,a2,a3,a4,a5,a6,a7,a8,a9]
n=int(input())
b=[]
for i in range(n):
    c=int(input())
    b.append(c)
for i in a:
    if b.count(i)==1:
        a[d]=0
    d+=1
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):
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n = int(input())
B = [int(input()) for _ in range(n)]



for i in B:
    if i in l1:
        l1[l1.index(i)] = 0
    if i in l2:
        l2[l2.index(i)] = 0
    if i in l3:
        l3[l3.index(i)] = 0

l4 = [l1[0], l2[0], l3[0]]
l5 = [l1[1], l2[1], l3[1]]
l6 = [l1[2], l2[2], l3[2]]
l7 = [l1[0], l2[1], l3[2]]
l8 = [l1[2], l2[1], l3[0]]

ans=[l1, l2, l3, l4, l5, l6, l7, l8]

c = 0
for i in range(8):
    if ans[i] == [0, 0, 0]:
        c += 1

if c >= 1:
    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 _ in range(N)]

A = [a11, a12, a13, a21, a22, a23, a31, a32, a33]


for k in range(N):
    for p in range(9):
        if B[k] == A[p]:
            A[p] = 0

if (A[0]==0 and A[1]==0 and A[2]==0) or (A[3]==0 and A[4]==0 and A[5]==0) or(A[6]==0 and A[7]==0 and A[8]==0) or (A[0]==0 and A[3]==0 and A[6]==0) or (A[1]==0 and A[4]==0 and A[7]==0)or(A[2]==0 and A[5]==0 and A[8]==0)or(A[0]==0 and A[4]==0 and A[8]==0)or(A[2]==0 and A[4]==0 and A[6]==0):
    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 = list()
for i in range(N):
  b.append(int(input()))
A = A1 + A2 + A3

l = list()

for i in range(9):
  cnt = b.count(A[i])
  l.append(cnt)

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

Solution (Python):
A = [0]*3
for i in range(3):
    A[i] = list(map(int,input().split()))
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))
             
for k in range(3):
    for j in range(3):
        if A[k][j] in B:
             A[k][j] = 0
answer = 'No'
for i in range(3):
    if sum(A[i])==0:
        answer = 'Yes'
        break
    count = 0
    for j in range(3):
        count += A[j][i]
    if count == 0:
        answer = 'Yes'
if A[0][0]+A[1][1]+A[2][2]==0:
    answer = 'Yes'
if A[0][2]+A[1][1]+A[2][0]==0:
    answer = 'Yes'
print(answer)

Solution (Python):
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
bs = [int(input()) for _ in range(N)]

A = np.array([A1, A2, A3])
mask = np.zeros_like(A)
for b in bs:
    mask += (A==b).astype(int)

mask = mask>0
if np.any(np.all(mask, axis=0)):
    print('Yes')
elif np.any(np.all(mask, axis=1)):
    print('Yes')
elif np.all(np.diag(mask)):
    print('Yes')
elif np.all(np.diag(mask[::-1])):
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
bs = [int(input()) for _ in range(N)]

A = np.array([A1, A2, A3])
mask = np.zeros_like(A)
for b in bs:
    mask += (A==b).astype(int)

mask = mask>0
if np.any(np.all(mask, axis=0)):
    print('Yes')
elif np.any(np.all(mask, axis=1)):
    print('Yes')
elif np.all(np.diag(mask)):
    print('Yes')

elif mask[0][2]&mask[1][1]&mask[2][0]:
    print('Yes')
else:
    print('No')

Solution (Python):
A = []

for i in range(3):
    A.append(input().split())

N = int(input())

for n in range(N):
    b = input()
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if b == col:
                A[i][j] = True

res = False
for i in range(3):
    if A[i][0] == True and A[i][1] == True and A[i][2] == True:
        res = True
    if A[0][i] == True and A[1][i] == True and A[2][i] == True:
        res = True
if A[0][0] == True and A[1][1] == True and A[2][2] == True:
    res = True
if A[2][0] == True and A[1][1] == True and A[0][2] == True:
    res = True

print('Yes') if res else print('No')

Solution (Python):
A = []

for i in range(3):
    bingo_line = input().split()
    for j in range(3):
        A.append(int(bingo_line[j]))

N = int(input())

side = [0,0,0]
vertical = [0,0,0]


for i in range(N):
    number = int(input())
    if number in A:
        xy = A.index(number)
        y = xy // 3
        x = xy % 3
        vertical[y] += 1
        side[x] += 1
        A[xy] = 0

if 3 in side:
    print('Yes')
    exit();
if 3 in vertical:
    print('Yes')
    exit();
if A[4]==0 and A[0]==0 and A[8]==0:
    print('Yes')
    exit();
elif A[4]==0 and A[2]==0 and A[6]==0:
    print('Yes')
    exit();
    
print('No')

Solution (Python):
A = [[0 for _ in range(3)] for _ in range(3)]
B = [[False for _ in range(3)] for _ in range(3)]
b = []

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

N = int(input())

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

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

judge = False

count3=0
count4=0

for i in range(3):
    count1=0
    count2=0
    
    if B[i][i]==True:
        count3 += 1
        if count3==3:
            judge=True
            break
        
    if B[2-i][i]==True:
        count4 +=1
        if count4==3:
            judge=True
            break
    
    for j in range(3):
        if B[i][j]==True:
            count1 += 1
            if count1 == 3:
                judge = True
                break
            
        if B[j][i]==True:
            count2 += 1
            if count2 == 3:
                judge = True
                break
if judge==True:
    print("Yes")
else:
    print("No")

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

if (sum(A[0]) == 0) or (sum(A[1]) == 0) or (sum(A[2]) == 0):
    print('Yes')
elif(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):
field = [[int(i) for i in input().split()] for j in range(3)]
N = int(input())
b_list = [int(input()) for n in range(N)]
bingo = False

for dan, row in enumerate(field):
    for suji, masu in enumerate(row):
        for b in b_list:
            if b == masu:
                field[dan][suji] = 0

for dan in field:
    if dan == [0, 0, 0]:
        bingo = True

hantei_list = []
i = 0
for dan in field:
    hantei_list.append(dan[i])
    i += 1
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
i = 2
for dan in field:
    hantei_list.append(dan[i])
    i -= 1
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
for dan in field:
    hantei_list.append(dan[0])
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
for dan in field:
    hantei_list.append(dan[1])
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
for dan in field:
    hantei_list.append(dan[2])
if hantei_list == [0, 0, 0]:
    bingo = True

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