Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

Solution (Python):
A = []

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

N = int(input())
ans=[]
for _ in range(N):
    b=int(input())
    for i in range(3):
        if(b in A[i]):
            ans.append([i+1,A[i].index(b)+1])
            break
tate=False
if(ans == []):
    print("No")
else:
    counter1=[0,0,0]
    counter2=[0,0,0]
    counter3=0
    counter4=0
    two=False
    for a in ans:
        if(a[0]==1):
            counter1[0]+=1
        elif(a[0] == 2):
            counter1[1]+=1
        elif(a[0] == 3):
            counter1[2]+=1

        if(a[1] == 1):
            counter2[0]+=1
        elif(a[1] == 2):
            counter2[1]+=1
        elif(a[1] == 3):
            counter2[2]+=1
        if(a[0] == a[1] ):
            counter3+=1
        if((a[0] == 1 and a[1] == 3) or (a[1]==1 and a[0]==3)):
            counter4+=1
        if(a[0] == 2 and a[1] == 2):
            two=True
    if(3 in counter1 or 3 in counter2 or counter3 >=3 or (two==True and  counter4==2)):
        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)]

Size = 3
bingo = False
for row in a:
    if all(item in b for item in row):
        bingo = True
for col in zip(*a):
    if all(item in b for item in col):
        bingo = True
if all(a[i][i] in b for i in range(Size)):
    bingo = True
if all(a[i][Size - 1 - i] in b for i in range(Size)):
    bingo = True
 
print("Yes" if bingo else "No")

Solution (Python):
import sys 
A = [input().split() for l in range(3)]
N = int(input())

b = ['0'] * N
for i in range(0,N):
    b[i] = input()

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

for i in range(0,3):
    count = 0
    for j in range(0,3):
        if A[i][j] == '0':
            count += 1
    if count == 3:
        print('Yes')
        sys.exit()

for j in range(0,3):
    count = 0
    for i in range(0,3):
        if A[i][j] == '0':
            count += 1
    if count == 3:
        print('Yes')
        sys.exit()

if A[0][0] == '0' and A[1][1] == '0' and A[2][2] == '0':
    print('Yes')
    sys.exit()
elif A[0][2] == '0' and A[1][1] == '0' and A[2][0] == '0':
    print('Yes')
    sys.exit()
else:
    print('No')
    sys.exit()

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

for i in B:
    for j in range(len(A)):
        if i == A[j]:
            A[j] = 0
if A[0]+A[1]+A[2] == 0 or A[3]+A[4]+A[5] == 0 or A[6]+A[7]+A[8] == 0 or A[0]+A[3]+A[6] == 0 or A[1]+A[4]+A[7] == 0 or A[2]+A[5]+A[8] == 0 or A[0]+A[4]+A[8] == 0 or A[2]+A[4]+A[6] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

ll = [[int(x) for x in input().split()] for y in range(3)]

n = int(input())

for i in range(n):
    b = int(input())
    for ii in range(3):
        if b in ll[ii]:
            ll[ii][ll[ii].index(b)] = 0

for i in range(3):
    if ll[i][0] == ll[i][1] == ll[i][2] == 0:
        print("Yes")
        sys.exit()
    if ll[0][i] == ll[1][i] == ll[2][i] == 0:
        print("Yes")
        sys.exit()

if ll[0][0] == ll[1][1] == ll[2][2] == 0 or ll[0][2] == ll[1][1] == ll[2][0] == 0:
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
import sys

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


for i in range(3):
    for j in range(3):
        for x in range(N):
            if A[i][j]==b[x]:
                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")
        sys.exit(0)
for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        print("Yes")
        sys.exit(0)
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print("Yes")
    sys.exit(0)
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    print("Yes")
    sys.exit(0)
print("No")

Solution (Python):
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
 
bingo = [[0 for i in range(3)] for j in range(3)]
 
for i in range(N):
  key = int(input())
  for j in range(3):
    for k in range(3):
      if card[j][k] == key:
        bingo[j][k] += 1

for i in range(3):
  if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
    print('Yes')
    exit()
for i in range(3):
  if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
    print('Yes')
    exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
for i in range(3):
  a = list(map(int,input().split()))
  for j in range(3):
    d[a[j]] = 3*i+j+1
