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):
ab = []
for _ in range(3):
    a, b, c = (int(x) for x in input().split())
    ab.append([a, b, c])
dp = [[0 for i in range(3)] for j in range(3)] 
n=int(input())

for _ in range(n):
    t=int(input())
    for i in range(3):
        for j in range(3):
            if ab[i][j] == t:
                dp[i][j] = 1

for i in range(3):
    if 0 not in dp[i]:
        print('Yes')
        exit()

for i in range(3):
    if dp[0][i] == 1 and dp[1][i] == 1 and dp[2][i] == 1:
        print('Yes')
        exit()
if dp[0][0] == 1 and dp[1][1] == 1 and dp[2][2] == 1:
    print('Yes')
    exit()
elif dp[0][2] == 1 and dp[1][1] == 1 and dp[0][2] == 1:
    print('Yes')
    exit()
else:
    print('No')

Solution (Python):
bingo = [0 for i in range(9)]
check = [False for i in range(9)]
complete = [[0, 1, 2], [3, 4, 5], [6, 7, 8],
            [0, 3, 6], [1, 4, 7], [2, 5, 8],
            [0, 4, 8], [2, 4, 6]]
for i in [0, 3, 6]:
    bingo[i], bingo[i+1], bingo[i+2] = map(int, input().split(" "))

N = int(input())
for i in range(N):
    bi = int(input())
    try:
        number_index = bingo.index(bi)
    except:
        continue
    if number_index != -1:
        check[number_index] = True

Yes = False
for a, b, c in complete:
    if True == check[a] == check[b] == check[c]:
        print("Yes")
        Yes = True
        break
if Yes == False:
    print("No")

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = set(int(input()) for _ in range(N))
hit = [[False] * 3 for _ in range(3)]

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

cond = [all(hit[r]) for r in range(3)]
if any(cond):
    print("Yes")
    exit()

cond = [all(hit[r][c] for r in range(3)) for c in range(3)]
if any(cond):
    print("Yes")
    exit()

cond = [
    all(hit[i][i] for i in range(3)),
    hit[0][2] and hit[1][1] and hit[2][0]
]
if any(cond):
    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()))


N = int(input())
for i in range(N):
  bingo_num = int(input())
  if bingo_num in A1:
    A1[A1.index(bingo_num)] = 0
  if bingo_num in A2:
    A2[A2.index(bingo_num)] = 0
  if bingo_num in A3:
    A3[A3.index(bingo_num)] = 0
if A1.count(0) == 3 or A2.count(0) == 3 or A3.count(0) == 3\
or A1[0]+A2[0]+A3[0] == 0 or A1[1]+A2[1]+A3[1] == 0 or A1[2]+A2[2]+A3[2] == 0\
or A1[0]+A2[1]+A3[2] == 0 or A1[2]+A2[1]+A3[0]==0:
  print("Yes")
else:
  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):
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))


if (a1[0] in b) and (a1[1] in b) and (a1[2] in b):
    print("Yes") 
    exit()

if (a2[0] in b) and (a2[1] in b) and (a2[2] in b):
    print("Yes") 
    exit()

if (a3[0] in b) and (a3[1] in b) and (a3[2] in b):
    print("Yes") 
    exit()

if (a1[0] in b) and (a2[0] in b) and (a3[0] in b):
    print("Yes") 
    exit()
    
if (a1[1] in b) and (a2[1] in b) and (a3[1] in b):
    print("Yes") 
    exit()

if (a1[2] in b) and (a2[2] in b) and (a3[2] in b):
    print("Yes") 
    exit()

if (a1[0] in b) and (a2[1] in b) and (a3[2] in b):
    print("Yes") 
    exit()

if (a1[2] in b) and (a2[1] in b) and (a3[0] in b):
    print("Yes") 
    exit()

print("No")
exit()

Solution (Python):
ary = []
for i in range(0, 3):
    ary.append(list(map(int, input().split())))
n = int(input())
ans = False
call = []
for i in range(0, n):
    call.append(int(input()))

for i in range(0, 3):
    
    if (ary[i][0] in call and ary[i][1] in call and ary[i][2] in call):
        print("Yes")
        exit()
    
    if (ary[0][i] in call and ary[1][i] in call and ary[2][i] in call):
        print("Yes")
        exit()

for i in range(0, 2):
    if (ary[0][0] in call and ary[1][1] in call and ary[2][2] in call) or (ary[0][2] in call and ary[1][1] in call and ary[2][0] in call):
        print("Yes")
        exit()
