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):
A1=[]
A2=[]
A3=[]


a11, a12, a13 = map(int,input().split())
A1.append(a11)
A1.append(a12)
A1.append(a13)

a21, a22, a23 = map(int,input().split())
A2.append(a21)
A2.append(a22)
A2.append(a23)

a31, a32, a33 = map(int,input().split())
A3.append(a31)
A3.append(a32)
A3.append(a33)

N = int(input())
for i in range(N):
    b = int(input())
    if b==A1[0]:
        A1[0] ="OK"
    if b==A1[1]:
        A1[1]="OK"
    if b==A1[2]:
        A1[2]="OK"
    if b==A2[0]:
        A2[0] ="OK"
    if b==A2[1]:
        A2[1]="OK"
    if b==A2[2]:
        A2[2]="OK"
    if b==A3[0]:
        A3[0] ="OK"
    if b==A3[1]:
        A3[1]="OK"
    if b==A3[2]:
        A3[2]="OK"

ans ="No"
if A1[0]==A1[1] and A1[0]==A1[2]:
    ans ="Yes"
if A2[0]==A2[1] and A2[0]==A2[2]:
    ans ="Yes"
if A3[0]==A3[1] and A3[0]==A3[2]:
    ans ="Yes"

if A1[0]==A2[0] and A1[0]==A3[0]:
    ans ="Yes"
if A1[1]==A2[1] and A1[1]==A3[1]:
    ans ="Yes"
if A1[2]==A2[2] and A1[2]==A3[2]:
    ans ="Yes"

if A1[0]==A2[1] and A1[0]==A3[2]:
    ans ="Yes"
if A1[2]==A2[1] and A1[2]==A3[0]:
    ans ="Yes"

print(ans)

Solution (Python):
A1 = list(map(str, input().split()))
A2 = list(map(str, input().split()))
A3 = list(map(str, input().split()))

N = int(input())
for i in range(N):
  a = input()
  for j in range(3):
    if a == A1[j]:
        A1[j] = '*'
    if a == A2[j]:
        A2[j] = '*'    
    if a == A3[j]:
        A3[j] = '*'
B1= [A1[0], A2[0], A3[0]]
B2= [A1[1], A2[1], A3[1]]
B3= [A1[2], A2[2], A3[2]]
C1= [A1[0], A2[1], A3[2]]
C2= [A1[2], A2[1], A3[0]]

if ''.join(A1) == '***' or ''.join(A2) == '***' or ''.join(A3) == '***' or ''.join(B1) == '***' or ''.join(B2) == '***' or ''.join(B3) == '***' or ''.join(C1) == '***' or ''.join(C2) == '***':
  print('Yes')
else:
  print('No')

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

Bingo = False


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


for i in range(3):
    for j in range(3):
        if A[i][0] == A[i][1] == A[i][2] == 9999:
            Bingo = True
        elif A[0][j] == A[1][j] == A[2][j] == 9999:
            Bingo = True
        elif A[0][0] == A[1][1] == A[2][2] == 9999:
            Bingo = True
        elif A[0][2] == A[1][1] == A[2][0] == 9999:
            Bingo = True
   
if Bingo:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

a_list = list(map(int, input().split()))
a_list_2 = list(map(int, input().split()))
a_list_3 = list(map(int, input().split()))

a_total_list = np.array([a_list, a_list_2, a_list_3])
bingo_array = np.zeros((3, 3))

N = int(input())

b_list = []

for i in range(N):
    b = int(input())
    if b in a_total_list:
        bingo_array[np.where(a_total_list == b)[0][0]][np.where(a_total_list == b)[1][0]] = 1

bingo_x_y = 0
break_flag = False
for i in range(3):
    if break_flag is True:
        break
    else:
        bingo_x = 0
        bingo_y = 0
    for j in range(3):
        if bingo_array[i][j] == 1:
            bingo_x += 1
            if bingo_x == 3:
                break_flag = True
                break
        if bingo_array[j][i] == 1:
            bingo_y += 1
            if bingo_y == 3:
                break_flag = True
                break
        if i == j:
            if bingo_array[i][j] == 1:
                bingo_x_y += 1
                if bingo_x_y == 3:
                    break_flag = True
                    break

