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

N = int(input())
BL = list(int(input()) for i in range(N))


def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]

for k, i in enumerate(AL):
    for n,j in enumerate(i):
        if j in BL:
            AL[k][n]="True"


ans=False
if AL[0][0]=="True" and AL[1][1]=="True" and AL[2][2]=="True":
    ans=True
if AL[0][2]=="True" and AL[1][1]=="True" and AL[2][0]=="True":
    ans=True
if AL[0][0]=="True" and AL[0][1]=="True" and AL[0][2]=="True":
    ans=True
if AL[1][0]=="True" and AL[1][1]=="True" and AL[1][2]=="True":
    ans=True
if AL[2][0]=="True" and AL[2][1]=="True" and AL[2][2]=="True":
    ans=True
if AL[0][0]=="True" and AL[1][0]=="True" and AL[2][0]=="True":
    ans=True
if AL[0][1]=="True" and AL[1][1]=="True" and AL[2][1]=="True":
    ans=True
if AL[0][2]=="True" and AL[1][2]=="True" and AL[2][2]=="True":
    ans=True

if ans:
    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 b in B:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = -100

f = False
for i in range(3):
  s = 0
  for j in range(3):
    s += A[i][j]
  if s == -300:
    f = True
for i in range(3):
  s = 0
  for j in range(3):
    s += A[j][i]
  if s == -300:
    f = True
s = 0
for i in range(3):
  s += A[i][i]
  if s == -300:
    f = True
s = 0
for i in range(3):
  s += A[i][2-i]
  if s == -300:
    f = True
print('Yes' if f else 'No')

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
    
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if b[i] in A:
    l.append(tuple(nd[0] for nd in np.where(A == b[i])))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
a = list(np.array(a).flatten())
N = int(input())
index = []
for _ in range(N):
    b_i = int(input())
    if b_i in a:
        index.append(a.index(b_i))
for i in sorted(index):
    if 0 in index and 1 in index and 2 in index:
        print("Yes")
        exit()
    elif 0 in index and 3 in index and 6 in index:
        print("Yes")
        exit()
    elif 0 in index and 4 in index and 8 in index:
        print("Yes")
        exit()
    elif 1 in index and 4 in index and 7 in index:
        print("Yes")
        exit()
    elif 2 in index and 5 in index and 8 in index:
        print("Yes")
        exit()
    elif 2 in index and 4 in index and 6 in index:
        print("Yes")
        exit()
    elif 3 in index and 4 in index and 5 in index:
        print("Yes")
        exit()
    elif 6 in index and 7 in index and 8 in index:
        print("Yes")
        exit()
print("No")

Solution (Python):
a1, a2, a3 = input(), input(), input()
a1 = [int(i) for i in a1.split()]
a2 = [int(i) for i in a2.split()]
a3 = [int(i) for i in a3.split()]
A = [a1, a2, a3]
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
for i in range(len(b)):
    for j in range(len(A)):
        for k in range(len(A[0])):
            if b[i] == A[j][k]:
                A[j][k] = 0
ans = 0
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        ans = 1
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        ans = 1
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    ans = 1
if A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
    ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
input1 = list(map(int, (input().split())))
input2 = list(map(int, (input().split())))
input3 = list(map(int, (input().split())))

a = input1 + input2 + input3

n = int(input())

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


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

for i in range(3):
    if(a[i] + a[i+3] + a[i+6] == 0):
        print("Yes")
        exit(0)

for i in [0, 3, 6]:
    
    if(a[i] + a[i+1] + a[i+2] == 0):
        print("Yes")
        exit(0)

if(a[0] + a[4] + a[8] == 0):
    print("Yes")
    exit(0)

if(a[2] + a[4] + a[6] == 0):
    print("Yes")
    exit(0)

print("No")

Solution (Python):
import sys

f = sys.stdin

l1 = f.readline().rstrip().split(" ")
l2 = f.readline().rstrip().split(" ")
l3 = f.readline().rstrip().split(" ")

mat = l1 + l2 + l3

f.readline()  
nums = []
for line in f.readlines():
    nums.append(line.rstrip())



def check(kohos, n1, n2, n3):
    kohos = set(kohos)
    if n1 in kohos:
        if n2 in kohos:
            if n3 in kohos:
                
                print("Yes", end="")
                quit()
    return False



check(nums, mat[0], mat[1], mat[2])
check(nums, mat[3], mat[4], mat[5])
check(nums, mat[6], mat[7], mat[8])

check(nums, mat[0], mat[3], mat[6])
check(nums, mat[1], mat[4], mat[7])
check(nums, mat[2], mat[5], mat[8])