f = [False for _ in range(10)]

N = int(input())
for _ in range(N):
  b = int(input())
  f[d[b]] = True
  
ans = False

for i in range(3):
  ans = ans or (f[3*i+1] and f[3*i+2] and f[3*i+3])
  ans = ans or (f[i+1] and f[i+4] and f[i+7])
  
ans = ans or (f[1] and f[5] and f[9])
ans = ans or (f[3] and f[5] and f[7])

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

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

bingo = [[0]*3 for _ in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if card[j][k] == An[i]:
                bingo[j][k] += 1

for i in range(3):
    if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
        print('Yes')
        exit()
for i in range(3):
    if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
        print('Yes')
        exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')

Solution (Python):
a1_list = list(map(int, input().split()))
a2_list = list(map(int, input().split()))
a3_list = list(map(int, input().split()))

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


def is_bingo(a_coor):
    if a_coor[0][0] + a_coor[1][0] + a_coor[2][0] == 0:
        return True
    elif a_coor[0][1] + a_coor[1][1] + a_coor[2][1] == 0:
        return True
    elif a_coor[0][2] + a_coor[1][2] + a_coor[2][2] == 0:
        return True
    elif a_coor[0][0] + a_coor[0][1] + a_coor[0][2] == 0:
        return True
    elif a_coor[1][0] + a_coor[1][1] + a_coor[1][2] == 0:
        return True
    elif a_coor[2][0] + a_coor[2][1] + a_coor[2][2] == 0:
        return True
    elif a_coor[0][0] + a_coor[1][1] + a_coor[2][2] == 0:
        return True
    elif a_coor[2][0] + a_coor[1][1] + a_coor[0][2] == 0:
        return True
    return False


for b in b_list:
    a1_list = [0 if a==b else a for a in a1_list]
    a2_list = [0 if a==b else a for a in a2_list]
    a3_list = [0 if a==b else a for a in a3_list]
if is_bingo([a1_list, a2_list, a3_list]):
    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 for _ in range(3)] for _ in range(3)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                bingo[j][k] += 1

for i in range(3):
    if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
        print('Yes')
        exit()
for i in range(3):
    if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
        print('Yes')
        exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')

Solution (Python):
ls=[int(s) for s in input().split()]
ls=ls+[int(s) for s in input().split()]
ls=ls+[int(s) for s in input().split()]
N=int(input())
for _ in range(N):
  a=int(input())
  for i in range(9):
    if ls[i]==a:
      ls[i]=0
if ((ls[0]+ls[1]+ls[2])
    *(ls[3]+ls[4]+ls[5])
    *(ls[6]+ls[7]+ls[8])
    *(ls[0]+ls[3]+ls[6])
    *(ls[1]+ls[4]+ls[7])
    *(ls[2]+ls[5]+ls[8])
    *(ls[0]+ls[4]+ls[8])
    *(ls[2]+ls[4]+ls[6]))==0:
  print('Yes')
else:
  print('No')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    from itertools import product
    BINGO = [[(i, j) for j in range(3)] for i in range(3)] + \
            [[(j, i) for j in range(3)] for i in range(3)] + \
            [[(0, 0), (1, 1), (2, 2)], [(0, 2), (1, 1), (2, 0)]]
    C = {A[i][j]:(i, j) for i, j in product(range(3), repeat=2)}
    D = tuple(map(lambda x: C.get(x, None), b))
    for B in BINGO:
        if all(p in D for p in B):
            return True
    return False



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    print(YES if solve(A, N, b) else NO)

if __name__ == '__main__':
    main()

Solution (Python):

def judge(A):
    flag = 'No'
    for j in range(3):
        if A[0][j]==0 and A[1][j]==0 and A[2][j]==0:
            flag = 'Yes'
            break
        if A[j][0]==0 and A[j][1]==0 and A[j][2]==0:
            flag = 'Yes'
            break
    if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
        flag = 'Yes'
    elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
        flag = 'Yes'
    print(flag)
    
def main():
    import sys
    A = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]
    N = int(sys.stdin.readline())
    B = [int(sys.stdin.readline()) for _ in range(N)]
    
    
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                A[i][j] =0
    
    judge(A)



        


if __name__ == '__main__':
    main()

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