if bingo_x >= 3:
    print("Yes")
    exit()
elif bingo_y >= 3:
    print("Yes")
    exit()
elif bingo_x_y >= 3:
    print("Yes")
    exit()
elif bingo_array[0][2] == 1 and bingo_array[1][1] == 1 and bingo_array[2][0] == 1:
    print("Yes")
    exit()
else:
    print("No")
    exit()

Solution (Python):
def judge_bingo(m,a):
    sum_d1 = 0
    sum_d2 = 0
    for i in range(m):
        sum_h = 0
        sum_v = 0
        for j in range(m):
            sum_h += a[i][j]
            sum_v += a[j][i]
        
        if sum_h==3 or sum_v==3:
            return True
        sum_d1 += a[i][i]
        sum_d2 += a[i][-i-1]
        
    if sum_d1==3 or sum_d2==3:
        return True
    else:
        return False
    

if __name__ == "__main__":
    m = 3
    card = [[0]]*m
    bingo = [[0]*m for i in range(m)]
    for i in range(m):
        card[i] = list(map(int,input().split()))
    n = int(input())
    nums = []
    for i in range(n):
        nums.append(int(input()))
        
    sum_h = [0]*m
    for num in nums:
        for i in range(m):
            for j in range(m):
                if card[i][j]==num:
                    bingo[i][j] = 1
    if judge_bingo(m,bingo):
        print("Yes")
    else:
        print("No")

Solution (Python):
L = [] ;
L2 = [] ;
for x in range (3 )  :
	arr = list (  map ( int , input().strip().split(" ") ) );
	L.append( arr ) ; 

	L2.append (  [ False for c in range ( 3 ) ] ) ;


r = int( input().strip() ) ; 
for c  in range ( r ) :
	v = int( input().strip() ) ; 
	for y in range ( 3 ) :
		for x in range ( 3 ) :
			if L[y][x] == v :
				L2[y][x] = True ;

b1 = False ;
for x in range ( 3 ) :
	if L2[x][0] and L2[x][1] and L2[x][2] :
		b1 = True ;

	if L2[0][x] and L2[1][x] and L2[2][x] :
		b1 = True ;
	if L2[0][0] and L2[1][1] and L2[2][2] :
		b1 = True ;
	if L2[0][2] and L2[1][1] and L2[2][0] :
		b1 = True ;
if b1 :
	print ("Yes") ;
else :
	print ("No") ;

Solution (Python):
Aa = [0]*3
for i in range(3):
    Aa[i] = [int(j) for j in  input().split()]
N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())
A = [[False] * 3 for _ in range(3)]
for i in range(N):
    for k in range(3):
        for t in range(3):
            if Aa[k][t] == b[i]:
                A[k][t] = True
for i in range(3):
    if A[0][i] == True and A[1][i] == True and A[2][i] == True:
        print("Yes")
        exit()
for i in range(3):
    if A[i][0] == True and A[i][1] == True and A[i][2] == True:
        print("Yes")
        exit()
if A[0][0] == True and A[1][1] == True and A[2][2] == True:
    print("Yes")
    exit()
if A[0][2] == True and A[1][1] == True and A[2][0] == True:
    print("Yes")
    exit()
print("No")

Solution (Python):
import copy
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
A_copy = copy.copy(A)
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                A_copy[i][j] = -1

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

Solution (Python):




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


count = int(input())

for num in range(count):
    x = int(input())
    for y in range(3):
        if a[y] == x:
            a[y] = 0
    for y in range(3):
        if b[y] == x:
            b[y] = 0
    for y in range(3):
        if c[y] == x:
            c[y] = 0











if a[0]+a[1]+a[2] == 0:
    print("Yes")
elif b[0]+b[1]+b[2] == 0:
    print("Yes")
elif c[0]+c[1]+c[2] == 0:
    print("Yes")