print("No")

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

c = [[a[0][0], a[0][1], a[0][2]],
    [a[1][0], a[1][1], a[1][2]],
    [a[2][0], a[2][1], a[2][2]],
    [a[0][0], a[1][0], a[2][0]],
    [a[0][1], a[1][1], a[2][1]],
    [a[0][2], a[1][2], a[2][2]],
    [a[0][0], a[1][1], a[2][2]],
    [a[0][2], a[1][1], a[2][0]]]

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

for i in c:
    flag = True
    for j in i:
        if j not in b:
            flag = False
            continue
    if flag:
        print("Yes")
        break
else:
    print("No")

Solution (Python):


A = []
for i in range(3):
    A.append(list(map(int,input().split())))
    
N = int(input())
Flg = False
F = [[1 for i in range(3)] for j in range(3)]

for i in range(N):
    m = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == m:
                F[j][k] = 0

for i in range(3):
    if list(set(F[i])) == [0]:
        Flg = True
        break

for i in range(3):
    if F[0][i]==F[1][i]==F[2][i]==0:
        Flg = True
        break

if F[0][0]==F[1][1]==F[2][2]==0 or F[0][2]==F[1][1]==F[2][0]==0:
    Flg = True

if Flg:
    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())

A = A_1 + A_2 + A_3

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

bingo = [
    A[0] + A[1] + A[2],
    A[3] + A[4] + A[5],
    A[6] + A[7] + A[8],
    A[0] + A[3] + A[6],
    A[1] + A[4] + A[7],
    A[2] + A[5] + A[8],
    A[0] + A[4] + A[8],
    A[2] + A[4] + A[6],
    ]

if 0 in bingo:
    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):
    if a1[i] in b:
        a1[i] = "o"
        
for i in range(3):
    if a2[i] in b:
        a2[i] = "o"
        
for i in range(3):
    if a3[i] in b:
        a3[i] = "o"
        
if a1[0]==a1[1]==a1[2] or a2[0]==a2[1]==a2[2] or a3[0]==a3[1]==a3[2] or a1[0]==a2[0]==a3[0] or a1[1]==a2[1]==a3[1] or a1[2]==a2[2]==a3[2] or a1[0]==a2[1]==a3[2] or a1[2]==a2[1]==a3[0]:
    print("Yes")
else:
    print("No")

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

n = int(input())

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


def check(a):
    for i in range(3):
        for j in range(3):
            if bc[i][j] == a:
                bc[i][j] = 0
                return


for k in range(len(lb)):
    check(lb[k])

ans = False

for i in range(3):
    if sum(bc[i]) == 0:
        ans = True
        break

    if bc[0][i] + bc[1][i] + bc[2][i] == 0:
        ans = True
        break


if bc[0][0] + bc[1][1] + bc[2][2] == 0:
    ans = True

if bc[2][0] + bc[1][1] + bc[0][2] == 0:
    ans = True

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

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

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

ans = False
if bingo[0][0]==bingo[0][1]==bingo[0][2]==True:
    ans=True
if bingo[1][0]==bingo[1][1]==bingo[1][2]==True:
    ans=True
if bingo[2][0]==bingo[2][1]==bingo[2][2]==True:
    ans=True
if bingo[0][0]==bingo[1][0]==bingo[2][0]==True:
    ans=True
if bingo[0][1]==bingo[1][1]==bingo[2][1]==True:
    ans=True
if bingo[0][2]==bingo[1][2]==bingo[2][2]==True:
    ans=True
if bingo[0][0]==bingo[1][1]==bingo[2][2]==True:
    ans=True
if bingo[2][0]==bingo[1][1]==bingo[0][2]==True:
    ans=True
print('Yes' if ans else 'No')