N = int(input())
b = [0 for i in range (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:
      Ab[i][j] = 1
isbingo = False
for i in range(3):
  if (Ab[0][i] == Ab[1][i] == Ab[2][i] == 1\
      or Ab[i][0] == Ab[i][1] == Ab[i][2] == 1):
    isbingo = True
if (Ab[0][0] == Ab[1][1] == Ab[2][2] == 1\
   or Ab[0][2] == Ab[1][1] == Ab[2][0] == 1):
  isbingo = True
if isbingo:
  print('Yes')
else:
  print('No')

Solution (Python):
a=[]
c=[[False] * 3 for i in range(3)]
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()))

for i in b:
    for j in range(3):
        if(i in a[j]):
            t=a[j].index(i)
            c[j][t]=True

ans="No"
for i in range(3):
    if(c[i][0]==True and c[i][1]==True and c[i][2]==True):ans="Yes"
for i in range(3):
    if(c[0][i]==True and c[1][i]==True and c[2][i]==True):ans="Yes"
for i in range(3):
    if(c[i][i]==False):break
else:ans="Yes"

for i in range(3):
    if(c[2-i][i]==False):break
else:ans="Yes"
print(ans)

Solution (Python):
import numpy as np

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

N =  int(input())

for line in range(N):
	b=int(input())
	for a in range(3):
		for a_1 in range(3):
			if A[a][a_1]==b:
				A[a][a_1]=0
ans=[]
A_r=np.array(A).T.tolist()
ANS="No"
for k in range(3):
	if sum(A[k])==0 or sum(A_r[k])==0:
		ANS="Yes"
		break

if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
	ANS="Yes"
if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
	ANS="Yes"

print(ANS)

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a=n3(3)
n=n0()
b=n2(n)

c=[[0,0,0] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j]=1
ans="No"
for i in range(3):
    if sum(c[i])==3:
        ans="Yes"
    if c[0][i]+c[1][i]+c[2][i]==3:
        ans="Yes"
if c[0][0]+c[1][1]+c[2][2]==3 or c[0][2]+c[1][1]+c[2][0]==3:
    ans="Yes"
print(ans)

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

N = int(input())
lst = [int(input()) for i in range(N)]

for l in lst:
    for i in range(3):
        if a[i] == l:
            a[i] = "〇"
        if b[i] == l:
            b[i] = "〇"
        if c[i] == l:
            c[i] = "〇"
            
if a[0] == a[1] == a[2]:
    print("Yes")
elif b[0] == b[1] == b[2]:
    print("Yes")
elif c[0] == c[1] == c[2]:
    print("Yes")
elif a[0] == b[0] == c[0]:
    print("Yes")
elif a[1] == b[1] == c[1]:
    print("Yes")
elif a[2] == b[2] == c[2]:
    print("Yes")
elif a[0] == b[1] == c[2]:
    print("Yes")
elif a[2] == b[1] == c[0]:
    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,row in enumerate(a):
    for j,x in enumerate(row):
        if x in b:
            a[i][j] = 0
bingo = False
for row in a:
    if row == [0]*3:
        bingo = True
for j in range(3):
    if a[0][j] == 0 and a[1][j] == 0 and a[2][j] == 0:
        bingo = True
if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    bingo = True
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    bingo = True

if bingo:
    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)]
