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



bingos = []
for _ in range(3):
   bingo = [int(i) for i in input().split()]
   bingos.append(bingo)
  
N = int(input())

for i in range(N):
    n = int(input())
    for y in range(3):
        for x in range(3):
            if bingos[y][x] == n:
                bingos[y][x] = None

y_cnt = [0] * 3
x_cnt = [0] * 3
result = False
for y in range(3):
    for x in range(3):
        if bingos[y][x] is None:
            x_cnt[y] += 1
            y_cnt[x] += 1

if 3 in y_cnt or 3 in x_cnt:
    print('Yes')
elif bingos[0][0] is None and bingos[1][1] is None and bingos[2][2] is None:
    print('Yes')
elif bingos[0][2] is None and bingos[1][1] is None and bingos[2][0] is None:
    print('Yes')
else:
    print('No')

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

for i in range(n):
    u = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == u:
                bingo[j][k] = 0
b = 0

for l in range(3):
    if (bingo[l][0] == 0) and (bingo[l][1] == 0) and (bingo[l][2] == 0):
        b = 1
for m in range(3):
    if (bingo[0][m] == 0) and (bingo[1][m] == 0) and (bingo[2][m] == 0):
        b = 1
    
if (bingo[0][0] == 0) and (bingo[1][1] == 0) and (bingo[2][2] == 0):
    b = 1

if (bingo[0][2] == 0) and (bingo[1][1] == 0) and (bingo[0][2] == 0):
    b = 1
    
if b == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
*A,=map(int,input().split())
A=A+list(map(int,input().split()))
A=A+list(map(int,input().split()))
N=int(input())
i=0
B=[0]*N
while i<=N-1:
    B[i]=int(input())
    i+=1

for x in B:
    if x in A:
        A[A.index(x)]=0

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

bingo1 =[0,0,0]
bingo2 =[0,0,0]
bingo3 =[0,0,0]
for i in range(3):
    for j in range(N):
        if A1[i]==b[j]:
            bingo1[i]=1
        elif A2[i]==b[j]:
            bingo2[i]=1
        elif A3[i]==b[j]:
            bingo3[i]=1    


            
if bingo1[0] == bingo1[1] == bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == bingo2[1] == bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == bingo3[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[0] == bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == bingo2[1] == bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == bingo2[2] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[2] == bingo2[1] == bingo3[0] == 1:
    print("Yes")
else:
    print("No")

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

n = int(input())

for i in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b:
                a[x][y] = -1
                break

is_bingo = False

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -1 or a[0][i] == a[1][i] == a[2][i] == -1:
        is_bingo = True

if not is_bingo:
    if a[0][0] == a[1][1] == a[2][2] == -1 or a[2][0] == a[1][1] == a[0][2] == -1:
        is_bingo = True

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

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

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

if (a[0][0] == 0 and a[2][2] == 0 and a[1][1] == 0) or (a[0][2] == 0 and a[2][0] == 0 and a[1][1] == 0): 
  print("Yes")
  x = 1
for i in range(3):
  if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0 and x == 0: 
    print("Yes")
    x = 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0 and x == 0: 
    print("Yes")
    x = 1
    break
if x == 0:
  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())
lst=[a,b,c,d,e,f,g,h,i]
for i in range(int(input())):
  x=int(input())
  for j in range(9):
    if x==lst[j]:
      lst[j]=0
a,b,c,d,e,f,g,h,i=lst
tf=0
for k in [a+b+c,d+e+f,g+h+i,a+d+g,b+e+h,c+f+i,a+e+i,c+e+g]:
  if not k:
    tf=1
    break
if tf:
  print('Yes')
else:
  print('No')

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

a = []
for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[i][j])

  a.append(a_)

for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[j][i])

  a.append(a_)

a_ = []
for i in range(card_size):
  a_.append(c[i][i])

a.append(a_)

a_ = []
for i in range(card_size):
  a_.append(c[i][card_size-i-1])

a.append(a_)

maru = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
]
 
ans = 0
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        for k in range(3):
            if b == a[j][k]:
                maru[j][k] = 1
                if maru[j] == [1, 1, 1]:
                    ans = 1
 
if ans == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
A = [[int(x) for x in 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
flg = False
for i in range(3):
  if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
    flg = True
  if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
    flg = True
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
  flg = True
if A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
  flg = True
print('Yes' if flg else 'No')

Solution (Python):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())

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

maru = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
]