elif a[0] + b[0] + c[0] ==0:
    print("Yes")
elif a[1] + b[1] + c[1] ==0:
    print("Yes")
elif a[2] + b[2] + c[2] ==0:
    print("Yes")
elif a[0] + b[1] + c[2] == 0:
    print("Yes")
elif a[2] + b[1] + c[0] ==0:
    print("Yes")
else:
    print("No")

Solution (Python):
card = list()
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
card.append(a1)
card.append(a2)
card.append(a3)

res = list()
res1 = list(False for i in range(3)) 
res2 = list(False for i in range(3)) 
res3 = list(False for i in range(3)) 
res.append(res1)
res.append(res2)
res.append(res3)
res

for _ in range(n):
    num = int(input())
    for i in range(len(card)):
        for j in range(len(card)):
            if num == card[i][j]:
                res[i][j] = True

final = "No"
for r in range(len(res)):
    tmp = []
    tmp.append(all(res[r]))
    if all(tmp) == True:
        final = "Yes"

for c in range(len(res)):
    tmp = []
    for r in range(len(res)):
        tmp.append(res[r][c])
    if all(tmp) == True:
            final = "Yes"

tmp = []
for i in range(len(res)):
    tmp.append(res[i][i])
if all(tmp) == True:
    final = "Yes"

tmp = []
for i in range(len(res)):
    j = len(res) - i - 1
    tmp.append(res[i][j])
if all(tmp) == True:
    final = "Yes"

print(final)

Solution (Python):
import numpy as np
a1 = np.array(list(map(int, input().split())))
a2 = np.array(list(map(int, input().split())))
a3 = np.array(list(map(int, input().split())))
a = np.concatenate([a1, a2, a3], axis=0)
n = int(input())
b = 0
for i in range(n):
  b = int(input())
  a = np.where(a == b, 0, a)

a = a.reshape((3, 3))
if (a[0,0] == 0 and a[0,1] == 0 and a[0,2] == 0):
  print('Yes')
  exit()
if (a[1,0] == 0 and a[1,1] == 0 and a[1,2] == 0):
  print('Yes')
  exit()
if (a[2,0] == 0 and a[2,1] == 0 and a[2,2] == 0):
  print('Yes')
  exit()
if (a[0,0] == 0 and a[1,0] == 0 and a[2,0] == 0):
  print('Yes')
  exit()
if (a[0,1] == 0 and a[1,1] == 0 and a[2,1] == 0):
  print('Yes')
  exit()
if (a[0,2] == 0 and a[1,2] == 0 and a[2,2] == 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 i in range(3)]
n=int(input())
for k in range(n):
  s=int(input())
  for i in range(3):
    for j in range(3):
      if s == A[i][j]:
        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 [0,0,0] in A:
  print("Yes")
  
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  
elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
  print("Yes")
  
else:
  print("No")

Solution (Python):
a= list(map(int,input().split()))
a2= list(map(int,input().split()))
a3= list(map(int,input().split()))
b=[0,0,0,0,0,0,0,0,0]
a+=a2
a+=a3
n=int(input())
for i in range(n):
    j = int(input())
    for aa in range(9):
        if a[aa] == j:
            b[aa]=1

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

Solution (Python):
import numpy as np
import re, sys

A = np.zeros((3,3), dtype=int)
for i in range(3):
  row = input()
  nums = re.split(' ', row)
  for j in range(3):
  	A[i, j] = int(nums[j])
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
for i in range(3):
  if len(set(A[i]) & set(b)) == 3 or len(set(A[:,i]) & set(b)) == 3:
    print('Yes')
    sys.exit()
cross1 = [A[0,0] ,A[1,1], A[2,2]]
cross2 = [A[0,2] ,A[1,1], A[2,0]]
if len(set(cross1) & set(b)) == 3 or len(set(cross2) & set(b)) == 3:
  print('Yes')
  sys.exit()
else:
  print('No')

Solution (Python):
import numpy as np
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
a_ = np.array(a)
cond = np.full([3,3], False)
for i in b:
    cond[np.where(a_==i)] = True