mark = [[False, False, False] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True

ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break      
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

Solution (Python):
def check(list1):
    if(list1[0][0]==0 and list1[1][1]==0 and list1[2][2]==0):
        return "Yes"
    if(list1[1][1]==0 and list1[0][2]==0 and list1[2][0]==0):
        return "Yes"
    for i in range(3):
        count=0
        for j in range(3):
            if(list1[i][j]==0):
                count+=1
        if(count==3):
            return "Yes"
    for i in range(3):
        count=0
        for j in range(3):
            if(list1[j][i]==0):
                count+=1
        if(count==3):
            return "Yes"
    return "No" 
list1=[]
for i in range(3):
    list2=list(map(int,input().strip().split()))[:3]
    list1.append(list2)
n=int(input())
list3=[]
for i in range(n):
    list3.append(int(input()))
for i in list3:
    for j in range(3):
        for k in range(3):
            if(list1[j][k]==i):
                list1[j][k]=0
print(check(list1))

Solution (Python):
import numpy as np
A1 = list(map(int, input().strip().split()))
A2 = list(map(int, input().strip().split()))
A3 = list(map(int, input().strip().split()))
N = int(input())
b = [int(input()) for i in range(N)]
A = np.array([A1, A2, A3])
K = np.empty((3, 3))

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            K[i][j] = 1
        else:
            K[i][j] = 0

if (3 in K.sum(axis=1)) or (3 in K.sum(axis=0)) or (K[0][0] == 1 and K[1][1] == 1 and K[2][2]) or (K[0][2] == 1 and K[1][1] == 1 and K[2][0]):
    print("Yes")

else:
    print("No")

Solution (Python):
A = []
for i in range(3):
    A = A + [int(i) for i in input().split()]
N = int(input())
for i in range(N):
    b = int(input())
    if b in A:
        j = A.index(b)
        A[j] = -1
if (A[0] == -1 and A[3] == -1 and A[6] == -1) \
    or (A[1] == -1 and A[4] == -1 and A[7] == -1) \
    or (A[2] == -1 and A[5] == -1 and A[8] == -1) \
    or (A[0] == -1 and A[1] == -1 and A[2] == -1) \
    or (A[3] == -1 and A[4] == -1 and A[5] == -1) \
    or (A[6] == -1 and A[7] == -1 and A[8] == -1) \
    or (A[0] == -1 and A[4] == -1 and A[8] == -1) \
    or (A[2] == -1 and A[4] == -1 and A[6] == -1):
    print('Yes')
else:
    print('No')

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

n = int(input());
v = [];

for i in range(n):
    k = int(input());
    v.append(k);




for val in v:
    for i in range(3):
        for j in range(3):
            if f[i][j] == val:
                f[i][j] = 0;

flag = False;

for i in range(3):
    curr = 0;
    for j in range(3):
        curr += f[i][j];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][i];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][j];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][2 - j];
    if curr == 0:
        flag = True;

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

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

for i in range(3):
    judge = 0
    for j in range(3):
        judge += A[i][j]
    if judge == 0:
        print("Yes")
        exit()

for j in range(3):
    judge = 0
    for i in range(3):
        judge += A[i][j]
    if judge == 0:
        print("Yes")
        exit()

judge = 0

for k in range(3):
    judge += A[k][k]
if judge == 0:
    print("Yes")
    exit()

judge = 0

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

Solution (Python):
bingo = [0] * 9

A = input().split()
A += input().split()
A += input().split()

n = int(input())

for i in range(n):
    b = input()
    if b in A:
        bingo[A.index(b)] = 1        
    
ans = 'No'

for i in range(3):
    if bingo[i] == bingo[i + 3] == bingo[i + 6] == 1:
        ans = 'Yes'

for i in range(3):
    if bingo[3 * i] == bingo[3 * i + 1] == bingo[3 * i + 2] == 1:
        ans = 'Yes'
        
if bingo[0] == bingo[4] == bingo[8] == 1:
        ans = 'Yes'

if bingo[2] == bingo[4] == bingo[6] == 1:
        ans = 'Yes'

print(ans)

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())
for i in range(N):
    b = int(input())
    if A_1[0] == b:
        A_1[0] = 0
    if A_1[1] == b:
        A_1[1] = 0
    if A_1[2] == b:
        A_1[2] = 0
    if A_2[0] == b:
        A_2[0] = 0
    if A_2[1] == b:
        A_2[1] = 0
    if A_2[2] == b:
        A_2[2] = 0
    if A_3[0] == b:
        A_3[0] = 0
    if A_3[1] == b:
        A_3[1] = 0
    if A_3[2] == b:
        A_3[2] = 0
if A_1 == [0, 0, 0] or A_2 == [0, 0, 0] or A_3 == [0, 0, 0]:
    print("Yes")
    exit()
for j in range(3):
     if A_1[j] == 0 and A_2[j] == 0 and A_3[j] == 0:
         print("Yes")
         exit()
if A_1[0] == 0 and A_2[1] == 0 and A_3[2] == 0:
    print("Yes")
    exit()

if A_3[0] == 0 and A_2[1] == 0 and A_1[2] == 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)]