ans = 0
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        for k in range(3):
            if b == a[j][k]:
                maru[j][k] = 1
                if maru[j] == [1, 1, 1]:
                    ans = 1

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

Solution (Python):
A11,A12,A13 = list(map(int, input().split()))
A21,A22,A23 = list(map(int, input().split()))
A31,A32,A33 = list(map(int, input().split()))
l=[[A11,A12,A13],[A21,A22,A23],[A31,A32,A33],[A11,A22,A33],[A13,A22,A31],[A11,A21,A31],[A12,A22,A32],[A13,A23,A33]]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(8):
        if b in l[j]:
            l[j].remove(b)
f=1
for i in range(8):
    if l[i]==[]:
        print('Yes')
        f-=1
        break
if f==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)]

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

A = []
B = [[False for i in range(3)] for j in range(3)]
l = []
for i in range(3):
    A.append(iil())
    for item in A[i]:
        l.append(item)


n = ii()
for i in range(n):
    call = ii()
    if call in l:
        p = l.index(call)
        B[p//3][p%3] = True

if B[0][0]*B[0][1]*B[0][2] == 1:
    print('Yes')
elif B[1][0]*B[1][1]*B[1][2] == 1:
    print('Yes')
elif B[2][0]*B[2][1]*B[2][2] == 1:
    print('Yes')
elif B[0][0]*B[1][1]*B[2][2] == 1:
    print('Yes')
elif B[0][2]*B[1][1]*B[2][0] == 1:
    print('Yes')
elif B[0][0]*B[1][0]*B[2][0] == 1:
    print('Yes')
elif B[0][1]*B[1][1]*B[2][1] == 1:
    print('Yes')
elif B[0][2]*B[1][2]*B[2][2] == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
k = list(map(int, input().split()))
l = list(map(int, input().split()))
m = list(map(int, input().split()))
n = int(input())
count = 0


for i in range(n):
  b = int(input())
  for j in range(3):
    if k[j] == b:
      k[j] = 0
    elif l[j] == b:
      l[j] = 0
    elif m[j] == b:
      m[j] = 0


if k[0] == k[1] and k[1] == k[2]:
  count += 1
elif l[0] == l[1] and l[1] == l[2]:
  count += 1
elif m[0] == m[1] and m[1] == m[2]:
  count += 1
elif k[0] == l[1] and l[1] == m[2]:
  count += 1
elif k[2] == l[1] and l[1] == m[0]:
  count += 1
else:
  for i in range(3):
    if k[i] == l[i] and l[i] == m[i]:
      count += 1

print("Yes" if count > 0 else "No")

Solution (Python):
a=[[0]*3 for i in range(3)]
wk=[[0]*3 for i in range(3)]
a[0]=input().split()
a[1]=input().split()
a[2]=input().split()
n=int(input())
chk=False
for i in range(n):
  chk=False
  b=input()
  for j in range(3):
    if chk:
      break
    for k in range(3):
      if a[j][k]==b:
        wk[j][k]=1
        chk=True
        break
if [wk[0][0],wk[0][1],wk[0][2]]==[1,1,1]:
  print("Yes")
elif [wk[1][0],wk[1][1],wk[1][2]]==[1,1,1]:
  print("Yes")
elif [wk[2][0],wk[2][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][2],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][1],wk[1][1],wk[2][1]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][0],wk[2][0]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][1],wk[2][0]]==[1,1,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=list(int(input()) for i in range(n))
for i in range(3):
  for j in range(n):
    if a1[i]==b[j]:
      a1[i]=0
    elif a2[i]==b[j]:
      a2[i]=0
    elif a3[i]==b[j]:
      a3[i]=0
if a1[0]==a2[0]==a3[0]:
  print('Yes')
elif a1[0]==a2[1]==a3[2]:
  print('Yes')
elif a1[0]==a1[1]==a1[2]:
  print('Yes')
elif a1[1]==a2[1]==a3[1]:
  print('Yes')
elif a1[2]==a2[2]==a3[2]:
  print('Yes')
elif a1[2]==a2[1]==a3[0]:
  print('Yes')
elif a2[0]==a2[1]==a2[2]:
  print('Yes')
elif a3[0]==a3[1]==a3[2]:
  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 i in range(n)]
for i in range(3):
    for j in range(n):
        if a1[i] == b[j]:
            a1[i] = 1
        elif a2[i] == b[j]:
            a2[i] = 1
        elif a3[i] == b[j]:
            a3[i] = 1
 