check(nums, mat[0], mat[4], mat[8])
check(nums, mat[2], mat[4], mat[6])
print("No", end="")

Solution (Python):
bingo = []
for i in range(3):
  row = [int(j) for j in input().split()]
  bingo.append(row)
ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"
if (bingo[0][0] + bingo[1][0] + bingo[2][0]) == -3:
  ans = "Yes"
if (bingo[0][1] + bingo[1][1] + bingo[2][1]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][2] + bingo[2][2]) == -3:
  ans = "Yes"
print(ans)

Solution (Python):
import sys
a = [ list(map(int,input().split(" "))) for i in range(3)]
N=int(input())
c=0
for i in range(N):
  b=int(input())
  for j in range(3):
    
    for z in range(3):
      if a[j][z]-b==0:
        
        a[j][z]=0

if a[0][0]+a[1][1]+a[2][2]==0 or a[2][0]+a[1][1]+a[0][2]==0 or 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 or 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')
else:


    print('No')

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

flag=0
for i in range(0,3):
  if bingo[i][0]*bingo[i][1]*bingo[i][2]==1:
    flag=1
for i in range(0,3):
  if bingo[0][i]*bingo[1][i]*bingo[2][i]==1:
    flag=1
if bingo[0][0]*bingo[1][1]*bingo[2][2]==1:
  flag=1
if bingo[0][2]*bingo[1][1]*bingo[2][0]==1:
  flag=1

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

Solution (Python):
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=list(set([int(input()) for _ in range(n)]))
l=[]
for i in range(len(b)):
  for j in range(3):
    for k in range(3):
      if b[i]==a[j][k]:
        l.append([j+1,k+1])
if len(l)>=7:
  print('Yes')
elif len(l)<=2:
  print('No')
else:
  if l.count([1,1])==l.count([2,2])==l.count([3,3])==1 or l.count([1,3])==l.count([2,2])==l.count([3,1])==1:
    print('Yes')
  else:
    count1,count2=1,1
    l=sorted(l, key=lambda x: (x[0]))
    ll=sorted(l, key=lambda x: (x[1]))
    for i in range(len(l)-1):
      if l[i][0]==l[i+1][0]:
        count1+=1
      elif count1!=3:
        count1=1
      if ll[i][1]==ll[i+1][1]:
        count2+=1
      elif count2!=3:
        count2=1
    if count1==3 or count2==3:
      print('Yes')
    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()))
ans=[]
for i in b:
    if (i in a0) == True:
        ans.append(a0.index(i))
    if (i in a1) == True:
        ans.append((a1.index(i))+3)
    if (i in a2) == True:
        ans.append((a2.index(i))+6)
if (0 in ans) and (1 in ans) and (2 in ans) == True:
    print("Yes")
elif (0 in ans) and (3 in ans) and (6 in ans) == True:
    print("Yes")
elif (0 in ans) and (4 in ans) and (8 in ans) == True:
    print("Yes")
elif (1 in ans) and (4 in ans) and (7 in ans) == True:
    print("Yes")
elif (2 in ans) and (5 in ans) and (8 in ans) == True:
    print("Yes")
elif (2 in ans) and (4 in ans) and (6 in ans) == True:
    print("Yes")
elif (3 in ans) and (4 in ans) and (5 in ans) == True:
    print("Yes")
elif (6 in ans) and (7 in ans) and (8 in ans) == True:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
bingo = []
for _ in range(3):
    l=list(map(int, input().split()))
    bingo.extend(l)

N = int(input())
indices=[]

for _ in range(N):
    num = int(input())
    if num in bingo:
        indices.append(bingo.index(num))

