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

N = int(input())

bolls = []
for _ in range(N):
    bolls.append( int(input()) )

checklist = [[0,0,0],[0,0,0],[0,0,0]]

for idx1, nums in enumerate(cards):
    for idx2, num  in enumerate(nums):
        for boll in bolls:
            if num == boll:
                checklist[idx1][idx2] = 1

ans = 'No'

if checklist[0][0] and checklist[1][1] and checklist[2][2]:
    ans = 'Yes'

if checklist[0][2] and checklist[1][1] and checklist[2][0]:
    ans = 'Yes'

if checklist[0][0] and checklist[0][1] and checklist[0][2]:
    ans = 'Yes'

if checklist[1][0] and checklist[1][1] and checklist[1][2]:
    ans = 'Yes'

if checklist[2][0] and checklist[2][1] and checklist[2][2]:
    ans = 'Yes'


if checklist[0][0] and checklist[1][0] and checklist[2][0]:
    ans = 'Yes'

if checklist[0][1] and checklist[1][1] and checklist[2][1]:
    ans = 'Yes'

if checklist[0][2] and checklist[1][2] and checklist[2][2]:
    ans = 'Yes'

print(ans)

Solution (Python):
bingo1 = [int(x) for x in input().split()]
bingo2 = [int(x) for x in input().split()]
bingo3 = [int(x) for x in input().split()]

N = int(input())
for _ in range(N):
    b = int(input())
    bingo1 = [0 if x == b else x for x in bingo1]
    bingo2 = [0 if x == b else x for x in bingo2]
    bingo3 = [0 if x == b else x for x in bingo3]

bingos = [bingo1, bingo2, bingo3]
flag = "No"
if sum(bingo1) * sum(bingo2) * sum(bingo3) == 0:
    flag = "Yes"
else:
    tbingo1 = [x[0] for x in bingos]
    tbingo2 = [x[1] for x in bingos]
    tbingo3 = [x[2] for x in bingos]
    if sum(tbingo1) * sum(tbingo2) * sum(tbingo3) == 0:
        flag = "Yes"
    else:
        nbingo1 = [0 if bingos[i][i] == b else bingos[i][i] for i, x in enumerate(bingos)]
        nbingo2 = [0 if bingos[i][2-i] == b else bingos[i][2-i] for i, x in enumerate(bingos)]
        if sum(nbingo1) * sum(nbingo2) == 0:
            flag = "Yes"
print(flag)

Solution (Python):
import numpy as np

if __name__ == "__main__":
  _data_list = []
  tmp_list = list(map(int, input().split()))
  _data_list.append(tmp_list)
  _rows = len(tmp_list)
  for i in range(_rows-1):
    _data_list.append(list(map(int, input().split())))
  _data_list = np.array(_data_list)

  flag_matrix = np.zeros((3,3),dtype=np.bool)
  _n = int(input())
  _b = []
  for i in range(_n):
    _b.append(int(input()))

  for data in _b:
    flag_matrix = np.logical_or(flag_matrix,_data_list == data)

  if np.all(flag_matrix[0]) or np.all(flag_matrix[1]) or np.all(flag_matrix[2]) or np.all(flag_matrix[:,0]) or np.all(flag_matrix[:,1]) or np.all(flag_matrix[:,2]) or (flag_matrix[0,0]*flag_matrix[1,1]*flag_matrix[2,2]) or (flag_matrix[0,2]*flag_matrix[1,1]*flag_matrix[2,0]):
    print('Yes')
  else:
    print('No')

Solution (Python):
import numpy as np
ans=[0]*9
A=[0]*3
answer=0
for i in range(3):
    A[i]=list(map(int,input().split()))
N=int(input())
b=[0]*N
for j in range(N):
    b[j]=int(input())
def checkyoko(card):
    a=0
    for k in range(3):
        if card[k]==[1,1,1]:
            a=1
    return a
def checktate(card):
    a=0
    for l in range(3):
        if [card[0][l],card[1][l],card[2][l]]==[1,1,1]:
            a=1
    return a
