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

m = []

for i in range(0, 3):
    m.append([int(n) for n in input().strip().split(" ")])

ns = []
n = int(input().strip())

for i in range(0, n):
    ns.append(int(input().strip()))

for n in ns:
    for i in range(0, 3):
        for j in range(0, 3):
            if m[i][j] == n:
                m[i][j] = 0

import sys

for i in range(0, 3):
    if sum(m[i]) == 0:
        print('Yes')
        sys.exit(0)

for i in range(0, 3):
    if sum([m[0][i], m[1][i], m[2][i]])  == 0:
        print('Yes')
        sys.exit(0)


if sum([m[0][0], m[1][1], m[2][2]]) == 0 or sum([m[0][2], m[1][1], m[2][0]]) == 0:
    print('Yes')
    sys.exit(0)

print('No')

Solution (Python):
import numpy as np

data = np.array([input().split() for i in range(3)])
data = data.astype(np.int64)

N = int(input())

ans = 0
for i in range(N):
	check = 0
	num = int(input())
	for x in range(3):
		for y in range(3):
			if num == data[x][y]:
				data[x][y] = -1
				break
		if check == 1:
			break

if data[0][0] == -1 and data[0][1] == -1 and data[0][2] == -1:
	ans = 1
elif data[1][0] == -1 and data[1][1] == -1 and data[1][2] == -1:
	ans = 1
elif data[2][0] == -1 and data[2][1] == -1 and data[2][2] == -1:
	ans = 1
if data[0][0] == -1 and data[1][0] == -1 and data[2][0] == -1:
	ans = 1
elif data[0][1] == -1 and data[1][1] == -1 and data[2][1] == -1:
	ans = 1
elif data[0][2] == -1 and data[1][2] == -1 and data[2][2] == -1:
	ans = 1
elif data[0][0] == -1 and data[1][1] == -1 and data[2][2] == -1:
	ans = 1
elif data[0][2] == -1 and data[1][1] == -1 and data[2][0] == -1:
	ans = 1

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

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

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

for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i] == a[j][k]:
        a[j][k] = "x"

for i in range(3):
  if len(set(map(tuple, a[i]))) == 1:
    print("Yes")
    exit()
a_0 = []
a_1 = []
a_2 = []
for i in range(3):
  a_0.append(a[i][0])
  a_1.append(a[i][1])
  a_2.append(a[i][2])

a_rcross = []
a_lcross = []
for i in range(3):
  a_rcross.append(a[i][i])
  a_lcross.append(a[i][2-i])
if len(set(map(tuple, a_0))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_1))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_2))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_rcross))) == 1:
    print("Yes")
    exit()
elif len(set(map(tuple, a_lcross))) == 1:
    print("Yes")
    exit()
    
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_i = list([int(input()) for _ in range(N)])

for bi in b_i:
    for i in range(3):
        for j in range(3):
            if A[i][j] == bi:
                A[i][j] = 'on'

flag_no_bingo = False

for j in range(3):
    if A[0][j] == 'on':
        if A[1][j] == 'on' and A[2][j] == 'on':
            flag_no_bingo = True

for i in range(3):
    if A[i][0] == 'on':
        if A[i][1] == 'on' and A[i][2] == 'on':
            flag_no_bingo = True

if A[0][0] == 'on' and A[1][1] == 'on'  and A[2][2] == 'on' :
    flag_no_bingo = True
if A[0][2] == 'on' and A[1][1] == 'on' and A[2][0] == 'on' :
    flag_no_bingo = True

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

Solution (Python):
f = lambda:list(map(int,input().split()))
la = f()+f()+f()
sb = set()
n = int(input())
for i in range(n):
  b = int(input())
  if b in la:
    sb.add(la.index(b))
ls = [{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}]
for s in ls:
  if s<=sb:
    print('Yes')
    break
else:
  print('No')

Solution (Python):
import sys

def LI():
  return [int(s) for s in input().split()]

ROWS = 3
COLS = 3

A = []
A.append(LI())
A.append(LI())
A.append(LI())

BINGO = []
BINGO.append([0]*3)
BINGO.append([0]*3)
BINGO.append([0]*3)