candidates=[[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 candidate in candidates:
    if len(list(set(indices)&set(candidate))) == 3:
        ans='Yes'
        break
print(ans)

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 h in range(3):
    for w in range(3):
        for i in range(N):
            if b[i] == A[h][w]:
                A[h][w] = 0
if [0,0,0] in A:
    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:
    ans = 'No'
    for i in zip(*A):
        if i == (0,0,0):
            ans = 'Yes'
            break
    print(ans)

Solution (Python):
l = [list(map(int,input().split())) for _ in range(3)]
lb = [[0 for j in range(3)] for i in range(3)]
bl = []
cnt = 0
f = 0




n = int(input())

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

bll = list(dict.fromkeys(bl))


for i in bll:
    for j in range(3):
        for k in range(3):
            if l[j][k] == int(i):
                
                lb[j][k] = 1
                break



for i in range(3):
    for j in range(3):
        if lb[i][j] == 1:
            cnt += 1
        else:
            cnt = 0
            break
    else:
        if cnt == 3:
            f = 1
            break
        else:
            cnt = 0

cnt = 0

for i in range(3):
    for j in range(3):
        if lb[j][i] == 1:
            cnt += 1
        else:
            cnt = 0
            break
    else:
        if cnt == 3:
            f = 1
            break
        else:
            cnt = 0

if lb[0][0] == 1 and lb[1][1] == 1 and lb[2][2] == 1:
    f = 1
elif lb[0][2] == 1 and lb[1][1] == 1 and lb[2][0] == 1:
    f = 1

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

Solution (Python):
A1 = [int(i) for i in input().split()]
A2 = [int(i) for i in input().split()]
A3 = [int(i) for i in input().split()]




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

for b in B:
    if b in A1:
        A1[A1.index(b)] = 0
    if b in A2:
        A2[A2.index(b)] = 0
    if b in A3:
        A3[A3.index(b)] = 0

if sum(A1) * sum (A2) * sum(A3) * (A1[0]+A2[0]+A3[0]) * (A1[1]+A2[1]+A3[1]) * (A1[2]+A2[2]+A3[2]) * (A1[0]+A2[1]+A3[2]) * (A1[2]+A2[1]+A3[0]) == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import itertools
import sys

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for j in range(N):
  n = int(input())
  num_list.append(n)

set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i},{c,e,g}]
the_set = set(num_list) & set([a,b,c,d,e,f,g,h,i])

v = itertools.permutations(the_set,3)
for k in v:
  if set(k) in set_list:
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
s=[list(map(int,input().split())) for i in range(3)]
t=int(input())
u=[int(input()) for i in range(t)]
for i in range(t):
  for j in range(3):
    for k in range(3):
      if s[j][k]==u[i]:
        s[j][k]=0
b=0
if s[0][0]==0 and s[1][0]==0 and s[2][0]==0:
  b=1
elif s[0][1]==0 and s[1][1]==0 and s[2][1]==0:
  b=1
elif s[0][2]==0 and s[1][2]==0 and s[2][2]==0:
  b=1
elif s[0][0]==0 and s[0][1]==0 and s[0][2]==0:
  b=1
elif s[1][0]==0 and s[1][1]==0 and s[1][2]==0:
  b=1
elif s[2][0]==0 and s[2][1]==0 and s[2][2]==0:
  b=1
elif s[0][0]==0 and s[1][1]==0 and s[2][2]==0:
  b=1
elif s[0][2]==0 and s[1][1]==0 and s[2][0]==0:
  b=1
if b==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 _ in range(N):
    B.append(int(input()))


bingo=False
for i in range(3):
    for j in range(3):
        if not A[i][j] in B:
            break
        if j == 2:
            bingo=True


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


for i in range(3):
    if not A[i][i] in B:
        break
    if i == 2:
        bingo = True

for i in range(3):
    if not A[2-i][i] in B:
        break
    if i == 2:
        bingo = True

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

Solution (Python):
A = []

for i in range(3):
  A00 = input().rstrip().split(' ')
  A0 = int(A00[0])
  A1 = int(A00[1])
  A2 = int(A00[2])
  A.append([A0, A1, A2])

N = int(input())
b = []

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


flag_A = [[0,0,0],[0,0,0],[0,0,0]]

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

if flag_A[0][0] == 1 and flag_A[0][1] == 1 and flag_A[0][2] == 1:
  print("Yes")
elif flag_A[1][0] == 1 and flag_A[1][1] == 1 and flag_A[1][2] == 1:
  print("Yes")
elif flag_A[2][0] == 1 and flag_A[2][1] == 1 and flag_A[2][2] == 1:
  print("Yes")
elif flag_A[0][0] == 1 and flag_A[1][0] == 1 and flag_A[2][0] == 1:
  print("Yes")
elif flag_A[0][1] == 1 and flag_A[1][1] == 1 and flag_A[2][1] == 1:
  print("Yes")
elif flag_A[0][2] == 1 and flag_A[1][2] == 1 and flag_A[2][2] == 1:
  print("Yes")
elif flag_A[0][0] == 1 and flag_A[1][1] == 1 and flag_A[2][2] == 1:
  print("Yes")