def nanamecheck(card):
    a=0
    if [card[0][0],card[1][1],card[2][2]]==[1,1,1] or [card[0][2],card[1][1],card[2][0]]==[1,1,1]:
        a=1
    return a
counter=0
for m in range(3):
    for n in range(3):
        if A[m][n]in b:
            ans[counter]=1
        counter+=1
ans=np.array(ans)
ans=ans.reshape(3,3)
ans=ans.tolist()
answer=(checktate(ans)==1 or checkyoko(ans)==1 or nanamecheck(ans)==1)

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

Solution (Python):
a = [[0 for i in range(3)] for j in range(3)]
for i in range(3):
    a[i] = [int(j) for j in input().split()]

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


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

f = 0
for i in range(3):
    if sum(a[i]) == 0:
        f = 1
        break

for i in range(3):
    tmp = 0
    for j in range(3):
        tmp += a[j][i]
    if tmp == 0:
        f = 1
        break

if a[0][0] + a[1][1] + a[2][2] == 0:
    f = 1
if a[0][2] + a[1][1] + a[2][0] == 0:
    f = 1

if f == 1:
    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(N):
    for j in range(3):
        for k in range(3):
            if b[i]==A[j][k]:
                A[j][k]=0
 
List=[]
                
sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[i][j]
    List.append(sum)
 
sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[j][i]
    List.append(sum)
 
sum = 0
for i in range(3):
    sum=sum+A[i][i]
List.append(sum)
 
sum= 0
for i in range(3):
    sum =sum+A[i][2-i]
List.append(sum)
 
ans=0
for i in range(len(List)):
    if List[i]==0:
        ans = ans +1
 
if ans !=0:
    print('Yes')
else:
    print('No')

Solution (Python):
P = [input().split() for i in range(3)]
N = int(input())
b = [input() for i in range(N)]

P_ = [[0,0,0] for _ in range(3)]
for j in range(3):
    for i in range(3):
        if P[i][j] in b:
            P_[i][j] = 1
        else:
            P_[i][j] = 0
            
ans = 'No'


for i in range(3):
    if [P_[i][j] for j in range(3)] == [1,1,1]:
        ans = 'Yes'
        

for i in range(3):
    if [P_[j][i] for j in range(3)] == [1,1,1]:
        ans = 'Yes'
        
if [P_[i][2 - i] for i in range(3)] == [1,1,1]:
    ans = 'Yes'
        
if [P_[i][i] for i in range(3)] == [1,1,1]:
    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)]

a_ = [[0]*3 for _ in range(3)]
for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a_[j][k] = 1
                
count = 0
for i in range(3):
    count += (a_[i][0]+a_[i][1]+a_[i][2])//3
    count += (a_[0][i]+a_[1][i]+a_[2][i])//3
    
count += (a_[0][0]+a_[1][1]+a_[2][2])//3
count += (a_[0][2]+a_[1][1]+a_[2][0])//3

if count > 0:
    print('Yes')
else:
    print('No')

Solution (Python):


A_list=[[int(j) for j in input().split()] for i in range(3)]
N = int(input().strip())
b_list=[int(input().strip()) for _ in range(N)]


for num in b_list:
    for ai in range(3):
        for aj in range(3):
            if num == A_list[ai][aj]:
                A_list[ai][aj] = "O"

Flag=False
for i in range(3):
    if A_list[i][0]==A_list[i][1]==A_list[i][2]=="O":
        Flag = True
    if A_list[0][i]==A_list[1][i]==A_list[2][i]=="O":
        Flag = True

if A_list[0][0]==A_list[1][1]==A_list[2][2]=="O":
    Flag = True
if A_list[2][0]==A_list[1][1]==A_list[0][2]=="O":
    Flag = True

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

Solution (Python):
import math