Solution (Python):
def main():
    import numpy as np
    A=[]
    for _ in range(3):
        A.append(list(map(int,input().split())))
    
    R=np.zeros((3,3))
    K=[]
    for a in A:
        K+=a

    N=int(input())
    for i in range(N):
        b=int(input())
        if b not in K:
            continue
        
        idx=K.index(b)
        R[idx//3,idx%3]=1

    if any( all(x) for x in R.tolist()) or any(all(x) for x in R.T.tolist()):
        print('Yes')
    elif R[0,0] and R[1,1] and R[2,2] or R[0,2] and R[1,1] and R[2,0]:
        print('Yes')
    else:
        print('No')
        
main()

Solution (Python):
a1 =list( map(int,input().split()))
a2 =list( map(int,input().split()))
a3 =list( map(int,input().split()))
N = int(input())
flag = False
for i in range(N):
    num = int(input())
    for i in range(3):
        if num == a1[i]:
            a1[i] = 0
        if num == a2[i]:
            a2[i] = 0
        if num == a3[i]:
            a3[i] = 0
if sum(a1) == 0:
    flag = True
if sum(a2) == 0:
    flag = True
if sum(a3) == 0:
    flag = True

for i in range(3):
    if a1[i] + a2[i] + a3[i] == 0:
        flag = True

if a1[0] + a2[1] + a3[2] == 0:
    flag = True

if a1[2] + a2[1] + a3[0] == 0:
    flag = True

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

Solution (Python):
b = list(map(int, input().split()))
tmp1 = list(map(int, input().split()))
tmp2 = list(map(int, input().split()))
b.extend(tmp1)
b.extend(tmp2)
answer = [False]*9
N = int(input())
for i in range(N):
    num = int(input())
    if num in b:
        answer[b.index(num)] = True
if (answer[0] and answer[1] and answer[2]) or (answer[3] and answer[4] and answer[5]) or (answer[6] and answer[7] and answer[8]) or (answer[1-1] and answer[4-1] and answer[7-1]) or (answer[2-1] and answer[5-1] and answer[8-1]) or (answer[3-1] and answer[6-1] and answer[9-1]) or (answer[1-1] and answer[5-1] and answer[9-1]) or (answer[3-1] and answer[5-1] and [7-1]):
    print("Yes")
else:
    print("No")

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

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

bingo=np.zeros((3,3),int)
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            bingo[i][j]=1

flag=False
for x in bingo.sum(axis=1):
    if x ==3:
        flag=True
for x in bingo.sum(axis=0):
    if x ==3:
        flag=True
y=0
for i in range(3):
    y+=bingo[i,i]
if y==3:
    flag=True
y=0
for i in range(3):
    y+=bingo[2-i,i]
if y==3:
    flag=True

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

Solution (Python):
card = [list(map(int,input().split(' '))) for j in range(3)]
N = int(input())
called = set([int(input()) for i in range(N)])
for x,i in enumerate(card):
    for y,j in enumerate(i):
        if j in called:
            card[x][y] = 0
for i in range(3):
    if sum(card[i])==0:
        print('Yes')
        exit()
    if sum([card[j][i] for j in range(3)])==0:
        print('Yes')
        exit()
if (card[0][0]+card[1][1]+card[2][2])==0 or (card[0][2]+card[1][1]+card[2][0])==0:
    print('Yes')
    exit()
print('No')

Solution (Python):


a_1, a_2, a_3 = map(int, input().split())
a_4, a_5, a_6 = map(int, input().split())
a_7, a_8, a_9 = map(int, input().split())

a_list = []

a_list.append([a_1, a_2, a_3])
a_list.append([a_4, a_5, a_6])
a_list.append([a_7, a_8, a_9])
a_list.append([a_1, a_4, a_7])
a_list.append([a_2, a_5, a_8])
a_list.append([a_3, a_6, a_9])
a_list.append([a_1, a_5, a_9])
a_list.append([a_3, a_5, a_7])

N = int(input())
for i in range(N):
    b = int(input())
    for a in a_list:
        if b in a:
            a.pop(a.index(b))

ans = False
for a in a_list:
    if len(a)==0:
        ans = True
        break

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

Solution (Python):
A = []

for _ in range(3):
  for e in list(map(int, input().split())):
    A.append(e)

N = int(input())

for _ in range(N):
  n = int(input())
  if n in A:
    A[A.index(n)] = 0

patterns = [
  [0, 1, 2],
  [3, 4, 5],
  [6, 7, 8],
  [0, 3, 6],
  [1, 4, 7],
  [2, 5, 8],
  [0, 4, 8],
  [2, 4, 6]
]

for pattern in patterns:
  if not any([A[e] for e in pattern]):
    print('Yes')
    exit()

print('No')

Solution (Python):
nums = []

for i in range(3):
    nums.append([int(n) for n in input().split(" ")])

bingo_list = []

bingo_list.extend(nums)
for i in range(3):
    bingo_list.append([nums[0][i], nums[1][i], nums[2][i]])
bingo_list.append([nums[0][0], nums[1][1], nums[2][2]])
bingo_list.append([nums[2][0], nums[1][1], nums[0][2]])

is_bingo = False
n = int(input())
for i in range(n):
    num = int(input())
    for bingo in bingo_list:
        if num in bingo:
            bingo.remove(num)
            if not bingo:
                is_bingo = True

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

Solution (Python):
A = [[int(i) for i in input().split()] for _ in range(3)]
B = [[False, False, False], [False, False, False], [False, False, False]]
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:
                B[j][k]=True
for r in B:
    if all(r):
        print("Yes")
        quit()

for c in zip(*B):
    if all(c):
        print("Yes")
        quit()

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

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):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            idx = a[j].index(b)
            a[j][idx] = 0