if a1[0] == a1[1] == a1[2]:
    print("Yes")
elif a2[0] == a2[1] == a2[2]:
    print("Yes")
elif a3[0] == a3[1] == a3[2]:
    print("Yes")
elif a1[0] == a2[0] == a3[0]:
    print("Yes")
elif a1[1] == a2[1] == a3[1]:
    print("Yes")
elif a1[2] == a2[2] == a3[2]:
    print("Yes")
elif a1[0] == a2[1] == a3[2]:
    print("Yes")
elif a1[2] == a2[1] == a3[0]:
    print("Yes")
else:
    print("No")

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 = []
bingo_cnt = 3
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt_diag = 0
cnt_diag_rev = 0
is_bingo = False

for i in range(n):
    b.append(int(input()))
    
for i in range(len(a)):
    cnt = 0
    for j in range(len(a[i])):
        if a[i][j] in b:
            cnt = cnt + 1
            if j is 0:
                cnt1 = cnt1 + 1
            if j is 1:
                cnt2 = cnt2 + 1
            if j is 2:
                cnt3 = cnt3 + 1
            if i == j:
                cnt_diag = cnt_diag + 1
                cnt_diag_rev = cnt_diag_rev + 1
            if (i is 0 and j is 2) or (j is 0 and i is 2):
                cnt_diag_rev = cnt_diag_rev + 1
        
        if (cnt is 3 or cnt1 is 3 or cnt2 is 3 or cnt3 is 3 or cnt_diag is 3 or cnt_diag_rev is 3) and not is_bingo:
            print("Yes")
            is_bingo = True
            break

if is_bingo is False:
    print("No")

Solution (Python):
import sys
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = []
cnt = 0
for _ in range(n):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            cnt += 1
            a[i][j] = 0
if cnt < 3:
    print("No")
else:
    if a[0][0]==a[1][1]==a[2][2]:
        print("Yes")
        sys.exit()
    elif a[2][0]==a[1][1]==a[0][2]:
        print("Yes")
        sys.exit()
    else:
        for k in range(3):
            if a[k][0]==a[k][1]==a[k][2] or a[0][k]==a[1][k]==a[2][k]:
                print("Yes")
                sys.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)]
Z_1=[0,0,0]
Z_2=[0,0,0]
Z_3=[0,0,0]

for i in range(3):
    for j in range(N):
        if A_1[i]==b[j]:
            Z_1[i]=1
        elif A_2[i]==b[j]:
            Z_2[i]=1 
        elif A_3[i]==b[j]:
            Z_3[i]=1

if Z_1[0] == Z_1[1] == Z_1[2] == 1:
    print("Yes")
elif Z_2[0] == Z_2[1] == Z_2[2] == 1:
    print("Yes")
elif Z_3[0] == Z_3[1] == Z_3[2] == 1:
    print("Yes")
elif Z_1[0] == Z_2[0] == Z_3[0] == 1:
    print("Yes")
elif Z_1[1] == Z_2[1] == Z_3[1] == 1:
    print("Yes")
elif Z_1[2] == Z_2[2] == Z_3[2] == 1:
    print("Yes")
elif Z_1[0] == Z_2[1] == Z_3[2] == 1:
    print("Yes")
elif Z_1[2] == Z_2[1] == Z_3[0] == 1:
    print("Yes")
else:
    print("No")

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

N = int(input())
is_called = [False]*9
for _ in range(N):
    b = int(input())
    if b in a:
        idx = a.index(b)
        is_called[idx] = True


def isBingo(a) -> bool:
    ret = False
    
    ret |= all([a[0], a[1], a[2]])
    ret |= all([a[3], a[4], a[5]])
    ret |= all([a[6], a[7], a[8]])
    
    ret |= all([a[0], a[3], a[6]])
    ret |= all([a[1], a[4], a[7]])
    ret |= all([a[2], a[5], a[8]])
    
    ret |= all([a[0], a[4], a[8]])
    ret |= all([a[2], a[4], a[6]])
    return ret


print("Yes" if isBingo(is_called) else "No")

Solution (Python):
*inputs, = map(int, open(0).read().split())
A = inputs[:9]
B = inputs[9:]

C = [0] * 9
for b in B:
  if b in A:
    C[A.index(b)] = 1
    