naname = np.array([[cond[0,0], cond[1,1], cond[2,2]], [cond[0,2], cond[1,1], cond[2,0]]])
if True in np.all(cond==True, axis=0):
    print("Yes")
elif True in np.all(cond==True, axis=1):
    print("Yes")
elif True in np.all(naname==True, axis=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())
c = "check"
for i in range(n):
    v = int(input())
    ind = 0
    if v in a1 :
        ind = a1.index(v)
        a1[ind] = c
    if v in a2 :
        ind = a2.index(v)
        a2[ind] = c
    if v in a3 :
        ind = a3.index(v)
        a3[ind] = c

if ((a1[0] == c and a2[0] == c and a3[0] == c) or  
    (a1[1] == c and a2[1] == c and a3[1] == c) or 
    (a1[2] == c and a2[2] == c and a3[2] == c) or 
    (a1[0] == c and a2[1] == c and a3[2] == c) or
    (a1[2] == c and a2[1] == c and a3[0] == c) or
    a1.count(c) == 3 or
    a2.count(c) == 3 or
    a3.count(c) == 3):
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
for i in range(0,3):
    A.extend(list(map(int,input().split())))
N = int(input())
B = []
for j in range(0,N):
    B.append(int(input()))
for b in B:
    if b in A:
        A[A.index(b)] = 0
for i in range(0, 3):
    if A[i] + A[i+3] + A[i+6] == 0:
        print("Yes")
        exit()
    if A[i*3] + A[i*3+1] + A[i*3+2] == 0:
        print("Yes")
        exit()
if A[0] + A[4] + A[8] == 0 or A[2] + A[4] + A[6] ==0:
    print("Yes")
    exit()
print("No")

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

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

Solution (Python):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
A = [a11, a12, a13, a21, a22, a23, a31, a32, a33]
N = int(input())
b = []
for _ in range(N):
    try:
        A[A.index(int(input()))] = '○'
    except ValueError:
        pass

ans = 'No'
if A[0] == '○' and A[1] == '○' and A[2] == '○':
    ans = 'Yes'
if A[3] == '○' and A[4] == '○' and A[5] == '○':
    ans = 'Yes'
if A[6] == '○' and A[7] == '○' and A[8] == '○':
    ans = 'Yes'

if A[0] == '○' and A[3] == '○' and A[6] == '○':
    ans = 'Yes'
if A[1] == '○' and A[4] == '○' and A[7] == '○':
    ans = 'Yes'
if A[2] == '○' and A[5] == '○' and A[8] == '○':
    ans = 'Yes'

if A[0] == '○' and A[4] == '○' and A[8] == '○':
    ans = 'Yes'
if A[2] == '○' and A[4] == '○' and A[6] == '○':
    ans = 'Yes'

print(ans)

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 = [str(i) for i in input().split()]
a2 = [str(i) for i in input().split()]
a3 = [str(i) for i in input().split()]
a = [a1,a2,a3]
new_a = []
import itertools
a = list(itertools.chain.from_iterable(a))
n = int(input())
l = [str(input()) for _ in range(n)]
l = list(set(l))
for i in a:
    if i in l:
        item_mod = i.replace(i,'o')
        new_a.append(item_mod)
    else:
        new_a.append(i)
import numpy
a = numpy.array(new_a).reshape(3,3)
yoko1 = []
yoko2 = []
yoko3 = []
tate1 = []
tate2 = []
tate3 = []
for i in range(3):
    yoko1.append(a[0][i])
    yoko2.append(a[1][i])
    yoko3.append(a[2][i])
    tate1.append(a[i][0])
    tate2.append(a[i][1])
    tate3.append(a[i][2])
naname1 = [a[0][0],a[1][1],a[2][2]]
naname2 = [a[0][2],a[1][1],a[2][0]]
x = ['o','o','o']
if x == yoko1:
    print('Yes')

elif x == yoko2:
    print('Yes')

elif x == yoko3:
    print('Yes')