def ag(li):
    return (li[0][0] and li[0][1] and li[0][2]) \
        or (li[1][0] and li[1][1] and li[1][2]) \
        or (li[2][0] and li[2][1] and li[2][2]) \
        or (li[0][0] and li[1][0] and li[2][0]) \
        or (li[0][1] and li[1][1] and li[2][1]) \
        or (li[0][2] and li[1][2] and li[2][2]) \
        or (li[0][0] and li[1][1] and li[2][2]) \
        or (li[0][2] and li[1][1] and li[2][0])


card = [list(map(int, input().split())) for i in range(3)]
n = int(input())
bList = [input() for _ in range(n)]
tList = [[False, False, False], [False, False, False], [False, False, False]]

for i, b in enumerate(bList):
    for j, c1 in enumerate(card):
        for k, c2 in enumerate(c1):
            if c2 == int(b):
                tList[k][j] = True

if ag(tList):
    print("Yes")
else:
    print("No")

Solution (Python):
import itertools

A = []
A1 = [int(i) for i in input().split()]
A.append(A1)
A2 = [int(i) for i in input().split()]
A.append(A2)
A3 = [int(i) for i in input().split()]
A.append(A3)

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




N = int(input ())
b = [input().split() for i in range(N)]
b= list(itertools.chain.from_iterable(b))
b = list(map(int, b))

for i in range(3):
    for j in range(3):
        for x in b:
            if A[i][j] == x:
                f[i][j] = 1
s = 0

for i in range(3):
    if sum(f[i]) == 3:
        s = 1
    if f[0][0] + f[1][1] + f[2][2] == 3:
        s = 1
    if f[0][2] + f[1][1] + f[2][0] == 3:
        s = 1
    for j in range(3):
        if f[0][j] + f[1][j] + f[2][j] == 3:
            s = 1
        
                
        
if s == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))

n = int(input())
li_call = []
for i in range(n):
  li_call.append(int(input()))
for i in range(n):
  for j in range(3):
    if li_a[j] == li_call[i]:
      li_a[j] = 0
  for k in range(3):
    if li_b[k] == li_call[i]:
      li_b[k] = 0
  for l in range(3):
    if li_c[l] == li_call[i]:
      li_c[l] = 0
li_o = [0, 0, 0]
li_d = [li_a[0], li_b[0], li_c[0]]
li_e = [li_a[1], li_b[1], li_c[1]]
li_f = [li_a[2], li_b[2], li_c[2]]
li_g = [li_a[0], li_b[1], li_c[2]]
li_h = [li_a[2], li_b[1], li_c[0]]
if li_a == li_o:
  print("Yes")
elif li_b == li_o:
  print("Yes")
elif li_c == li_o:
  print("Yes")
elif li_d == li_o:
  print("Yes")
elif li_e == li_o:
  print("Yes")
elif li_f == li_o:
  print("Yes")
elif li_g == li_o:
  print("Yes")
elif li_h == li_o:
  print("Yes")

else:
  print("No")