N = int(input())

for n in range(N):
  b = int(input())
  for i in range(ROWS):
    for j in range(COLS):
      if A[i][j] == b:
        BINGO[i][j] = 1
      
if BINGO[0][0] == 1 and BINGO[0][1] == 1 and BINGO[0][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[1][0] == 1 and BINGO[1][1] == 1 and BINGO[1][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[2][0] == 1 and BINGO[2][1] == 1 and BINGO[2][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][0] == 1 and BINGO[1][0] == 1 and BINGO[2][0] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][1] == 1 and BINGO[1][1] == 1 and BINGO[2][1] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][2] == 1 and BINGO[1][2] == 1 and BINGO[2][2] == 1:
  print('Yes')
  sys.exit()
      
if BINGO[0][0] == 1 and BINGO[1][1] == 1 and BINGO[2][2] == 1:
  print('Yes')
  sys.exit()
  
if BINGO[0][2] == 1 and BINGO[1][1] == 1 and BINGO[2][0] == 1:
  print('Yes')
  sys.exit() 
      
print('No')

Solution (Python):
from itertools import product
import numpy as np

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

is_open = np.array([[0] * 3 for _ in range(3)])
for i, k in product(range(3), repeat=2):
    if a[i][k] in b:
        is_open[i][k] = 1

bingo = False
for i in range(3):
    if sum(is_open[i, :]) == 3:
        bingo = True
        break
    elif sum(is_open[:, i]) == 3:
        bingo = True
        break
if not bingo:
    if sum(np.diag(is_open)) == 3:
        bingo = True
    elif sum(np.diag(np.fliplr(is_open))) == 3:
        bingo = True

print('Yes') if bingo 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())

c_1=[0,0,0]
c_2=[0,0,0]
c_3=[0,0,0]
b = []

count = 0

for i in range(N):
    b.append(int(input()))
    
for i in range(N):
    for j in range(3):
        if b[i] == a_1[j]:
            c_1[j] = 1
        if b[i] == a_2[j]:
            c_2[j] = 1
        if b[i] == a_3[j]:
            c_3[j] = 1
            
if c_1[0] == 1 and c_1[1] == 1 and c_1[2]:
    count += 1
if c_2[0] == 1 and c_2[1] == 1 and c_2[2]:
    count += 1
if c_3[0] == 1 and c_3[1] == 1 and c_3[2]:
    count += 1
if c_1[0] == 1 and c_2[0] == 1 and c_3[0]:
    count += 1
if c_1[1] == 1 and c_2[1] == 1 and c_3[1]:
    count += 1
if c_1[2] == 1 and c_2[2] == 1 and c_3[2]:
    count += 1
if c_1[0] == 1 and c_2[1] == 1 and c_3[2]:
    count += 1
if c_1[2] == 1 and c_2[1] == 1 and c_3[0]:
    count += 1







if count >= 1:
    print('Yes')
else:
    print('No')

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

ans = False
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):
    if sum(a[i])==0:
        ans = True
        break
    if (a[0][i]+a[1][i]+a[2][i])==0:
        ans = True
        break
if (a[0][0]+a[1][1]+a[2][2])==0:
    ans = True

if (a[0][2]+a[1][1]+a[2][0])==0:
    ans = True

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

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


for i in range(n):
    hit = input()
    for line in bingo:
        if hit in line:
            i = line.index(hit)
            line[i] = '○'
            break


is_bingo = False

for line in bingo:
  if line[0] == line[1] == line[2]:
    is_bingo = True

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

if bingo[0][0] == bingo[1][1] == bingo[2][2]:
  is_bingo = True
elif bingo[0][2] == bingo[1][1] == bingo[2][0]:
  is_bingo = True

if is_bingo:
    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())
S =[int(input()) for i  in range(N)]
ans = "No"

D = [A[0],B[0],C[0]]
E = [A[1],B[1],C[1]]
F = [A[2],B[2],C[2]]
G = [A[0],B[1],C[2]]
H = [A[2],B[1],C[0]]

if len(set(S)&set(A)) >= 3:
  ans ="Yes"