elif x == tate1:
    print('Yes')

elif x == tate2:
    print('Yes')

elif x == tate3:
    print('Yes')

elif x == naname1:
    print('Yes')

elif x == naname2:
    print('Yes')

else:
    print('No')

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

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

if a[0][0]+a[0][1]+a[0][2]==0 or a[1][0]+a[1][1]+a[1][2]==0 or a[2][0]+a[2][1]+a[2][2]==0:
    print('Yes')
    exit()

if a[0][0]+a[1][0]+a[2][0]==0 or a[0][1]+a[1][1]+a[2][1]==0 or a[0][2]+a[1][2]+a[2][2]==0:
    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 = []
for i in range(3):
  tmp = input()
  a.append(list(map(int, tmp.split())))

n = int(input())

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




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

def check(a):
    
    
    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()
    for i in range(3):
        if (a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0):
            print('Yes')
            exit()
        if a[i] == [0, 0, 0]:
            print('Yes')
            exit()
    print('No')

check(a)

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

bingo.append([bingo[0][0], bingo[1][1], bingo[2][2]])
bingo.append([bingo[0][2], bingo[1][1], bingo[2][0]])
bingo.append([bingo[0][0], bingo[1][0], bingo[2][0]])
bingo.append([bingo[0][1], bingo[1][1], bingo[2][1]])
bingo.append([bingo[0][2], bingo[1][2], bingo[2][2]])


print("Yes" if any([len([j for j in k if j in bs])==3 for k in bingo]) else "No")

Solution (Python):
from numpy import *
import itertools

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

b=[]
for i in range(N):
  b.append(int(input())) 
C=zeros((3,3))
for i in range(0,3):
  for j in range(0,3): 
    for k in range(0,N):
      if A[i][j]==b[k]:
        C[i][j]=1     
if C[0][0]==1 and C[1][1]==1 and C[2][2]==1:
  print("Yes") 
elif C[0][2]==1 and C[1][1]==1 and C[2][0]==1:  
   print("Yes") 
elif C[0][0]==1 and C[1][0]==1 and C[2][0]==1:
  print("Yes")    
elif C[0][1]==1 and C[1][1]==1 and C[2][1]==1:
  print("Yes")  
elif C[0][2]==1 and C[1][2]==1 and C[2][2]==1:
  print("Yes") 
elif C[0][0]==1 and C[0][1]==1 and C[0][2]==1:
  print("Yes")   
elif C[1][0]==1 and C[1][1]==1 and C[1][2]==1:
  print("Yes")   
elif C[2][0]==1 and C[2][1]==1 and C[2][2]==1:
  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):
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 = []
check = []
for i in range(3):
    a.append([int(j) for j in input().split()])
 
d1 = [a[0][0],a[1][1], a[2][2]]
d2 = [a[0][2],a[1][1], a[2][0]]
col1 = [a[0][0],a[1][0], a[2][0]]
col2 = [a[0][1],a[1][1], a[2][1]]
col3 = [a[0][2],a[1][2], a[2][2]]
 
n = input()
n = int(n)
for i in range(n):
    check.append(int(input()))
 
if all(elem in check for elem in d1):
    print("Yes")
elif all(elem in check for elem in d2):
    print("Yes")
elif all(elem in check for elem in col1):
    print("Yes")
elif all(elem in check for elem in col2):
    print("Yes")
elif all(elem in check for elem in col3):
    print("Yes")
elif all(elem in check for elem in a[0]):
    print("Yes")
elif all(elem in check for elem in a[1]):
    print("Yes")
elif all(elem in check for elem in a[2]):
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
arr = np.zeros((3,3), dtype=np.int8)

a = [int(i) for i in input().split(' ') ]
b = [int(i) for i in input().split(' ') ]
c = [int(i) for i in input().split(' ') ]

for ii in range(3):
  arr[ii] = [a,b,c][ii]

n = int(input())

ca = []
for nn in range(n):
  aaa = int(input())
  for i in range(3):
    for j in range(3):    
      if arr[i,j]==aaa:
        ca.append((i,j))