Solution (Python):
li=[list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b=int(input())
    for i in range(3):
        li[i] = [0 if j == b else j for j in li[i]]
for i in range(3):
    if li[i][0]==0 and li[i][1]==0 and li[i][2]==0:
        print("Yes")
        exit(0)
for i in range(3):
    if li[0][i]==0 and li[1][i]==0 and li[2][i]==0:
        print("Yes")
        exit(0)
if li[0][0]==0 and li[1][1]==0 and li[2][2]==0:
    print("Yes")
    exit(0)
if li[2][0]==0 and li[1][1]==0 and li[0][2]==0:
    print("Yes")
    exit(0)
print("No")

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

N = int(input())

for n in range(N):
    b = int(input())
    for i in range(3):
        for l in range(3):
            if A[i][l] == b:
                A[i][l] = 0
                
if (
    (A[0][0] == 0 and A[0][1] ==0 and A[0][2] ==0 ) or 
    (A[1][0] == 0 and A[1][1] ==0 and A[1][2] ==0 ) or 
    (A[2][0] == 0 and A[2][1] ==0 and A[2][2] ==0 ) or 
    (A[0][0] == 0 and A[1][0] ==0 and A[2][0] ==0 ) or 
    (A[0][1] == 0 and A[1][1] ==0 and A[2][1] ==0 ) or 
    (A[0][2] == 0 and A[1][2] ==0 and A[2][2] ==0 ) or 
    (A[0][0] == 0 and A[1][1] ==0 and A[2][2] ==0 ) or 
    (A[0][2] == 0 and A[1][1] ==0 and A[2][0] ==0 )
):
    print("Yes")
else:
    print("No")

Solution (Python):
A_11,A_12,A_13 = map(int, input().split())
A_21,A_22,A_23 = map(int, input().split())
A_31,A_32,A_33 = map(int, input().split())
N=int(input())
b = []
for _ in range(N):
    b.append(int(input()))

A_11j,A_12j,A_13j,A_21j,A_22j,A_23j,A_31j,A_32j,A_33j=[0,0,0,0,0,0,0,0,0]
r=[]
if A_11 in b:
  A_11j=1
if A_12 in b:
  A_12j=1
if A_13 in b:
  A_13j=1
if A_21 in b:
  A_21j=1
if A_22 in b:
  A_22j=1
if A_23 in b:
  A_23j=1
if A_31 in b:
  A_31j=1
if A_32 in b:
  A_32j=1
if A_33 in b:
  A_33j=1

  
if(A_11j==1)&(A_12j==1)&(A_13j==1):
  r="Yes"
elif(A_21j==1)&(A_22j==1)&(A_23j==1):
  r="Yes"
elif(A_31j==1)&(A_32j==1)&(A_33j==1):
  r="Yes"
elif(A_11j==1)&(A_21j==1)&(A_31j==1):
  r="Yes"
elif(A_12j==1)&(A_22j==1)&(A_32j==1):
  r="Yes"
elif(A_13j==1)&(A_23j==1)&(A_33j==1):
  r="Yes"
elif(A_11j==1)&(A_22j==1)&(A_33j==1):
  r="Yes"
elif(A_13j==1)&(A_22j==1)&(A_31j==1):
  r="Yes"
else:
  r="No"
  
print(r)

Solution (Python):
line1 = input()
line2 = input()
line3 = input()
bingo = [0 for i in range(9)]
ans_bingo = [0 for i in range(9)]

bingo[0], bingo[1], bingo[2] = line1.split(" ")
bingo[3], bingo[4], bingo[5] = line2.split(" ")
bingo[6], bingo[7], bingo[8] = line3.split(" ")

n = input()
for i in range(int(n)):
    b = input()
    if b in bingo:
        index = bingo.index(b)
        ans_bingo[index] = "1"

if ans_bingo[0] == "1" and ans_bingo[1] == "1" and ans_bingo[2] == "1":
    print("Yes")
elif ans_bingo[3] == "1" and ans_bingo[4] == "1" and ans_bingo[5] == "1":
    print("Yes")
elif ans_bingo[6] == "1" and ans_bingo[7] == "1" and ans_bingo[8] == "1":
    print("Yes")
elif ans_bingo[0] == "1" and ans_bingo[3] == "1" and ans_bingo[6] == "1":
    print("Yes")
elif ans_bingo[1] == "1" and ans_bingo[4] == "1" and ans_bingo[7] == "1":
    print("Yes")
elif ans_bingo[2] == "1" and ans_bingo[5] == "1" and ans_bingo[8] == "1":
    print("Yes")
elif ans_bingo[0] == "1" and ans_bingo[4] == "1" and ans_bingo[8] == "1":
    print("Yes")
elif ans_bingo[2] == "1" and ans_bingo[4] == "1" and ans_bingo[6] == "1":
    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)]

bingo=[[0]*3 for _ in range(3)]
for i in range(n):
  for ai in range(3):
    for aj in range(3):
      if A[ai][aj]==B[i]:
        bingo[ai][aj]=1