if len(set(S)&set(B)) >= 3:
  ans ="Yes"
if len(set(S)&set(C)) >= 3:
  ans ="Yes"
if len(set(S)&set(D)) >= 3:
  ans ="Yes"
if len(set(S)&set(E)) >= 3:
  ans ="Yes"
if len(set(S)&set(F)) >= 3:
  ans ="Yes"
if len(set(S)&set(G)) >= 3:
  ans ="Yes"
if len(set(S)&set(H)) >= 3:
  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):
a0 = list(map(int,input().split(" ")))
a1 = list(map(int,input().split(" ")))
a2 = list(map(int,input().split(" ")))
n = int(input())
b = []

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

for i in range(n):
    for j in range(3):
        if b[i] == a0[j]:
            a0[j] = 0
        if b[i] == a1[j]:
            a1[j] = 0
        if b[i] == a2[j]:
            a2[j] = 0

ans = 0

if a0[0] + a0[1] + a0[2] == 0:
    ans += 1
if a1[0] + a1[1] + a1[2] == 0:
    ans += 1
if a2[0] + a2[1] + a2[2] == 0:
    ans += 1
if a0[0] + a1[0] + a2[0] == 0:
    ans += 1
if a0[1] + a1[1] + a2[1] == 0:
    ans += 1
if a0[2] + a1[2] + a2[2] == 0:
    ans += 1
if a0[0] + a1[1] + a2[2] == 0:
    ans += 1
if a0[2] + a1[1] + a2[0] ==0:
    ans += 1

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

Solution (Python):


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

A = []
A.extend(list(map(int, input().split())))
A.extend(list(map(int, input().split())))
A.extend(list(map(int, input().split())))

N = int(input())

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

hole = []
for i in b:
    if i in A:
        hole.append(A.index(i))
    else:
        continue

for answer in answers:
    i, j, k = answer
    if i in hole and j in hole and k in hole:
        print("Yes")
        exit(0)
print("No")

Solution (Python):

import sys

f = sys.stdin
A = [list(map(int, f.readline().split(' '))) for _ in range(3)]

f_A = A[0] + A[1] + A[2]

N = int(f.readline())
b = [int(f.readline()) for _ in range(N)]

row = {'0': 0, '1': 0, '2': 0}
col = {'0': 0, '1': 0, '2': 0}
left_diag = 0
right_diag = 0

result = 'No'
for i in range(N):
    idx = -1
    if b[i] in f_A:
        idx = f_A.index(b[i])
    else:
        continue
    i, j = idx // 3, idx % 3
    row[str(i)] += 1
    col[str(j)] += 1
    if i == j:
        left_diag += 1
    if i + j == 2:
        right_diag += 1
    if (row[str(i)] == 3 or col[str(j)] == 3 or left_diag == 3 or right_diag ==
            3):
        result = 'Yes'
        break



print(result)

Solution (Python):
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()
N=int(input())
numbers=[input() for i in range(N)]



for n in numbers:
    if a==n:
        a=0
    elif b==n:
        b=0
    elif c==n:
        c=0
    elif d==n:
        d=0
    elif e==n:
        e=0
    elif f==n:
        f=0
    elif g== n:
        g = 0
    elif h == n:
        h = 0
    elif i == n:
        i = 0
    else:
        continue

if a==b==c or d==e==f or g==h==i or a==d==g or b==e==h or c==f==i or a==e==i or c==e==g:
    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):
tbl=[list(map(int, input().split())) for _ in range(3)]
N=int(input())
lst=list(int(input()) for _ in range(N))
for i in range(3):
  for j in range(3):
    for x in lst:
      if tbl[i][j] == x:
        tbl[i][j] = 0
        break
if max(tbl[0][0],tbl[0][1],tbl[0][2]) == 0:
  print("Yes")
elif max(tbl[1][0],tbl[1][1],tbl[1][2]) == 0:
  print("Yes")
elif max(tbl[2][0],tbl[2][1],tbl[2][2]) == 0:
  print("Yes")
elif max(tbl[0][0],tbl[1][0],tbl[2][0]) == 0:
  print("Yes")