if any([
     all(C[:3]), all(C[3:6]), all(C[6:]),
     all(C[::3]), all(C[1::3]), all(C[2::3]),
     all([C[0], C[4], C[8]]), all([C[2], C[4], C[6]])
    ]):
  print('Yes')
else:
  print('No')

Solution (Python):
a = input().split()
b = input().split()
c = input().split()
n = int(input())
key = []
ans = []
for i in range(n):
    key.append(input())
for i in key:
    if i in a:
        ans.append(a.index(i)+1)
for i in key:
    if i in b:
        ans.append(b.index(i)+4)
for i in key:
    if i in c:
        ans.append(c.index(i)+7)
ans.sort()
x = 0
if 1 in ans and 2 in ans and 3 in ans:
    x += 1
if 4 in ans and 5 in ans and 6 in ans:
    x += 1
if 7 in ans and 8 in ans and 9 in ans:
    x += 1
if 1 in ans and 4 in ans and 7 in ans:
    x += 1
if 2 in ans and 5 in ans and 8 in ans:
    x += 1
if 3 in ans and 6 in ans and 9 in ans:
    x += 1
if 1 in ans and 5 in ans and 9 in ans:
    x += 1
if 3 in ans and 5 in ans and 7 in ans:
    x += 1
if x > 0:
    print("Yes")
else:
    print("No")

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
rec = [[0] * 3 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:
                rec[j][k] = 1
Lotto = False

for i in range(3):
    if sum(rec[i]) == 3:
        Lotto = True
        break

for i in range(3):
    if rec[0][i] == rec[1][i] and rec[1][i] == rec[2][i]:
        if rec[0][i] == 1:
            Lotto = True
            break

if rec[1][1] == 1:
    if rec[0][0] == rec[2][2] and rec[0][0] == 1:
        Lotto = True
    if rec[0][2] == rec[2][0] and rec[0][2] == 1:
        Lotto = True

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

Solution (Python):
bingo = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
]

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 = []
for i in range(N):
    B.append(int(input()))
    
for b in B:
    for i, ai in enumerate(A):
        for j, aij in enumerate(ai):
            if b == aij:
                bingo[i][j] = 1
                break
                
if bingo[0][0] == bingo[0][1] == bingo[0][2] == 1:
    print('Yes')
elif bingo[1][0] == bingo[1][1] == bingo[1][2] == 1:
    print('Yes')
elif bingo[2][0] == bingo[2][1] == bingo[2][2] == 1:
    print('Yes')
elif bingo[0][0] == bingo[1][0] == bingo[2][0] == 1:
    print('Yes')
elif bingo[0][1] == bingo[1][1] == bingo[2][1] == 1:
    print('Yes')
elif bingo[0][2] == bingo[1][2] == bingo[2][2] == 1:
    print('Yes')
elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 1:
    print('Yes')
elif bingo[0][2] == bingo[1][1] == bingo[2][0] == 1:
    print('Yes')
else:
    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)]
Z_1 = [0, 0, 0]
Z_2 = [0, 0, 0]
Z_3 = [0, 0, 0]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j]:
            Z_1[i] = 1
        elif A_2[i] == b[j]:
            Z_2[i] = 1
        elif A_3[i] == b[j]:
            Z_3[i] = 1


if Z_1[0] == Z_1[1] == Z_1[2] == 1:
    print("Yes")
elif Z_2[0] == Z_2[1] == Z_2[2] == 1:
    print("Yes")
elif Z_3[0] == Z_3[1] == Z_3[2] == 1:
    print("Yes")
elif Z_1[0] == Z_2[0] == Z_3[0] == 1:
    print("Yes")
elif Z_1[1] == Z_2[1] == Z_3[1] == 1:
    print("Yes")
elif Z_1[2] == Z_2[2] == Z_3[2] == 1:
    print("Yes")
elif Z_1[0] == Z_2[1] == Z_3[2] == 1:
    print("Yes")
elif Z_1[2] == Z_2[1] == Z_3[0] == 1:
    print("Yes")
else:
    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)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j]:
            A_1[i] = 1
        elif A_2[i] == b[j]:
            A_2[i] = 1
        elif A_3[i] == b[j]:
            A_3[i] = 1


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

Solution (Python):