for k in range(3):
    if sum(a[k]) == 0:  
        print('Yes')
        exit()
    elif a[0][k] + a[1][k] + a[2][k] == 0:
        print("Yes")
        exit()
if a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
A = list(map(int,input().split()))
B =list(map(int,input().split()))
C = list(map(int,input().split()))

N = int(input())

for i in range(N):
    X = int(input())
    
    if X in A:
        A[A.index(X)] = 0
    
    if X in B:
        B[B.index(X)] = 0
    
    if X in C:
        C[C.index(X)] = 0
        
ans = False
for i in range(3):
    
    if A[i]+ B[i] + C[i] ==0:
        ans = True
        
if sum(A)==0 or sum(B)==0 or sum(C)==0 or A[0] + B[1] + C[2] == 0 or A[2] + B[1] + C[0] == 0:
    ans = True
    
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):





inp = []
for i in range(3):
    a = list(map(int, input().split()))
    inp.append(a)
res = []
for _ in range(int(input())):
    res.append(int(input()))
for i in range(3):
    for j in range(3):
        for k in res:
            if inp[i][j] == k:
                inp[i][j] = -1
r1, r2, r3, c1, c2, c3, d1, d2 = 0, 0, 0, 0, 0, 0, 0, 0
for i in range(3):
    if inp[i][0] == -1:
        r1 += 1
    if inp[i][1] == -1:
        r2 += 1
    if inp[i][2] == -1:
        r3 += 1
    if inp[0][i] == -1:
        c1 += 1
    if inp[1][i] == -1:
        c2 += 1
    if inp[2][i] == -1:
        c3 += 1
    if inp[i][i] == -1:
        d1 += 1
if inp[0][2] == inp[1][1] == inp[2][0] == -1:
    d2 += 3
if r1 == 3 or r2 == 3 or r3 == 3 or c1 == 3 or c2 == 3 or c3 == 3 or d1 == 3 or d2 == 3:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
readline = sys.stdin.buffer.readline

lst1 = [list(map(int,readline().split())) for i in range(3)]

n = int(readline())

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

for i in range(n):
    b = int(readline())
    for i in range(3):
        for j in range(3):
            if lst1[i][j] == b:
                lstans[i][j] = 1
flag = 0
for i in range(3):
    if sum(lstans[i]) == 3:
        flag = 1
for i in range(3):
    res = 0
    for j in range(3):
        res += lstans[j][i]
    if res == 3:
        flag = 1

if lstans[0][0] + lstans[1][1] + lstans[2][2] == 3:
    flag = 1
if lstans[0][2] + lstans[1][1] + lstans[2][0] == 3:
    flag = 1

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

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

answer = 'No'
for i in range(3):
    count = 0
    for j in range(3):
        number = a_lst[i][j]
        if number in b_lst:
            count += 1

    if count==3:
        answer = 'Yes'
        break

if answer=='No':
    for i in range(3):
        count = 0
        for j in range(3):
            number = a_lst[j][i]
            if number in b_lst:
                count += 1

        if count==3:
            answer = 'Yes'
            break

if answer=='No':
    lu = a_lst[0][0]
    ru = a_lst[0][2]
    cen = a_lst[1][1]
    ld = a_lst[2][0]
    rd = a_lst[2][2]

    if lu in b_lst:
        if cen in b_lst:
            if rd in b_lst:
                answer = 'Yes'

    if ru in b_lst:
        if cen in b_lst:
            if ld in b_lst:
                answer = 'Yes'

print(answer)

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

n = int(input())

res = [[0,0,0],[0,0,0],[0,0,0]]

for _ in range(n):
    b = int(input())
    for i in range(3):
        if b in A[i]:
            index = A[i].index(b)
            res[i][index] = 1

if res[0][0] & res[0][1] & res[0][2] or res[1][0] & res[1][1] & res[1][2] or res[2][0] & res[2][1] & res[2][2] or res[0][0] & res[1][0] & res[2][0] or res[0][1] & res[1][1] & res[2][1] or res[0][2] & res[1][2] & res[2][2] or res[0][0] & res[1][1] & res[2][2] or res[0][2] & res[1][1] & res[2][0]:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