elif max(tbl[0][1],tbl[1][1],tbl[2][1]) == 0:
  print("Yes")
elif max(tbl[0][2],tbl[1][2],tbl[2][2]) == 0:
  print("Yes")
elif max(tbl[0][0],tbl[1][1],tbl[2][2]) == 0:
  print("Yes")
elif max(tbl[2][0],tbl[1][1],tbl[0][2]) == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
list1 = list(map(int,input().split()))
list2 = list(map(int,input().split()))
list3 = list(map(int,input().split()))
N=int(input())
i=0
list4=[]

rlist1=[]
rlist2=[]
rlist3=[]

while(i<N) :
  a = int(input())
  list4.append(a)
  i+=1

j=0

while(j<len(list4)):
  if(list1.count(list4[j])!=0):
    rlist1.append(list1.index(list4[j]))
  j+=1

k=0
while(k<len(list4)):
  if(list2.count(list4[k])!=0):
    rlist2.append(list2.index(list4[k]))
  k+=1

l=0
while(l<len(list4)):
  if(list3.count(list4[l])!=0):
    rlist3.append(list3.index(list4[l]))
  l+=1

result="No"

rlist1.sort()
rlist2.sort()
rlist3.sort()

if(len(rlist1)==3):
  result="Yes"

if(len(rlist2)==3):
  result="Yes"

if(len(rlist3)==3):
  result="Yes"

if(rlist1.count(0)!=0 and rlist2.count(0)!=0 and rlist3.count(0)!=0):
  result="Yes"

if(rlist1.count(1)!=0 and rlist2.count(1)!=0 and rlist3.count(1)!=0):
  result="Yes"

if(rlist1.count(2)!=0 and rlist2.count(2)!=0 and rlist3.count(2)!=0):
  result="Yes"

if(rlist1.count(0)!=0 and rlist2.count(1)!=0 and rlist3.count(2)!=0):
  result="Yes"

if(rlist1.count(2)!=0 and rlist2.count(1)!=0 and rlist3.count(0)!=0):
  result="Yes"

print(result)

Solution (Python):
n1,n2,n3=map(int, input().split())
n4,n5,n6=map(int, input().split())
n7,n8,n9=map(int, input().split())
M=[n1,n2,n3,n4,n5,n6,n7,n8,n9]
O=[0,0,0,0,0,0,0,0,0]
N=int(input())
for i in range(N):
 a=int(input())
 if a in M:
  b=M.index(a)
  if O[b]==0:
   O[b]+=1
a1=[1,0,0,1,0,0,1,0,0]
a2=[0,1,0,0,1,0,0,1,0]
a3=[0,0,1,0,0,1,0,0,1]
a4=[1,1,1,0,0,0,0,0,0]
a5=[0,0,0,1,1,1,0,0,0]
a6=[0,0,0,0,0,0,1,1,1]
a7=[1,0,0,0,1,0,0,0,1]
a8=[0,0,1,0,1,0,1,0,0]
a=[a1,a2,a3,a4,a5,a6,a7,a8]
d=0
for i in range(8):
 c=0
 for j in range(9):
  c+=a[i][j]*O[j]
 if c==3:
  d+=1
if d>=1:
 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())
lista = a+b+c
call_number = []
for i in range(n):
    k = int(input())
    call_number.append(k)
bingo_number_list = []
for m,n in enumerate(lista):
    if n in call_number:
        bingo_number_list.append(m)
    
list0 = [0,1,2]
list1 = [3,4,5]
list2 = [6,7,8]
list3 = [0,3,6]
list4 = [1,4,7]
list5 = [2,5,8]
list6 = [0,4,8]
list7 = [2,4,6]
bingo = 0
for i in range(8):
    if set(list0) <= set(bingo_number_list):
        bingo += 1
    if set(list1) <= set(bingo_number_list):
        bingo += 1
    if set(list2) <= set(bingo_number_list):
        bingo += 1
    if set(list3) <= set(bingo_number_list):
        bingo += 1
    if set(list4) <= set(bingo_number_list):
        bingo += 1
    if set(list5) <= set(bingo_number_list):
        bingo += 1
    if set(list6) <= set(bingo_number_list):
        bingo += 1
    if set(list7) <= set(bingo_number_list):
        bingo += 1