if (0, 0) in ca and (1,1) in ca and (2,2) in ca:
  print('Yes')

elif (0, 2) in ca and (1,1) in ca and (2,0) in ca:
  print('Yes')

elif (0, 0) in ca and (0,1) in ca and (0,2) in ca:
  print('Yes')
  
elif (1, 0) in ca and (1,1) in ca and (1,2) in ca:
  print('Yes')
  
elif (2, 0) in ca and (2,1) in ca and (2,2) in ca:
  print('Yes')
  
elif (0, 0) in ca and (1,0) in ca and (2,0) in ca:
  print('Yes')
  
elif (0, 1) in ca and (1,1) in ca and (2,1) in ca:
  print('Yes')
  
elif (0, 2) in ca and (1,2) in ca and (2,2) in ca:
  print('Yes')
  
else:
  print('No')

Solution (Python):


a = []
result = []

for i in range(3):
  a.append(list(map(int, input().split(' '))))
  
a_flat = sum(a, [])
n = int(input())

for _ in range(n):
  b = int(input())
  
  if b in a_flat:
    result.append(a_flat.index(b))


score = 'No'
result = set(result)

if result:
  if set([0, 1, 2]) <= result:
    score = 'Yes'
  if set([3, 4, 5]) <= result:
    score = 'Yes'
    
  if set([6, 7, 8]) <= result:
    score = 'Yes'
    
  if set([0, 3, 6]) <= result:
    score = 'Yes'
    
  if set([1, 4, 7]) <= result:
    score = 'Yes'
    
  if set([2, 5, 8]) <= result:
    score = 'Yes'
    
  if set([0, 4, 8]) <= result:
    score = 'Yes'
    
  if set([2, 4, 6]) <= result:
    score = 'Yes'

print(score)

Solution (Python):
a11,a12,a13 = (x for x in input().split())
a21,a22,a23 = (x for x in input().split())
a31,a32,a33 = (x for x in input().split())
N = int(input())
b = list()
for _ in range(N):
    b.append(input())
if a11 in b and a12 in b and a13 in b:
    print("Yes")
elif a21 in b and a22 in b and a23 in b:
    print("Yes")
elif a31 in b and a32 in b and a33 in b:
    print("Yes")
elif a11 in b and a21 in b and a31 in b:
    print("Yes")
elif a12 in b and a22 in b and a32 in b:
    print("Yes")
elif a13 in b and a23 in b and a33 in b:
    print("Yes")
elif a11 in b and a22 in b and a33 in b:
    print("Yes")
elif a13 in b and a22 in b and a31 in b:
    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())
v = 0

for i in range(0, n):
    v = int(input())
    if v in a1:
        a1[a1.index(v)] = 0
    if v in a2:
        a2[a2.index(v)] = 0
    if v in a3:
        a3[a3.index(v)] = 0


if sum(a1) == 0:
    print('Yes')
    sys.exit()

if sum(a2) == 0:
    print('Yes')
    sys.exit()

if sum(a3) == 0:
    print('Yes')
    sys.exit()

if a1[0] == a2[0] == a3[0] == 0:
    print('Yes')
    sys.exit()

if a1[1] == a2[1] == a3[1] == 0:
    print('Yes')
    sys.exit()

if a1[2] == a2[2] == a3[2] == 0:
    print('Yes')
    sys.exit()

if a1[0] == a2[1] == a3[2] == 0:
    print('Yes')
    sys.exit()

if a3[0] == a2[1] == a1[2] == 0:
    print('Yes')
    sys.exit()
    
print('No')

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

for _ in range(n):
  b = int(input())
  tmp = 0
  for i in range(3):
    for j in range(3):
      tmp += 1
      if A[i][j] == b:
        bingo[tmp-1] = True
        
for i in range(3):
  if all(bingo[i*3:(i+1)*3]):
         print('Yes')
         exit()
for i in range(3):
  if all(bingo[i:9:3]):
         print('Yes')
         exit()