flag=False
if bingo[0][0]==bingo[0][1]==bingo[0][2]==1: flag=True
if bingo[1][0]==bingo[1][1]==bingo[1][2]==1: flag=True
if bingo[2][0]==bingo[2][1]==bingo[2][2]==1: flag=True
  
if bingo[0][0]==bingo[1][0]==bingo[2][0]==1: flag=True
if bingo[0][1]==bingo[1][1]==bingo[2][1]==1: flag=True
if bingo[0][2]==bingo[1][2]==bingo[2][2]==1: flag=True
  
if bingo[0][0]==bingo[1][1]==bingo[2][2]==1: flag=True
if bingo[0][2]==bingo[1][1]==bingo[2][0]==1: flag=True
if flag:
  print('Yes')
else:
  print('No')

Solution (Python):

a_1 = input().split()
a_2 = input().split()
a_3 = input().split()
a = [a_1,a_2,a_3]
n = int(input())
b = []
for i in range(n):
    b.append(input())



def ana(card,nums):
    for i in range(len(card)):
        for n in nums:
            replaced = ["0" if k == n else k for k in card[i]]
            card[i] = replaced





def bingo_or_not(list):
    flag = 0
    if len(set(list[0])) == 1 or len(set(list[1])) == 1 or len(set(list[2])) == 1:
        flag = 1
    elif list[0][0] == list[1][0] and list[0][0] == list[2][0]:
        flag = 1
    elif list[0][1] == list[1][1] and list[0][1] == list[2][1]:
        flag = 1
    elif list[0][2] == list[1][2] and list[0][2] == list[2][2]:
        flag = 1
    elif list[0][0] == list[1][1] and list[0][0] == list[2][2]:
        flag = 1
    elif list[0][2] == list[1][1] and list[0][2] == list[2][0]:
        flag = 1
    if flag == 0:
        return False
    else:
        return True


ana(a,b)


if bingo_or_not(a) == True:
    print("Yes")
else:
    print("No")

Solution (Python):
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()]
A = [A_0,A_1,A_2]
N = int(input())
B = set()
for i in range(N):
    B.add(int(input()))
for i in range(3):
    C = {A[k][i] for k in range(3)}
    D = {A[i][k] for k in range(3)}
    if C <= B or D <= B:
            print("Yes")
            break
else:
    if {A[0][0],A[1][1],A[2][2]} <= B or {A[0][2],A[1][1],A[2][0]} <= B:
        print("Yes")
    else :
        print("No")

Solution (Python):
def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    ans = [[0] * 3 for _ in range(3)]
    for b in B:
        for i, a in enumerate(A):
            g = my_index(a, b)
            if g != 'no':
                ans[i][g] = 1
    for r in range(3):
        if 1 == ans[0][r] == ans[1][r] == ans[2][r]:
            print('Yes')
            exit()
    for r in range(3):
        if 1 == ans[r][0] == ans[r][1] == ans[r][2]:
            print('Yes')
            exit()
    if 1 == ans[0][0] == ans[1][1] == ans[2][2]:
        print('Yes')
        exit()
    if 1 == ans[0][2] == ans[1][1] == ans[2][0]:
        print('Yes')
        exit()
    print('No')

def my_index(l, x):
    return l.index(x) if x in l else 'no'

if __name__ == '__main__':
    main()

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

N=int(input())

A=[]

for i in range(N):
    A.append(int(input()))
ans = list(set(A))

for i in range(3):
    for j in range(3):
        if bingo[i][j] in ans: score[i][j]=1

flg=0

col=[0]*3

for i in range(3):
    col[0]+=score[i][0]
    col[1]+=score[i][1]
    col[2]+=score[i][2]

for i in range(3):
    if col[i] == 3: flg=1
        

for i in score:
    if sum(i) == 3: flg=1


S1=score[0][0]+score[1][1]+score[2][2]
S2=score[2][0]+score[1][1]+score[0][2]

if S1 == 3: flg=1
if S2 == 3: flg=1
    