elif flag_A[0][2] == 1 and flag_A[1][1] == 1 and flag_A[2][0] == 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()))
x=[[0 for i in range(3)] for j in range(3)]
N=int(input())
if N>=3:
  for i in range(N):
    b=int(input())
    for j in range(3):
      if A[j]==b:
        x[0][j]=1
      elif B[j]==b:
        x[1][j]=1
      elif C[j]==b:
        x[2][j]=1
  flag=0
  if x[0][0]==1:
    if x[0][1]==1 and x[0][2]==1:
      flag=1
    if x[1][0]==1 and x[2][0]==1:
      flag=1
    if x[1][1]==1 and x[2][2]==1:
      flag=1
  if x[1][1]==1:
    if x[0][1]==1 and x[2][1]==1:
      flag=1
    if x[1][0]==1 and x[1][2]==1:
      flag=1
    if x[0][2]==1 and x[2][0]==1:
      flag=1
  if x[2][2]==1:
    if x[2][0]==1 and x[2][1]==1:
      flag=1
    if x[0][2]==1 and x[1][2]==1:
      flag=1
  if flag==1:
    print("Yes")
  else:
    print("No")
  
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 _ in range(N)}
A = a1+a2+a3
ijk = [ [0,1,2], [3,4,5], [6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]


end = False
for i,j,k in ijk:
    if {A[i], A[j], A[k]} <= B:
        print('Yes')
        end = True
        break
    else:
        continue
if not end:        
    print('No')

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

N=int(input())
for i in range(N):
    b=int(input()) 
    for i in range(3):
        for j in range(3):
            if  A[i][j]==b:
                B[i][j]=1    

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

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

Solution (Python):
import sys
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
for i in range(3):
    
    if A[i][0] in B and A[i][1] in B and A[i][2] in B:
        print("Yes")
        sys.exit()
    elif A[0][i] in B and A[1][i] in B and A[2][i] in B:
        print("Yes")
        sys.exit()
    elif A[0][0] in B and A[1][1] in B and A[2][2] in B:
        print("Yes")
        sys.exit()
    elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):




import sys
input = sys.stdin.readline



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

    res = 'No'

    C = [[0 for i in range(3)] for j in range(3)]

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

    for i in range(3):
        if C[i] == [1,1,1]:
            res = 'Yes'

    for i in range(3):
        temp = []
        for j in range(3):
            if C[j][i] == 1:
                temp.append(1)
            else:
                temp.append(0)
        
        if temp == [1,1,1]:
            res = 'Yes'
            break

    temp1 = [C[0][0],C[1][1],C[2][2]]
    temp2 = [C[0][2],C[1][1],C[2][0]]

    if temp1 == [1,1,1]:
        res = 'Yes'
    if temp2 == [1,1,1]:
        res = 'Yes'

    print(res)



main()

Solution (Python):
import sys
a =[]
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
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):
    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:
        print('Yes')
        exit()
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i]==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):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def solve():
    a = LIR(3)
    n = II()
    c = [0] * 9
    for i in range(n):
        b = II()
        for i in range(3):
            for j in range(3):
                c[i * 3 + j] |= a[i][j] == b
    ans = (c[0] & c[1] & c[2]) | (c[3] & c[4] & c[5]) | (c[6] & c[7] & c[8])
    for i in range(3):
        ans |= c[i] & c[3 + i] & c[6 + i]
    ans |= c[0] & c[4] & c[8]
    ans |= c[2] & c[4] & c[6]
    print("Yes" if ans else "No")
    return




if __name__ == '__main__':
    solve()

Solution (Python):
a11,a12,a13 = input().split()
a21,a22,a23 = input().split()
a31,a32,a33 = input().split()
lst = [a11,a12,a13,a21,a22,a23,a31,a32,a33]
bingo = []
n = int(input())
for i in range(n):
    ai = input()
    if ai in lst:
        bingo.append(lst.index(ai))
if 4 in bingo:
    if 0 in bingo:
        if 8 in bingo:
            print('Yes')
            exit()
    if 1 in bingo:
        if 7 in bingo:
            print('Yes')
            exit()
    if 2 in bingo:
        if 6 in bingo:
            print('Yes')
            exit()
    if 3 in bingo:
        if 5 in bingo:
            print('Yes')
            exit()
if 0 in bingo:
    if 1 in bingo:
        if 2 in bingo:
            print('Yes')
            exit()
    if 3 in bingo:
        if 6 in bingo: 
            print('Yes')
            exit()
if 8 in bingo:
    if 2 in bingo:
        if 5 in bingo:
            print('Yes')
            exit()
    if 6 in bingo:
        if 7 in bingo:           
            print('Yes')
            exit()
print('No')

Solution (Python):
import itertools

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

a = list(itertools.chain.from_iterable(a))

def return_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default

def check_bingo(a):
    if a[0] + a[1] + a[2] == 0:
        return True
    if a[3] + a[4] + a[5] == 0:
        return True
    if a[6] + a[7] + a[8] == 0:
        return True
    if a[0] + a[3] + a[6] == 0:
        return True
    if a[1] + a[4] + a[7] == 0:
        return True
    if a[2] + a[5] + a[8] == 0:
        return True
    if a[0] + a[4] + a[8] == 0:
        return True
    if a[2] + a[4] + a[6] == 0:
        return True
    return False