if bingo > 0:
    print("Yes")
else:
    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()))
a1_list.extend(a2_list)
a1_list.extend(a3_list)

n = int(input())
nums = []
for _ in range(n):
  x = int(input())
  nums.append(x)
  
result = "No"
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 p in patterns:
  if a1_list[p[0]] in nums and a1_list[p[1]] in nums and a1_list[p[2]] in nums:
    result = "Yes"
    break
print(result)

Solution (Python):
import collections

def bingo(card):
  v = list(card.values())
  bingo = [v[:3], v[3:6], v[6:], 
           v[::3], v[1::3], v[2::3], 
           [v[0], v[4], v[-1]], 
           [v[2], v[4], v[6]]]
  z = [0]*3
  b = [1 if n == z else 0 for n in bingo]
  if 1 in b:
    return "Yes"
  else:
    return "No"

  
card = collections.OrderedDict()
for i in range(3):
  for n in input().split():
    card[n] = 1

while 1:
  try:
    n = input()
    if card.get(n):
  	  card[n] = 0
    
  except:
    break
  
print(bingo(card))

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

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            check[i][j] = 1
OK = False
for i in range(3):
    if sum(check[i]) == 3:
        OK = True
for i in range(3):
    if check[0][i]+check[1][i]+check[2][i] == 3:
        OK = True
if check[0][0]+check[1][1]+check[2][2] == 3:
    OK = True
if check[0][2]+check[1][1]+check[2][0] == 3:
    OK = True
if OK:
    print('Yes')
else:
    print('No')

Solution (Python):
import random

A = input().split()
B = input().split()
C = input().split()

A[0]=int(A[0])
A[1]=int(A[1])
A[2]=int(A[2])

B[0]=int(B[0])
B[1]=int(B[1])
B[2]=int(B[2])

C[0]=int(C[0])
C[1]=int(C[1])
C[2]=int(C[2])


N = input()
N = int(N)


for i in range(N):
  j = input()
  j=int (j)
 
  if A[0] == j :
    A[0] =1
  if A[1] == j :
    A[1] =1
  if A[2] == j :
    A[2] =1
    
  if B[0] == j :
    B[0] =1
  if B[1] == j :
    B[1] =1
  if B[2] == j :
    B[2] =1
    
  if C[0] == j :
    C[0] =1
  if C[1] == j :
    C[1] =1
  if C[2] == j :
    C[2] =1
    
if ((A[0]==1 and A[1]==1 and A[2]==1) or (B[0]==1 and B[1]==1 and B[2]==1) or (C[0]==1 and C[1]==1 and C[2]==1) or (A[0]==1 and B[0]==1 and C[0]==1) or (A[1]==1 and B[1]==1 and C[1]==1) or (A[2]==1 and B[2]==1 and C[2]==1) or (A[0]==1 and B[1]==1 and C[2]==1) or (A[2]==1 and B[1]==1 and C[0]==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()))


a=a1+a2+a3

n=int(input())

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

def aru(n):
    if n in b:
        return True
    else:
        return False

ans=[aru(aa) for aa in a]
    
    


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

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

N = int(input())
a = [int(input()) for i in range(N)]
  
for i in a:
  for j in range(3):
    for k in range(3):
      if i == A[j][k]:
        P[j][k] = 1

if P[0][0] * P[0][1] * P[0][2] == 1 or P[1][0] * P[1][1] * P[1][2] == 1 or P[2][0] * P[2][1]\
*P[2][2] == 1 or P[0][0] * P[1][0] *P[2][0] == 1 or P[0][1] * P[1][1] * P[2][1] == 1 or\
P[0][2] * P[1][2] * P[2][2] == 1 or P[0][0] * P[1][1] * P[2][2] == 1 or\
P[0][2] * P[1][1] * P[2][0] == 1:
  print("Yes")
else:
  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()))
a1_list.extend(a2_list)
a1_list.extend(a3_list)