A = np.zeros((3,3),int)
for i in range(3):
    A[i,:] = np.array([int(x) for x in input().split()])
    
N = int(input())

for _ in range(N):
    b = int(input())
    A[A==b] = 0

ans = 'No'
if np.sum(A[0,:])==0 or np.sum(A[1,:])==0 or np.sum(A[2,:])==0 or np.sum(A[:,0])==0 or np.sum(A[:,1])==0 or np.sum(A[:,2])==0 or np.sum(A[0,0]+A[1,1]+A[2,2])==0 or np.sum(A[0,2]+A[1,1]+A[2,0])==0:
   ans = 'Yes'

print(ans)

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

for i in range(3):
  if A[i][0]==0 and A[i][1]==0 and A[i][2]==0:
    print("Yes");exit()

for j in range(3):
  if A[0][j]==0 and A[1][j]==0 and A[2][j]==0:
    print("Yes");exit()
    
if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
  print("Yes");exit()
if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  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)]

C = [A[0],
     A[1],
     A[2],
     [A[0][0], A[1][0], A[2][0]],
     [A[0][1], A[1][1], A[2][1]],
     [A[0][2], A[1][2], A[2][2]],
     [A[0][0], A[1][1], A[2][2]],
     [A[0][2], A[1][1], A[2][0]]]

for n in B:
    for i in range(8):
        for j in range(3):
            if C[i][j] == n:
                C[i][j] = 0

for i in range(8):
    C[i] = sum(C[i])

if 0 in C:
    print('Yes')
else:
    print('No')

Solution (Python):

As = []
As += list(map(int,(input().split())))
As += list(map(int,(input().split())))
As += list(map(int,(input().split())))
N = int(input())
bingo = [0] * 9
for b in range(N):
    b = int(input())
    if b in As:
        bingo[As.index(b)] = 1    


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

Solution (Python):
def main(a,n,b):
    check = [[0]*3 for _ in range(3)]
    for i in range(n):
        val = b[i]
        for row in range(3):
            for col in range(3):
                if a[row][col] == val:
                    check[row][col] = 1
    res = judge(check)
    return res

def judge(check):
    if ((check[0][0] * check[0][1] * check[0][2] == 1)
        or (check[1][0] * check[1][1] * check[1][2] == 1)
        or (check[2][0] * check[2][1] * check[2][2] == 1)
        or (check[0][0] * check[1][0] * check[2][0] == 1)
        or (check[0][1] * check[1][1] * check[2][1] == 1)
        or (check[0][2] * check[1][2] * check[2][2] == 1)
        or (check[0][0] * check[1][1] * check[2][2] == 1)
        or (check[2][0] * check[1][1] * check[0][2] == 1)):
        return "Yes"
    return "No"



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

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

visits=[0 for i in range(9)]
k=int(input())
for i in range(k):
  n=int(input())
  if n in ha:
    x=ha.index(n)
    visits[x]=1
if visits[0:3]==[1,1,1] or visits[3:6]==[1,1,1] or visits[6:9]==[1,1,1]:
  print("Yes")
elif [1,1,1] in ([visits[0],visits[3],visits[6]],[visits[1],visits[4],visits[7]],[visits[2],visits[5],visits[8]]):
  print("Yes")
elif [1,1,1] in ([visits[0],visits[4],visits[8]],[visits[2],visits[4],visits[6]]):
  print("Yes")
else:
  print("No")

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

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

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