print("Yes" if flg==1 else "No")

Solution (Python):




A1 = list(input().split())
A2 = list(input().split())
A3 = list(input().split())
n = int(input())

if n <= 2:
    print("No")
    exit()

B = []
for _ in range(n):
    B.append(input())

for i in B:
    if i in A1:
        A1[A1.index(i)] = "
    if i in A2:
        A2[A2.index(i)] = "
    if i in A3:
        A3[A3.index(i)] = "


flag = 0
for i in range(3):
    if A1[i] == "
        flag += 1
    if A2[i] == "
        flag += 1
    if A3[i] == "
        flag += 1
    if flag != 3:
        flag = 0
    if flag == 3:
        print("Yes")
        exit()

if A1[0] == "
    print("Yes")
    exit()

if A2[0] == "
    print("Yes")
    exit()

if A3[0] == "
    print("Yes")
    exit()

if A1[0] == "
    print("Yes")
    exit()

if A3[0] == "
    print("Yes")
    exit()

print("No")

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
alist = [a1[0] ,a1[1] ,a1[2], a2[0], a2[1], a2[2], a3[0], a3[1], a3[2]]
n = int(input())
b = [int(input()) for _ in range(n)]
ans = 'No'
for i in b:
    for ji, jv in enumerate(alist):
        if i == jv:
            alist[ji] = 0

if sum(alist[0:3]) == 0:
    ans = 'Yes'
if sum(alist[3:6]) == 0:
    ans = 'Yes'
if sum(alist[6:9]) == 0:
    ans = 'Yes'
if sum(alist[0::3]) == 0:
    ans = 'Yes'
if sum(alist[1::3]) == 0:
    ans = 'Yes'
if sum(alist[2::3]) == 0:
    ans = 'Yes'
if (alist[0] + alist[4] + alist[8]) == 0:
    ans = 'Yes'
if (alist[2] + alist[4] + alist[6]) == 0:
    ans = 'Yes'
print(ans)

Solution (Python):
a=[0]
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
n=int(input())
for i in range(n):
    b=int(input())
    for k in range(10):
        if a[k]==b:
            a[k]=0
t="No"
if a[1]==0 and a[2]==0 and a[3]==0:
    t="Yes"
if a[4]==0 and a[5]==0 and a[6]==0:
    t="Yes"
if a[7]==0 and a[8]==0 and a[9]==0:
    t="Yes"
if a[1]==0 and a[4]==0 and a[7]==0:
    t="Yes"
if a[2]==0 and a[5]==0 and a[8]==0:
    t="Yes"
if a[3]==0 and a[6]==0 and a[9]==0:
    t="Yes"
if a[1]==0 and a[5]==0 and a[9]==0:
    t="Yes"
if a[3]==0 and a[5]==0 and a[7]==0:
    t="Yes"

print(t)

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

a = a1 + a2 + a3

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

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

Solution (Python):
import sys
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = list(int(x) for x in sys.stdin.read().split())
if len(B) < 3:
  print('No')
  exit()
comb = []
for b in B:
  if b in A1:
    comb.append("1" + str(A1.index(b) + 1))
  elif b in A2:
    comb.append("2" + str(A2.index(b) + 1))
  elif b in A3:
    comb.append("3" + str(A3.index(b) + 1))
bingo_cond = ["111213", "212223", "313233", "112131", "112233", "132231", "132333"]
from itertools import combinations
for c in combinations(comb, 3):
  s = "".join(x for x in sorted(c))
  if s in bingo_cond:
    print('Yes')
    exit()
print('No')

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

for el in number:
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == el:
                bingo[i][j] = 0
flag = 0
for i in range(3):
    for j in range(3):
        if bingo[i][j] != 0:
            break
    else:
        flag = 1
        
for i in range(3):
    for j in range(3):
        if bingo[j][i] != 0:
            break
    else:
        flag = 1
    
if bingo[0][0] == 0:
    if bingo[1][1] == 0:
        if bingo[2][2] == 0:
            flag = 1
            