n = int(input())
nums = []
for _ in range(n):
  x = int(input())
  nums.append(x)
  
result = "No"
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 p in patterns:
  if a1_list[p[0]] in nums and a1_list[p[1]] in nums and a1_list[p[2]] in nums:
    result = "Yes"
    break
print(result)

Solution (Python):
import sys
A=[[0]*3 for i in range(3)]
for i in range(3):
  A[i]=list(map(int,input().split()))
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k]==b:
        A[j][k]=10**10
for i in range(3):
  if sum(A[i])==3*10**10:
    print("Yes")
    sys.exit()
a=0
for i in range(3):
  a=a+A[i][0]
if a==3*10**10:
  print("Yes")
  sys.exit()
a=0
for i in range(3):
  a=a+A[i][1]
if a==3*10**10:
  print("Yes")
  sys.exit()
a=0
for i in range(3):
  a=a+A[i][2]
if a==3*10**10:
  print("Yes")
  sys.exit()
if A[0][0]+A[1][1]+A[2][2]==3*10**10 or A[0][2]+A[1][1]+A[2][0]==3*10**10:
  print("Yes")
  sys.exit()
print("No")

Solution (Python):
import numpy as np

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


flag = False
n = int(input())
n_list=[list(map(int,input().split())) for i in range(n)]
bingo_list=np.asarray(bingo_list)

for j in n_list:
    if j in bingo_list:
        bingo_list = np.where(bingo_list==j, 0, bingo_list)


for i in range(3):
    if sum(bingo_list[i]) == 0 or sum(bingo_list[:, i]) == 0:
        flag = True
        break

a = (bingo_list[0][0]+bingo_list[1][1]+bingo_list[2][2])
b = (bingo_list[0][2]+bingo_list[1][1]+bingo_list[2][0])
if(a == 0 or b == 0):
    flag = True

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

Solution (Python):
bingo = []
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
matched = [[False for _ in range(3)] for _ in range(3)]
N = int(input())
for n in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                matched[i][j] = True
is_bingo = False
if matched[0][0] and matched[1][1] and matched[2][2]:
    is_bingo = True
if matched[0][2] and matched[1][1] and matched[2][0]:
    is_bingo = True
if matched[0][0] and matched[0][1] and matched[0][2]:
    is_bingo = True
if matched[1][0] and matched[1][1] and matched[1][2]:
    is_bingo = True
if matched[2][0] and matched[2][1] and matched[2][2]:
    is_bingo = True
if matched[0][0] and matched[1][0] and matched[2][0]:
    is_bingo = True
if matched[0][1] and matched[1][1] and matched[2][1]:
    is_bingo = True
if matched[0][2] and matched[1][2] and matched[2][2]:
    is_bingo = True
if is_bingo:
    print('Yes')
else:
    print('No')

Solution (Python):
def determin_bingo(row_list):
    for num in row_list:
        if num != 0:
            return False
    return True

g=0
a_list=[]
while g<3:
    a_element=input()
    a_element=a_element.split()
    a_list.append(list(map(int, a_element)))
    g+=1

h=0
b_list=[]
n=int(input())
while h<n:
    b_list.append(int(input()))
    h+=1
    
a_list.extend([
    [a_list[0][0], a_list[1][0], a_list[2][0]],
    [a_list[0][2], a_list[1][2], a_list[2][2]],
    [a_list[0][0], a_list[1][1], a_list[2][2]],
    [a_list[0][2], a_list[1][1], a_list[2][0]]
])

f=0
for a in a_list:
    for b in b_list:
        if b in a:
            a_list[f][a.index(b)]=0
    f+=1


result='No'

for a in a_list:
    if determin_bingo(a):
        result='Yes'
        break

print(result)

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


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

cnt1 = 0
for i in range(8):
    cnt = 0
    for j in range(3):
        for k in range(N):
            if A[i][j] == B[k]:
                cnt += 1
            if cnt == 3:
                cnt1 = 100
if cnt1 != 0:
    print('Yes')
else:
    print('No')

Solution (Python):
al = [input().split() for _ in range(3)]
n = int(input())
for _ in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if al[i][j]==b:
                al[i][j] = "0"

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