Solution (Python):
a=[[j for j in input().split()] for _ in range(3)]
n=int(input())
b=[input() for i in range(n)]
ans=[[0 for i in range(3)] for j in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            ans[i][j]=1
flg=False
for i in range(3):
    if all([ans[i][j]==1 for j in range(3)]):
        flg=True
    if all([ans[j][i]==1 for j in range(3)]):
        flg=True
if all([ans[i][i]==1 for i in range(3)]):
    flg=True
if all([ans[i][2-i]==1 for i in range(3)]):
    flg=True
    
print('Yes' if flg else 'No')

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

ans="No"
for i in range(3):
    
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        ans="Yes"
        break
    
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        ans="Yes"
        break

if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        ans="Yes"
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
        ans="Yes"

print(ans)

Solution (Python):
import sys









mod = int(1e9+7)
INF = 1<<29

def main():
    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 b == a[j][k]:
                    a[j][k] = 0
    ans = 1
    for i in range(3):
        ans = 1
        for j in range(3):
            if a[i][j]:
                ans = 0
                break
        if ans:
            print("Yes")
            return
    for j in range(3):
        ans = 1
        for i in range(3):
            if a[i][j]:
                ans = 0
                break
        if ans:
            print("Yes")
            return
    ans = 1
    for i in range(3):
        if a[i][i]:
            ans = 0
            break
    if ans:
        print("Yes")
        return
    if a[2][0] or a[1][1] or a[0][2]:
        print("No")
        return
    print("Yes")
    return

if __name__=='__main__':
    main()

Solution (Python):
def f():
  a1 = list(map(int, input().split()))
  a2 = list(map(int, input().split()))
  a3 = list(map(int, input().split()))
  A = a1+a2+a3

  N = int(input())

  c = [False]*9

  for i in range(N):
    b = int(input())
    if b in A:
      c[A.index(b)] = True

  for i in range(3):
    if c[i] and c[3+i] and c[6+i]:
      return 'Yes'
    elif c[3*i] and c[3*i+1] and c[3*i+2]:
      return 'Yes'

  if c[0] and c[4] and c[8]:
    return 'Yes'
  elif c[2] and c[4] and c[6]:
    return 'Yes'

  return 'No'
print(f())

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):
card = []
for i in range(3):
  card += list(map(int, input().split()))
N = int(input())
bingo = [(1, 2, 3), (4, 5, 6), (7, 8, 9), (1, 4, 7), (2, 5, 8), (3, 6, 9), (1, 5, 9), (3, 5, 7)]
for i in range(N):
  n = int(input())
  if n in card:
    card[card.index(n)] = "hit"

ans = "No"
for patt in bingo:
  if card[patt[0]-1] == card[patt[1]-1] == card[patt[2]-1] == "hit":
    ans = "Yes"
    break
print(ans)

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
R = [[0,0,0],[0,0,0],[0,0,0]]
Rt = [[0,0,0],[0,0,0],[0,0,0]] 
for i in range(3):
  for j in range(3):
    for k in range(N):
      if(A[i][j] == B[k]):
        R[i][j] = 1
        Rt[j][i] = 1
        break
bingo = [1,1,1]
if(R[0] == bingo or R[1] == bingo or R[2] == bingo):
  print("Yes")
elif(Rt[0] == bingo or Rt[1] == bingo or Rt[2] == bingo):
  print("Yes")
elif([R[0][0], R[1][1], R[2][2]] == bingo or [R[0][2], R[1][1], R[2][0]] == bingo):
  print("Yes")
else:
  print("No")

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

x = [[0] * 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:
                x[i][j] = 1

for i in range(3):
    if sum(x[i]) == 3:
        print('Yes')
        exit()
s0 = 0
s1 = 0
s2 = 0
for i in range(3):
    s0 += x[i][0]
    s1 += x[i][1]
    s2 += x[i][2]
if s0 == 3 or s1 == 3 or s2 == 3:
    print('Yes')
    exit()
if x[0][0] + x[1][1] + x[2][2] == 3:
    print('Yes')
    exit()
if x[0][2] + x[1][1] + x[2][0] == 3:
    print('Yes')
    exit()
print('No')

Solution (Python):
A = []
import sys
for i in range(3):
  A += [[int(c) for c in input().split()]]
N = int(input())
dic = [0]*101
for i in range(N):
  b = int(input())
  dic[b] = 1
for j in range(3):
  for i in range(3):
    if dic[A[j][i]]==0:
      break
  else:
    print('Yes')
    sys.exit()
for i in range(3):
  for j in range(3):
    if dic[A[j][i]]==0:
      break
  else:
    print('Yes')
    sys.exit()
for i in range(3):
  if dic[A[i][i]]==0:
    break
else:
  print('Yes')
  sys.exit()
for i in range(3):
  if dic[A[2-i][i]]==0:
    break
else:
  print('Yes')
  sys.exit()
print('No')

Solution (Python):
A = [list(map(int, input().split())) for i 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

for i in range(3):
  if A[i][0] + A[i][1] + A[i][2] == 0:
    print('Yes')
    exit()

for j in range(3):
  if A[0][j] + A[1][j] + A[2][j] == 0:
    print('Yes')
    exit()

if A[0][0] + A[1][1] + A[2][2] == 0 or A[0][2] + A[1][1] + A[2][0] == 0:
  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(N):
    for j in range(3):
        if B[i] in A[j]:
            index_v = A[j].index(B[i])
            A[j][index_v] = 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')