if bingo[0][2] == 0:
    if bingo[1][1] == 0:
        if bingo[2][0] == 0:
            flag = 1
            
if flag == 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())

A = a1 + a2 + a3

b = [0]*9
for i in range(N):
    bingo = int(input())
    for j in range(len(A)):
        if bingo == A[j]:
            b[j] = 1

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

Solution (Python):
a = [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 a[j][k] == b:
                a[j][k] = 0

cross = 0
ucross = 0
for j in range(3):
    if sum(a[j][:]) == 0 or sum([row[j] for row in a]) == 0:
        print("Yes")
        exit()
    cross += a[j][j]
    ucross += a[2-j][j]
if cross == 0 or ucross == 0:
    print("Yes")
    exit()

print("No")

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    A = [[int(i) for i in input().split()] for _ in range(3)]
    O = [[False] * 3 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: O[i][j] = True

    for i in range(3):
        if False in O[i]: continue
        else:
            print("Yes")
            break
    else:
        for i in range(3):
            if O[0][i] == O[1][i] == O[2][i] == True:
                print("Yes")
                break
        else:
            if O[0][0] == O[1][1] == O[2][2] == True: print("Yes")
            elif O[0][2] == O[1][1] == O[2][0] == True: print("Yes")
            else: print("No")

    return 0

if __name__ =="__main__":
    solve()

Solution (Python):
t = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
m = [int(input()) for i in range(n)]
x = 0
for i in range(3):
        if t[i][0] in m and t[i][1] in m and t[i][2] in m:
            print('Yes')
            break
        elif t[0][i] in m and t[1][i] in m and t[2][i] in m:
            print('Yes')
            break
        elif t[0][0] in m and t[1][1] in m and t[2][2] in m:
            print('Yes')
            break
        elif t[0][2] in m and t[1][1] in m and t[2][0] in m:
            print('Yes')
            break
        else:
            x += 1
if x == 3:
    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 i in range(n)]
f=False
for i in range(3):
    for j in range(n):
        if l1[i]==b[j]:
            l1[i]=0
        elif l2[i]==b[j]:
            l2[i]=0
        elif l3[i]==b[j]:
            l3[i]=0
for i in range(3):
    if l1[i]==l2[i] and l2[i]==l3[i] and l1[i]==l3[i]:
        f=True
if l1[0]==l1[1] and l1[1]==l1[2] and l1[0]==l1[2]:
    f=True
elif l2[0]==l2[1] and l2[1]==l2[2] and l2[0]==l2[2]:
    f=True
elif l3[0]==l3[1] and l3[1]==l3[2] and l3[0]==l3[2]:
    f=True
elif l1[0]==0 and l2[1]==0 and l3[2]==0:
    f=True
elif l3[0]==0 and l1[2]==0 and l2[1]==0:
    f=True
    
if f==True:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
A = [list(map(int, input().split())) for i in range(0,3)]
N = int(input())
b_list =list([int(input()) for i in range(0,N)])
count = np.zeros((3,3))
for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b_list:
            count[i][j] = count[i][j] + 1
if (count.sum(axis=1)  ==3).any():
    print('Yes')
elif (count.sum(axis=0) ==3).any():
    print('Yes')
elif count[0][0] + count[1][1] + count[2][2]==3:
    print('Yes')
elif count[2][0] + count[1][1] + count[0][2]==3:
    print('Yes')
else:
    print('No')

Solution (Python):
a = []
for i in range(3):
    row = list(map(int, input().split()))
    a += row
    
result = [1] * 9
    
n = int(input())
for j in range(n):
    k = int(input())
    try:
        c = a.index(k)
        result[c] = 0
    except ValueError:
        continue

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

Solution (Python):
import sys
L = []
bingo = set()
Numbers = []
testor = 0
for i in range(3):
  a,b,c = map(int,input().split())
  L.append((a,b,c)) 
N = int(input())
for i in range(3):
  a = L[0][i] 
  b = L[1][i]
  c = L[2][i]
  L.append((a,b,c))
a = L[0][0]
b = L[1][1]
c = L[2][2]
L.append((a,b,c))
a = L[2][0] 
b = L[1][1]
c = L[0][2]
L.append((a,b,c))
for i in range(N):
  Numbers.append(int(input()))
for i in range(8): 
  bingo = L[i]
  for k in range(N):
    if Numbers[k] in bingo:
      testor += 1
    if testor == 3:
        print('Yes')
        sys.exit(0)
  testor = 0
print('No')

Solution (Python):
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)