bingo = [[False, False, False] for _ in range(3)]

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


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

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

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

if flag:
    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
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

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

Solution (Python):
l = list()
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    l.append(a1)
    l.append(a2)
    l.append(a3)
n = int(input())
for i in range(n):
    b = int(input())
    if b in l:
        l[l.index(b)] = 0
for i in range(3):
    if l[3 * i] == 0 and l[3 * i + 1] == 0 and l[3 * i + 2] == 0:
        print("Yes")
        exit()
    if l[i] == 0 and l[i + 3] == 0 and l[i + 6] == 0:
        print("Yes")
        exit()
if l[0] == 0 and l[4] == 0 and l[8] == 0:
    print("Yes")
    exit()
if l[2] == 0 and l[4] == 0 and l[6] == 0:
    print("Yes")
    exit()
print("No")

Solution (Python):
c = list(map(int,input().split())) + list(map(int,input().split())) + list(map(int,input().split()))
n = int(input())
d = [0]*9
for i in range(n):
    m = int(input())
    for j in range(9):
        if c[j] == m:
            d[j] = 1
if (d[0],d[1],d[2]) == (1,1,1) or (d[3],d[4],d[5]) == (1,1,1) or (d[6],d[7],d[8]) == (1,1,1)\
    or (d[0],d[3],d[6]) == (1,1,1) or (d[1],d[4],d[7]) == (1,1,1) or (d[2],d[5],d[8]) == (1,1,1)\
        or (d[0],d[4],d[8]) == (1,1,1) or (d[2],d[4],d[6]) == (1,1,1):
        print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
A = np.zeros((3,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())
N_list = []
for _ in range(N):
    N_list.append(int(input()))


for n in N_list:
    A = np.where(A==n, 0, A)


result = 'No'
for i in np.all(A==0, axis=0):
    if i == True:
        result = 'Yes'
for i in np.all(A==0, axis=1):
    if i == True:
        result = 'Yes'
if np.all(np.diag(A)==0) == True or np.all(np.array([A[0,2], A[1,1], A[2,0]]) == 0) == True:
    result = 'Yes'
print(result)

Solution (Python):
import numpy as np

def main():
    A = []
    for _ in range(3):
        A += list(map(int, input().split()))

    N = int(input())

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

    for v in b:
        if v in A:
            index = A.index(v)
            A[index] = 0
    
    bingo_list = [
        [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 bingo in bingo_list:
        if sum(np.array(A)[bingo]) == 0:
            print("Yes")
            exit()
    
    print("No")

if __name__ == '__main__':
    main()

Solution (Python):
card = [[int(x) for x in input().split()] for y in range(3)]
bools = [[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == card[i][j]:
        bools[i][j] = 1
ok = False
for i in range(3):
  if (bools[i][0], bools[i][1], bools[i][2]) == (1,1,1) or (bools[0][i], bools[1][i], bools[2][i]) == (1,1,1):
    ok = True
if (bools[0][0],bools[1][1],bools[2][2]) == (1,1,1) or (bools[0][2], bools[1][1], bools[2][0]) == (1,1,1):
  ok = True
print("Yes" if ok else "No")

Solution (Python):
one = list(map(int, input().split()))
two = list(map(int, input().split()))
three = list(map(int, input().split()))
n = int(input())
out = [int(input()) for x in range(n)]


def judge(a_list):
    for i in a_list:
        if i not in out:
            return False

    return True


for_judge = [one, two, three]

for i in range(3):
    tmp = [one[i], two[i], three[i]]
    for_judge.append(tmp)


naname1 = [one[0], two[1], three[2]]
naname2 = [one[2], two[1], three[0]]

for_judge.append(naname1)
for_judge.append(naname2)

for a_list in for_judge:
    if judge(a_list):
        print('Yes')
        exit()

print('No')

Solution (Python):
a_list1, a_list2, a_list3 = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b_list = []
for _ in range(n):
    b_list.append(int(input()))
a_list = a_list1 + a_list2 + a_list3
hit_list = []
for i in range(len(a_list)):
    if a_list[i] in b_list:
        hit_list.append(i)
bingo_list = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
ans = 'No'
for bingo in bingo_list:
    if set(bingo) <= set(hit_list):
        ans = 'Yes'
        break
print(ans)