if all(bingo[0:9:4]) or all(bingo[2:7:2]):
  print('Yes')
  exit()
  
print('No')

Solution (Python):
import numpy as np
N = []
FLAGS = True
for i in range(3):
  N1 = list(map(int, input().split(' ')))
  N.append(N1)

N = np.array(N)

M = int(input())

for i in range(M):
  a = int(input())
  
  for j in range(3):
    for k in range(3):
      if N[j, k] == a:
        N[j, k] = 0
  if (np.all(N == 0, axis = 0).any(0)) or (np.all(N == 0, axis = 1).any(0)) or (np.all(np.diag(N) == 0).any(0)) or (np.all(np.diag(np.fliplr(N)) == 0).any(0)):
    print('Yes')
    FLAGS = True
    break
  else:
    FLAGS = False
    continue
      
if FLAGS == False:     
  print('No')

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

d1 = [a[0][0],a[1][1], a[2][2]]
d2 = [a[0][2],a[1][1], a[2][0]]
col1 = [a[0][0],a[1][0], a[2][0]]
col2 = [a[0][1],a[1][1], a[2][1]]
col3 = [a[0][2],a[1][2], a[2][2]]

n = input()
n = int(n)
for i in range(n):
    check.append(int(input()))

if all(elem in check for elem in d1):
    print("Yes")
elif all(elem in check for elem in d2):
    print("Yes")
elif all(elem in check for elem in col1):
    print("Yes")
elif all(elem in check for elem in col2):
    print("Yes")
elif all(elem in check for elem in col3):
    print("Yes")
elif all(elem in check for elem in a[0]):
    print("Yes")
elif all(elem in check for elem in a[1]):
    print("Yes")
elif all(elem in check for elem in a[2]):
    print("Yes")
else:
    print("No")

Solution (Python):
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N =int(input())
B = []
for _ in range(N):
    B.append(int(input()))

a=str('Yes')
b=str('No')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

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

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                A[i][j]="HIT"
                
if A[0][0]==A[0][1]==A[0][2]=="HIT":
        ans=1
if A[1][0]==A[1][1]==A[1][2]=="HIT":
        ans=1
if A[2][0]==A[2][1]==A[2][2]=="HIT":
        ans=1
if A[0][0]==A[1][0]==A[2][0]=="HIT":
        ans=1
if A[0][1]==A[1][1]==A[2][1]=="HIT":
        ans=1
if A[0][2]==A[1][2]==A[2][2]=="HIT":
        ans=1
if A[0][0]==A[1][1]==A[2][2]=="HIT":
        ans=1
if A[0][2]==A[1][1]==A[2][0]=="HIT":
        ans=1
        
print("Yes" if ans else "No")

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

    for j in range(3):
        for k in range(3):
            if l[j][k] == m:
                l[j][k] = -1
o=0
p=0
for j in range(3):
    for k in range(3):
        o+=l[j][k]
        p+=l[k][j]
    if o==-3 or p==-3:
        print('Yes')
        exit()
    o=0
    p=0
if l[0][0]+l[1][1]+l[2][2]==-3 or l[0][2]+l[1][1]+l[2][0]==-3:
    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):
  tmp=int(input())
  for j in range(3):
    if tmp ==A[j]:
      A[j]=-1
    if tmp ==B[j]:
      B[j]=-1
    if tmp ==C[j]:
      C[j]=-1
if A[0]==A[1]==A[2]==-1:
  print('Yes')
  exit()
if B[0]==B[1]==B[2]==-1:
  print('Yes')
  exit()
if C[0]==C[1]==C[2]==-1:
  print('Yes')
  exit()
if A[0]==B[0]==C[0]==-1:
  print('Yes')
  exit()
if A[1]==B[1]==C[1]==-1:
  print('Yes')
  exit()
if A[2]==B[2]==C[2]==-1:
  print('Yes')
  exit()
if A[0]==B[1]==C[2]==-1:
  print('Yes')
  exit()
if C[0]==B[1]==A[2]==-1:
  print('Yes')
  exit() 
print('No')