Solution (Python):
bingo = [list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))]
N = int(input())
numbers = []
zeros = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
    numbers.append(int(input()))

for i in numbers:
    for y, row in enumerate(bingo):
        for x, elem in enumerate(row):
            if bingo[x][y] == i:
                zeros[x][y] = 1
ans = False
for i in range(3):
    if zeros[i][0] == 1 and zeros[i][1] == 1 and zeros[i][2] == 1:
        ans = True
    if zeros[0][i] == 1 and zeros[1][i] == 1 and zeros[2][i] == 1:
        ans = True
if zeros[0][0] == 1 and zeros[1][1] == 1 and zeros[2][2] == 1:
    ans = True
if zeros[0][2] == 1 and zeros[1][1] == 1 and zeros[2][0] == 1:
    ans = True
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
aList = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
bList = [int(input()) for _ in range(n)]
for i in range(3):
    for j in range(3):
        if aList[i][j] in bList:
            aList[i][j] = 0
flag = False
if [0, 0, 0] in aList:
    flag = True
else:
    for i in range(3):
        if aList[0][i] == aList[1][i] == aList[2][i] == 0:
            flag = True
if not flag and aList[1][1] == 0:
    if aList[0][0] == aList[2][2] == 0 or aList[2][0] == aList[0][2] == 0:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

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

for y in range(3):
    for b in b_list:
        if b in a_list[y]:
            index = a_list[y].index(b)
            a_list[y][index] = -1

is_bingo = False
for y in range(3):
    if sum(a_list[y]) == -3:
        is_bingo = True
        break

for x in range(3):
    if a_list[0][x]+a_list[1][x]+a_list[2][x] == -3:
        is_bingo = True
        break

if a_list[0][0]+a_list[1][1]+a_list[2][2] == -3:
    is_bingo = True
elif a_list[0][2]+a_list[1][1]+a_list[2][0] == -3:
    is_bingo = True


if is_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 = []
for i in range(N):
    b = int(input())
    B.append(b)

for i in B:
    for j in range(3):
        if i == A1[j]:
            A1[j] = 0
        elif i == A2[j]:
            A2[j] = 0
        elif i == A3[j]:
            A3[j] = 0
        
if A1 == [0,0,0] or A2 == [0,0,0] or A3 == [0,0,0]:
    print("Yes")
elif A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
    print("Yes")
elif A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
     print("Yes")
elif A1[0] == 0 and A2[0] == 0 and A3[0] == 0:
    print("Yes")
elif A1[1] == 0 and A2[1] == 0 and A3[1] == 0:
    print("Yes")
elif A1[2] == 0 and A2[2] == 0 and A3[2] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

bingo_list = [list(map(int, input().strip().split())) for i in range(3)]
n = int(input())
num_list = [int(input()) for i in range(n)]

bingo_ar = np.array(bingo_list)
out_ar = np.zeros((3, 3), dtype=int)

for i in range(3):
    for j in range(3):
        if bingo_ar[i, j] in num_list:
            out_ar[i, j] = 1

out = 'No'

if max(max(np.sum(out_ar, 0, dtype=int)), max(np.sum(out_ar, 1, dtype=int)), out_ar[0, 0] +
       out_ar[1, 1] + out_ar[2, 2], out_ar[2, 0] +
       out_ar[1, 1] + out_ar[0, 2]) == 3:
    out = 'Yes'

print(out)

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

n=int(input())
b = [(input()) for i in range(n)]
s=[]
for i in range(n):
  for j in range(3):
    if b[i] in a[j]:
      k=a[j].index(b[i])
      s.append([j,k])
      if [j,0] in s and [j,1] in s and [j,2] in s:
        print("Yes")
        break
      elif [0,k] in s and [1,k] in s and [2,k] in s:
        print("Yes")
        break
      elif j==k:
        if [0,0] in s and [1,1] in s and [2,2] in s:
          print("Yes")
          break
        elif [0,2] in s and [1,1] in s and [2,0] in s:
          print("Yes")
          break
  else:
    continue
  break
else:
  print("No")