A = [ [] for _ in range(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 = [int(input()) for _ in range(N)]
L = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

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

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

Solution (Python):
import sys
A1 = list(map(int, sys.stdin.readline().split()))
A2 = list(map(int, sys.stdin.readline().split()))
A3 = list(map(int, sys.stdin.readline().split()))
N = int(sys.stdin.readline())
b = [int(sys.stdin.readline()) for _ in range(N)]
A = A1 + A2 + A3
i = 0
while i <= 8:
  if b.count(A[i]):
    A[i] = 101
  i += 1
bingoFlag = False
k = 0
while k <= 2:
  if A[k] == A[k+3] == A[k+6] or A[k*3] == A[k*3 + 1] == A[k*3 + 2]:
    bingoFlag = True
    break
  k += 1
if A[0] == A[4] == A[8] or A[2] == A[4] == A[6]:
  bingoFlag = True
if bingoFlag:
  print("Yes")
else:
  print("No")

Solution (Python):
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
bn=[int(input()) for _ in range(N)]
ans=False
for ver in zip(*A):
    if all(item in bn for item in ver):
        ans=True
for wide in A:
    if all(item in bn for item in wide):
        ans=True
if all(A[i][i] in bn for i in range(3)):
    ans=True
if all(A[i][3-i-1] in bn for i in range(3)):
    ans=True
if ans==True:
    print("Yes")
else:
    print("No")

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

c = [[False for _ in range(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] = True

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

print("Yes" if is_bingo else "No")

Solution (Python):
lst = (
    list(int(x) for x in input().split())
    + list(int(x) for x in input().split())
    + list(int(x) for x in input().split())
)

N = int(input())
lst2 = [int(input()) for _ in range(N)]
for i, n in enumerate(lst):
    if lst2.count(n) > 0:
        lst[i] = 0

if (
    sum(lst[:3]) == 0
    or sum(lst[3:6]) == 0
    or sum(lst[6:]) == 0
    or lst[0] + lst[3] + lst[6] == 0
    or lst[1] + lst[4] + lst[7] == 0
    or lst[2] + lst[5] + lst[8] == 0
    or lst[0] + lst[4] + lst[8] == 0
    or lst[2] + lst[4] + lst[6] == 0
):
    print("Yes")
else:
    print("No")

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

if tmp[4]:
    if (tmp[0] and tmp[8]) or (tmp[1] and tmp[7]) or (tmp[2] and tmp[6]) or (tmp[3] and tmp[5]):
        print("Yes")
        exit()
if tmp[0]:
    if (tmp[1] and tmp[2]) or (tmp[3] and tmp[6]):
        print("Yes")
        exit()
if tmp[8]:
    if (tmp[6] and tmp[7]) or (tmp[2] and tmp[5]):
        print("Yes")
        exit()
print("No")

Solution (Python):
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())
N = int(input())
b=[]
for _ in range(N):
    b.append(int(input()))
for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"
IsBingo = "No"
for i in range(3):
    if bingo[i][0]=="True" and bingo[i][1]=="True" and bingo[i][2]=="True":
        IsBingo="Yes"
    if bingo[0][i]=="True" and bingo[1][i]=="True" and bingo[2][i]=="True":
        IsBingo="Yes"
if (bingo[0][0]=="True" and bingo[1][1]=="True" and bingo[2][2]=="True") or (bingo[0][2]=="True" and bingo[1][1]=="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ati = [[a[0][i],a[1][i],a[2][i]] for i in range(3)]
an1 = [a[0][0],a[1][1],a[2][2]]
an2 = [a[0][2],a[1][1],a[2][0]]
for i in a:
  if all(j in b for j in i):
    print('Yes')
    exit()
for i in ati:
  if all(j in b for j in i):
    print('Yes')
    exit()
if all(j in b for j in an1):
  print('Yes')
  exit()
if all(j in b for j in an2):
  print('Yes')
  exit()
print('No')

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ati=[[a[0][i],a[1][i],a[2][i]] for i in range(3)]
an1 = [a[0][0],a[1][1],a[2][2]]
an2 = [a[2][0],a[1][1],a[0][2]]
for i in a:
  if all(j in b for j in i):
    print('Yes')
    exit()
for i in ati:
  if all(j in b for j in i):
    print('Yes')
    exit()
for i in [an1,an2]:
  if all(j in b for j in i):
    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 range(n):
            if a[i][j] == b[k]:
                a[i][j] = -1

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    print("Yes")
    exit()

if a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    print("Yes")
    exit()

for i in range(3):
    t = []
    for j in range(3):
        if a[i].count(-1) == 3:
            print("Yes")
            exit()
        t.append(a[j][i])
    if t.count(-1) == 3:
        print("Yes")
        exit()

print("No")

Solution (Python):
Ass = []

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

N = int(input())

for i in range(N) :
  b = int(input())
  for i in range(3):
    for j in range(3):
      if Ass[i][j] == b :
        Ass[i][j] = 0

for i in range(3):
  bingo1 = True
  for j in range(3):
    if Ass[i][j] != 0 :
      bingo1 = False
  if bingo1 :
    print("Yes")
    exit()

for i in range(3):
  bingo1 = True
  for j in range(3):
    if Ass[j][i] != 0 :
      bingo1 = False
  if bingo1 :
    print("Yes")
    exit()

bingo1 = True
for i in range(3):
  if Ass[i][i] != 0 :
    bingo1 = False
if bingo1 :
  print("Yes")
  exit()

bingo1 = True
for i in range(3):
  if Ass[i][2-i] != 0 :
    bingo1 = False
if bingo1 :
  print("Yes")
  exit()

print("No")

Solution (Python):
a=[[int(j) for j in input().split()]for i in range(3)]
n=int(input())
s=set()
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                s.add((j+1,k+1))

for i in range(1,4):
    p,q=0,0
    for j in range(1,4):
        if (i,j) in s:
            p+=1
        if (j,i) in s:
            q+=1
    if p==3 or q==3:
        print("Yes")
        exit()
p,q=0,0
for i in range(1,4):
    if (i,i) in s:
        p+=1
    if (i,4-i) in s:
        q+=1
if p==3 or q==3:
    print("Yes")
    exit()

print("No")

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

check = [[ False ] * 3 for i in range(3)]

for i in range(n):
    number = b[i]
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == number:
                check[j][k] = True

check_t = [list(x) for x in zip(*check)]

for i in range(3):
    if sum(check[i]) == 3 or sum(check_t[i]) == 3:
        print("Yes")
        exit()

if check[0][0] == check[1][1] == check[2][2] == True or check[2][0] == check[1][1] == check[0][2] == 1:
    print("Yes")
    exit()

print("No")

Solution (Python):
def main():
    a = [list(map(int, input().split())) for i in range(3)]
    n = int(input())
    result = [[0,0,0],[0,0,0],[0,0,0]]
    for i in range(n):
        b = int(input())
        flag = False
        for i in range(3):
            for j in range(3):
                if a[i][j] == b:
                    flag = True
                    result[i][j] = 1
                    break
            if flag:
                break
    for i in range(3):
        ans = 0
        for j in range(3):
            ans += result[i][j]
        if ans == 3:
            break
    if ans == 3:
        print("Yes")
        return
    for i in range(3):
        ans = 0
        for j in range(3):
            ans += result[j][i]
        if ans == 3:
            break
    if ans == 3:
        print("Yes")
        return
    if result[0][0]+result[1][1]+result[2][2]==3 or result[0][2]+result[1][1]+result[2][0]==3:
        print("Yes")
        return
    print("No")
main()

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
punch = [[0] * 3 for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
Yes = 0
for i in range(3):
    for j in range(3):
        for k in range(N):
            if b[k] == A[i][j]:
                punch[i][j] = 1
                break
if punch[0][0] == 1:
    if punch[0][1] == 1:
        if punch[0][2] == 1:
            Yes = 1
if punch[0][0] == 1:
    if punch[1][1] == 1:
        if punch[2][2] == 1:
            Yes = 1
if punch[0][0] == 1:
    if punch[1][0] == 1:
        if punch[2][0] == 1:
            Yes = 1
if punch[1][0] == 1:
    if punch[1][1] == 1:
        if punch[1][2] == 1:
            Yes = 1
if punch[2][0] == 1:
    if punch[2][1] == 1:
        if punch[2][2] == 1:
            Yes = 1
if punch[2][0] == 1:
    if punch[1][1] == 1:
        if punch[0][2] == 1:
            Yes = 1
if punch[0][1] == 1:
    if punch[1][1] == 1:
        if punch[2][1] == 1:
            Yes = 1
if punch[0][2] == 1:
    if punch[1][1] == 1:
        if punch[2][0] == 1:
            Yes = 1
if punch[0][2] == 1:
    if punch[1][2] == 1:
        if punch[2][2] == 1:
            Yes = 1
            
if Yes == 1:
    print("Yes")
else:
    print("No")