if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Solution (Python):
from sys import stdin

def main():
    input = stdin.readline

    A = [[0] * 3 for i in range(3)]
    F = [[0] * 3 for i in range(3)]

    A[0][0],A[0][1],A[0][2] = map(int,input().split())
    A[1][0],A[1][1],A[1][2] = map(int,input().split())
    A[2][0],A[2][1],A[2][2] = map(int,input().split())

    N = int(input())

    B = []
    for _ in range(N):
        B.append(int(input()[:-1]))
    B.sort()
    
    for i in range(3):
        for j in range(3):
            for b in B:
                if(A[i][j] == b):
                    F[i][j] = True
                    break

    
    for i in range(3):
        if(F[i][0]) & (F[i][1]) & (F[i][2]):
            print("Yes")
            return
    for i in range(3):
        if(F[0][i]) & (F[1][i]) & (F[2][i]):
            print("Yes")
            return
    if (F[0][0]) & (F[1][1]) & (F[2][2]):
        print("Yes")
        return
    if (F[2][0]) & (F[1][1]) & (F[0][2]):
        print("Yes")
        return

    print("No")

if __name__ == "__main__":
    main()

Solution (Python):
A1 = input().split()
A2 = input().split()
A3 = input().split()

A1 = [int(i) for i in A1]
A2 = [int(i) for i in A2]
A3 = [int(i) for i in A3]

A = []
A.append(A1)
A.append(A2)
A.append(A3)

B = [[0,0,0],[0,0,0],[0,0,0]]

N = int(input())
vals = []
for i in range(N):
  vals.append(int(input()))

for val in vals:
  if A[0][0] == val:
    B[0][0] = 1
  elif A[0][1] == val:
    B[0][1] = 1
  elif A[0][2] == val:
    B[0][2] = 1
  elif A[1][0] == val:
    B[1][0] = 1
  elif A[1][1] == val:
    B[1][1] = 1
  elif A[1][2] == val:
    B[1][2] = 1
  elif A[2][0] == val:
    B[2][0] = 1
  elif A[2][1] == val:
    B[2][1] = 1
  elif A[2][2] == val:
    B[2][2] = 1

isGood = False
for i in range(3):
  if B[i][0] + B[i][1] + B[i][2] == 3:
    isGood = True

for i in range(3):
  if B[0][i] + B[1][i] + B[2][i] == 3:
    isGood = True
    
if B[0][0] + B[1][1] + B[2][2] == 3:
  isGood = True

if B[2][0] + B[1][1] + B[0][2] == 3:
  isGood = True
  
if isGood == True:
  print("Yes")
else:
  print("No")

Solution (Python):
def check(A,b):
    for raw in range(3):
        for colomn in range(3):
            if A[raw][colomn] == b:
                A[raw][colomn] = -1
                return
    return

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
is_bingo = 'No'
for _ in range(N):
    b = int(input())
    check(A,b)

for raw in range(3):
    if A[raw][0] + A[raw][1] + A[raw][2] == -3:
        is_bingo = 'Yes'

for colomn in range(3):
    if A[0][colomn] + A[1][colomn] + A[2][colomn] == -3:
        is_bingo = 'Yes'

if A[0][0] + A[1][1] + A[2][2] == -3:
    is_bingo = 'Yes'
if A[0][2] + A[1][1] + A[2][0] == -3:
    is_bingo = 'Yes'

print(is_bingo)