for i in b:
    if return_index(a, i) >= 0:
        a[return_index(a, i)] = 0

print("Yes") if check_bingo(a) else print("No")

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

Solution (Python):

a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
n = int(input())
bango = [int(input()) for k in range(n)]
if a in bango and b in bango and c in bango:
    print("Yes")
elif d in bango and e in bango and f in bango:
    print("Yes")
elif g in bango and h in bango and i in bango:
    print("Yes")
elif a in bango and d in bango and g in bango:
    print("Yes")
elif b in bango and e in bango and h in bango:
    print("Yes")
elif c in bango and f in bango and i in bango:
    print("Yes")
elif a in bango and e in bango and i in bango:
    print("Yes")
elif c in bango and e in bango and g in bango:
    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())


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

if A[0]in l and A[1] in l and A[2] in l:
    print('Yes')
elif B[0] in l and B[1] in l and B[2] in l:
    print('Yes')
elif C[0] in l and C[1] in l and C[2] in l:
    print('Yes')
elif A[0] in l and B[0] in l and C[0] in l:
    print('Yes')
elif A[1] in l and B[1] in l and C[1] in l:
    print('Yes')
elif A[2] in l and B[2] in l and C[2] in l:
    print('Yes')
elif A[0] in l and B[1] in l and C[2] in l:
    print('Yes')
elif A[2] in l and B[1] in l and C[0] in l:
    print('Yes')

else:
    print('No')

Solution (Python):
a = [[0 for i in range(3)] for j in range(3)]
bingo = [[False for i in range(3)] for j in range(3)]
b = []
flag = False


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


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

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

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[0][2] and bingo[1][1] and bingo[2][0]:
    flag = True

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

Solution (Python):
import sys

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

row = A
column = [[] for _ in range(3)]
for i in range(3):
    column[i] = [A[0][i], A[1][i], A[2][i]]
cross = [[A[0][0], A[1][1], A[2][2]], [A[2][0], A[1][1], A[0][2]]]

for i in range(3):
    if set(row[i]) <= set(B) or set(column[i]) <= set(B):
        print('Yes')
        sys.exit()

for i in range(2):
    if set(cross[i]) <= set(B):
        print('Yes')
        sys.exit()
else:
    print('No')

Solution (Python):
def resolve():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(len(a)):
            if a[j] == b:
                a[j] = -1
    x1 = a[0:3].count(-1)
    x2 = a[3:6].count(-1)
    x3 = a[6:9].count(-1)
    y1 = a[0:7:3].count(-1)
    y2 = a[1:8:3].count(-1)
    y3 = a[2:9:3].count(-1)
    nn = a[0:9:4].count(-1)
    nn2 = a[2:7:2].count(-1)

    if x1 == 3 or x2 == 3 or x3 == 3 or y1 == 3 or y2 == 3 or y3 == 3 or nn == 3 or nn2 == 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Solution (Python):
bingo = []

for i in range(3):
    bingo.append(input().split(" "))

n = int(input())

for i in range(n):
    num = input()
    for j in range(3):
        for k in range(3):
            if num == bingo[j][k]:
                bingo[j][k] = 0

result = False

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

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

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

if result == True:
    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()))
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]]

n = int(input())

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

for l in [a, b, c, d, e, f, g, h]:
    if (l[0] in bs) and (l[1] in bs) and (l[2] in bs):
        print("Yes")
        break
else:
    print("No")

Solution (Python):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def serch(x, count):
    

    for d in directions:
        nx = d+x
        
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)
                continue
            if field[nx[0]][nx[1]] == "
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)

    return count


field = []
for i in range(3):
    field.append(acinput())

N = int(input())


def chk(x):
    for i in range(3):
        for j in range(3):
            if field[i][j] == x:
                field[i][j] = -1


for i in range(N):
    chk(II())



for i in range(3):
    state = False
    for j in range(3):
        if field[i][j] != -1:
            break
        if j == 2:
            print("Yes")
            sys.exit()

for j in range(3):
    state = False
    for i in range(3):
        if field[i][j] != -1:
            break
        if i == 2:
            print("Yes")
            sys.exit()

state = False
for i in range(3):
    if field[i][i] != -1:
        break
    if i == 2:
        print("Yes")
        sys.exit()



for i in range(3):
    if field[2-i][i] != -1:
        break
    if i == 2:
        print("Yes")
        sys.exit()

print("No")