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

Solution (Python):
a = [[0] * 3 for x in range(3)]
s = [[0] * 3 for x in range(3)]
for i in range(3):
  a[i] = [int(x) for x in 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):
    for k in range(3):
      if b[i] == a[j][k]:
        s[j][k] = 1
res = "No"
if s[0][0] == 1 and s[0][1] == 1 and s[0][2] == 1:
  res = "Yes"
if s[1][0] == 1 and s[1][1] == 1 and s[1][2] == 1:
  res = "Yes"
if s[2][0] == 1 and s[2][1] == 1 and s[2][2] == 1:
  res = "Yes"
if s[0][0] == 1 and s[1][0] == 1 and s[2][0] == 1:
  res = "Yes"
if s[0][1] == 1 and s[1][1] == 1 and s[2][1] == 1:
  res = "Yes"
if s[0][2] == 1 and s[1][2] == 1 and s[2][2] == 1:
  res = "Yes"
if s[0][0] == 1 and s[1][1] == 1 and s[2][2] == 1:
  res = "Yes"
if s[2][0] == 1 and s[1][1] == 1 and s[0][2] == 1:
  res = "Yes"
print(res)

Solution (Python):
A=[[int(n) for n in input().split()] for m in range(3)]
N=int(input())

for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if b==A[j][k]:
                A[j][k]=0
                
ans="No"

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

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

if (A[0][0]==0 and A[1][1]==0 and A[2][2]==0) or (A[0][2]==0 and A[1][1]==0 and A[2][0]==0):
    ans="Yes"


print(ans)

Solution (Python):

def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    x = [[0]*3 for _ in range(3)]
    b =[]
    for _ in range(n):
        b.append(int(input()))
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                x[i][j] = 1
    
    for i in range(3):
        c = 1
        for j in range(3):
            c *= x[i][j]
        if c == 1:
            print("Yes")
            return
    for i in range(3):
        c = 1
        for j in range(3):
            c *= x[j][i]
        if c == 1:
            print("Yes")
            return
    c = 1
    for i in range(3):
        c *= x[i][i] 
    if(c):
        print("Yes")
        return
    if(x[0][2]*x[1][1]*x[2][0]):
        print("Yes")
        return
    print("No")
    

    
    

if __name__ == "__main__":
    main()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    A = [[]for _ in range(3)]
    for i in range(3):
        A[i] = LI()
    A_ = [[]for _ in range(3)]
    for i in range(3):
        for j in range(3):
            A_[j].append(A[i][j])
    A__ = [[]for  _ in range(2)]
    for i in range(3):
        A__[0].append(A[i][i])
        A__[1].append(A[i][2 - i])

    N = I()
    B = []
    for i in range(N):
        b = I()
        B.append(b)
        for i in range(3):
            if b in A[i]:
                ind = A[i].index(b)
                A[i][ind] = 0
            if b in A_[i]:
                ind = A_[i].index(b)
                A_[i][ind] = 0
        for j in range(2):
            if b in A__[j]:
                ind = A__[j].index(b)
                A__[j][ind] = 0
    ans_list = []
    for i in range(3):
        ans_list.append(sum(A[i]))
        ans_list.append(sum(A_[i]))
    for j in range(2):
        ans_list.append(sum(A__[j]))

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






if __name__ == "__main__":
    main()

Solution (Python):
al=[list(map(int, input().split())) for _ in range(3)]
bl=[[False]*3 for _ in range(3)]
n=int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if al[i][j] == b: bl[i][j] = True

for i in range(3):
    if all(bl[i]):
        print('Yes')
        exit()

for j in range(3):
    if all([bl[0][j],bl[1][j],bl[2][j]]):
        print('Yes')
        exit()

if all([bl[0][0],bl[1][1],bl[2][2]]) or all([bl[2][0],bl[1][1],bl[0][2]]):
    print('Yes')
    exit()

print('No')

Solution (Python):
A1 = [int(_) for _ in input().split()]
A2 = [int(_) for _ in input().split()]
A3 = [int(_) for _ in input().split()]
A_list = A1 + A2 + A3
N = int(input())
b_list = []
for _ in range(N):
    b_list.append(int(input()))

bingo_card = [False for _ in range(9)]

for b in b_list:
    for i in range(9):
        if A_list[i] == b:
            bingo_card[i] = True

flg = False

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

for pattern in patterns:
    if (
        bingo_card[pattern[0]]
        == bingo_card[pattern[1]]
        == bingo_card[pattern[2]]
        == True
    ):
        flg = True

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

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

ans = "No"
for k in range(3):
  if bingo[k][0] == bingo[k][1] == bingo[k][2] or \
     bingo[0][k] == bingo[1][k] == bingo[2][k]:
    ans = "Yes"
    break
if bingo[0][0] == bingo[1][1] == bingo[2][2] or \
   bingo[0][2] == bingo[1][1] == bingo[2][0]:
  ans = "Yes"
print(ans)

Solution (Python):
a = []
for _ in range(3):
  a = a + [int(i) for i in input().split()]
n = int(input())
a_bingo = [0] * 3 * 3
pos = [[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 _ in range(n):
  b = int(input())
  if b in a:
    a_bingo[a.index(b)] = 1
for po in pos:
  if a_bingo[po[0]] == a_bingo[po[1]] == a_bingo[po[2]] == 1:
    print('Yes')
    exit()
print('No')

Solution (Python):

A = [0]*101
for i in range(3):
    tmp = list(map(int,input().split()))
    for j in range(3):
        A[tmp[j]] = 3*i+j+1
N = int(input())
S = set()
for _ in range(N):
    b = int(input())
    S.add(A[b])

def bingo(l):
    ans = False
    for x,y,z in l:
        if x in S and y in S and z in S:
            ans = True
            break
    return ans

if bingo([(1,2,3),(4,5,6),(7,8,9),(1,4,7),(2,5,8),(3,6,9),(1,5,9),(3,5,7)]):
    print('Yes')
else:
    print('No')

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

bingo = 'No'

for t in zip(*a):
    a.append(list(t))

a.append([a[i][i] for i in range(3)])
a.append([a[i][2-i]for i in range(3)])

for line in a:
    if all(item in b for item in line):
        bingo = 'Yes'
        break

print(bingo)

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

bingo = 'No'

for t in zip(*a):
    a.append(list(t))

a.append([a[i][i] for i in range(3)])
a.append([a[i][2-i]for i in range(3)])

for line in a:
    if all(item in b for item in line):
        bingo = 'Yes'

print(bingo)

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    nums = np.array(read().split(), np.int64)
    a = nums[:9]

    for x in nums[10:]:
        a[a == x] = 0
    pos = ((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 pose in pos:
        if a[pose[0]] == a[pose[1]] == a[pose[2]] == 0:
            print('Yes')
            sys.exit()
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
list_a = [[int(n) for n in input().split()] for m in range(0, 3)]
n = int(input())
list_b = [int(input()) for k in range(0, n)]

if (list_a[0][0] in list_b and list_a[0][1] in list_b and list_a[0][2] in list_b) or\
    (list_a[1][0] in list_b and list_a[1][1] in list_b and list_a[1][2] in list_b) or\
    (list_a[2][0] in list_b and list_a[2][1] in list_b and list_a[2][2] in list_b) :
    print('Yes')

elif (list_a[0][0] in list_b and list_a[1][0] in list_b and list_a[2][0] in list_b) or\
    (list_a[0][1] in list_b and list_a[1][1] in list_b and list_a[2][1] in list_b) or\
    (list_a[0][2] in list_b and list_a[1][2] in list_b and list_a[2][2] in list_b) :
    print('Yes')

elif (list_a[0][0] in list_b and list_a[1][1] in list_b and list_a[2][2] in list_b) or\
    (list_a[2][0] in list_b and list_a[1][1] in list_b and list_a[0][2] in list_b):
    print('Yes')

else:
    print('No')

Solution (Python):
bin = []
for i in range(3):
  bin.append(list(map(int, input().split())))
bin = sum(bin, [])
N = int(input())
bingo = [False for _ in range(9)]
for _ in range(N):
  b = int(input())
  if b in bin:
    bingo[bin.index(b)] = True
if (bingo[0] and bingo[1] and bingo[2]) or (bingo[3] and bingo[4] and bingo[5]) or \
   (bingo[6] and bingo[7] and bingo[8]) or (bingo[0] and bingo[3] and bingo[6]) or \
   (bingo[1] and bingo[4] and bingo[7]) or (bingo[2] and bingo[5] and bingo[8]) or \
   (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bingo[4] and bingo[6]):
  print("Yes")
else:
  print("No")

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

for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a[j][k] = 0
ans = 'No'
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = 'Yes'
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = 'Yes'
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = 'Yes'
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = 'Yes'
print(ans)

Solution (Python):

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

card =[]
n = int(input())
for k in range(n):
    card.append(int(input()))

r_cnt =[0,0,0]
c_cnt =[0,0,0]
rc_result = [[0,0,0],[0,0,0],[0,0,0]]

for row in range(3):
    for column in range(3):
        if A_Bingo[row][column] in card:
            r_cnt[row] += 1
            c_cnt[column] += 1
            rc_result[row][column] = 1

if 3 in r_cnt:
    print("Yes")
elif 3 in c_cnt:
    print("Yes")
elif rc_result[0][0]*rc_result[1][1]*rc_result[2][2] == 1:
    print("Yes")
elif rc_result[0][2]*rc_result[1][1]*rc_result[2][0] == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

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]=0
			
ans_axis0=np.sum(np.array(A),axis=0)
ans_axis1=np.sum(np.array(A),axis=1)
ans_naname=[A[0][0]+A[1][1]+A[2][2],A[0][2]+A[1][1]+A[2][0]]



if 0 in ans_axis0 or 0 in ans_axis1 or 0 in ans_naname:
	print("Yes")
else:
	print("No")

Solution (Python):
A = []

for i in range(3):
  p, q, r = map(int, input().split())
  A.append(p)
  A.append(q)
  A.append(r)
N = int(input())
c = [0] * 9
for i in range(N):
  B = int(input())
  if B in A:
    position = A.index(B)
    c[position] = 1
if c[0]==c[4]==c[8]==1 or c[2]==c[4]==c[6]==1 or c[0]==c[1]==c[2]==1 or c[3]==c[4]==c[5]==1 or c[6]==c[7]==c[8]==1 or c[0]==c[3]==c[6]==1 or c[1]==c[4]==c[7]==1 or c[2]==c[5]==c[8]==1:
  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] = 0

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

  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:
    print('Yes')
    exit()
 

if A[0][2] == A[1][1] == A[2][0] == 0:
    print('Yes')
    exit()
    
  
print('No')

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

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

ans=['-']*9

for i in a:
  if i in b:
    ans[a.index(i)]='+'

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

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

for q in Q:
    for i in range(3):
        for j in range(3):
            if A[i][j] == q:
                A[i][j] = 0

if A[0][0] == A[1][1] == A[2][2] == 0:
    print('Yes')
    exit()

if A[0][2] == A[1][1] == A[2][0] == 0:
    print('Yes')
    exit()

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

    if A[0][i] == A[1][i] == A[2][i] == 0:
        print('Yes')
        exit()

print('No')

Solution (Python):
s = " 012 345 678 036 147 258 048 246 "
a = [input().split() for i in range(3)]
b = a[0] + a[1] + a[2]

for i in [input()for i in range(int(input()))]:
  if i in b:
    s = s.replace(str(b.index(i)), "")
print("Yes" if "  " in s else "No")

Solution (Python):
bingo=[]
for i in range(3):
  a=list(map(int,input().split()))
  bingo.append(a)
  
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    if b in bingo[j]:
      bingo[j][bingo[j].index(b)]=0
      
def hantei(l):
  for i in range(3):
    if all([l[i][j]==0 for j in range(3)]):
      return 'Yes'
    
    elif all([l[j][i]==0 for j in range(3)]):
      return 'Yes'
    
    elif l[0][0]==0 and l[1][1]==0 and l[2][2]==0:
      return 'Yes'
    
    elif l[0][2]==0 and l[1][1]==0 and l[2][0]==0:
      return 'Yes'
    
    else:
      continue
      
  return 'No'
    

print(hantei(bingo))

Solution (Python):
ri = lambda S: [int(v) for v in S.split()]

S = [ri(input()) for _ in range(3)]
N = int(input())
D = set()
O = set()

def mark(A, v):
    for i in range(3):
        for j in range(3):
            if A[i][j] != 0 and A[i][j] == v:
                A[i][j] = 0
                if (i, j) in [(0, 0), (1, 1), (2,2)]:
                    D.add((i,j))
                if (i, j) in [(0, 2), (1, 1), (2, 0)]:
                    O.add((i, j))

for _ in range(N):
    b = int(input())
    mark(S, b)

R = [sum(r) for r in S]
C = [sum(r) for r in zip(*S)]



check = len(D) == 3 or len(O) == 3 or any(v == 0 for v in R) or any(v == 0 for v in C)

print("Yes" if check else "No")

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




n = int(input())
b = [int(input()) for _ in range(n)]
ans = []

for i in b:
    for index, cow in enumerate(a):
        for index2, k in enumerate(cow):
            if i == k:
                a[index][index2] = True

for i in a:
    if i.count(True) == 3:
        print('Yes')
        exit(0)


for i in zip(*a):
    if i.count(True) == 3:
        print("Yes")
        exit(0)


temp = [a[i][i] for i in range(3)]
temp2 = [a[i][2-i] for i in range(3)]
if temp.count(True) == 3 or temp2.count(True) == 3:
    print('Yes')
    exit(0)


print('No')

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

    for j in range(3):
        for k in range(3):
            if Bingo[j][k] == b:
                Bingo[j][k] = 0

ans = 'No'

for i in range(3):
    if Bingo[i][0] == Bingo[i][1] == Bingo[i][2]:
        ans = 'Yes'
    if Bingo[0][i] == Bingo[1][i] == Bingo[2][i]:
        ans = 'Yes'

if Bingo[0][0] == Bingo[1][1] == Bingo[2][2]:
    ans = 'Yes'
if Bingo[2][0] == Bingo[1][1] == Bingo[0][2]:
    ans = 'Yes'

print(ans)

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]
result = ''

for b in B:
  if b in A1:
    a = A1.index(b)
    A1.remove(b)
    A1.insert(a, 0)
  elif b in A2:
    a = A2.index(b)
    A2.remove(b)
    A2.insert(a, 0)
  elif b in A3:
    a = A3.index(b)
    A3.remove(b)
    A3.insert(a, 0)
  else:
    pass


if A1.count(0) == 3:
  result ='y'
elif A2.count(0) == 3:
  result ='y'
elif A3.count(0) == 3:
  result ='y'

for m in range(3):
  if A1[m] == 0 and A2[m] == 0 and A3[m] == 0:
    result ='y' 
  else:
    pass


if A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
  result = 'y'
elif A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
  result = 'y'


if result == 'y':
  print('Yes')
else:
  print('No')

Solution (Python):
d = {}
m = [[False]*3 for _ in range(3)]
for i in range(3):
  for j, val in enumerate(list(map(int,input().split()))):
    d[val] = (i,j)
    
N = int(input())

for _ in range(N):
  key = int(input())
  if key in d:
    i,j = d[key]
    m[i][j] = True
  
def main():
  if m[0][0] and m[1][1] and m[2][2]:
    return True
  if m[0][2] and m[1][1] and m[2][0]:
    return True
  for i in range(3):
    if m[i][0] and m[i][1] and m[i][2]:
      return True
    if m[0][i] and m[1][i] and m[2][i]:
      return True
      
  return False

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

Solution (Python):
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
num=0
for s in range(3):
    num1=0
    for t in range(3):
        if A[s][t] in B:
            num1+=1
    if num1==3:
        num+=1
for a in range(3):
    num4=0
    for b in range(3):
        if A[b][a] in B:
            num4+=1
    if num4==3:
        num+=1
num2=0
for u in range(3):
    if A[u][u] in B:
        num2+=1
if num2==3:
    num+=1
num3=0
for v in range(3):
    if A[2-v][v] in B:
        num3+=1
if num3==3:
    num+=1
if num>0:
    print('Yes')
else:
    print('No')

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

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

for _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        bingo[i][j] = 1
        
check = False

for i in range(3):
  if 0 not in bingo[i]:
    check = True
  
for j in range(3):
  if bingo[0][j] + bingo[1][j] + bingo[2][j] == 3:
    check = True
    
if bingo[0][0] + bingo[1][1] + bingo[2][2] == 3:
  check = True

if bingo[0][2] + bingo[1][1] + bingo[2][0] == 3:
  check = True
  
print("Yes" if check else "No")

Solution (Python):
import numpy as np
a1 = [int(x.strip()) for x in input().split()]
a2 = [int(x.strip()) for x in input().split()]
a3 = [int(x.strip()) for x in input().split()]
a = np.array([a1,a2,a3])
n = int(input())
bingo = 0
for i in range(n):
  b = int(input())
  if b in a:
    ch = np.argwhere(a==b)
    a[ch[0][0]][ch[0][1]] = 0 
sum_col = np.sum(a, axis=0)
sum_row = np.sum(a, axis=1)
bingo = np.count_nonzero(sum_col==0) + np.count_nonzero(sum_row==0)
if a[0,0]==0 and a[1,1]==0 and a[2,2]==0:
  bingo += 1
if a[2,0]==0 and a[1,1]==0 and a[0,2]==0:
  bingo += 1
if bingo > 0:
  ans = 'Yes'
else:
  ans = 'No'
print(ans)

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

A = list()
A.append("")
A.extend(A1)
A.extend(A2)
A.extend(A3)

n = int(input())
B = list()
for _ in range(n):
    B.append(int(input()))

holes = [A.index(b) for b in B if (b in A)]
bingos = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
print("Yes" if any([(len(set(holes) & set(bingo)) == 3) for bingo in bingos]) else "No")

Solution (Python):
A=[]
for i in range(3):
  A.append(list(map(int, input().split())))
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
  
flugs = [[False] * 3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      flugs[i][j] = True
      
result = 'No'
for i in range(3):
  if all(flugs[i][:]) or all([row[i] for row in flugs]):
    result = 'Yes'
  
if all([flugs[0][0], flugs[1][1], flugs[2][2]]):
  result = 'Yes'
    
elif all([flugs[2][0], flugs[1][1], flugs[0][2]]):
  result = 'Yes'
    
print(result)

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

for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True

if (A[0][0]==True and A[1][0]==True and A[2][0]==True) or (A[0][1]==True and A[1][1]==True and A[2][1]==True) or (A[0][2]==True and A[1][2]==True and A[2][2]==True) or (A[0][0]==True and A[0][1]==True and A[0][2]==True) or (A[1][0]==True and A[1][1]==True and A[1][2]==True) or (A[2][0]==True and A[2][1]==True and A[2][2]==True) or (A[0][0]==True and A[1][1]==True and A[2][2]==True) or (A[0][2]==True and A[1][1]==True and A[2][0]==True): print('Yes')
else: print('No')

Solution (Python):
a = input("").split(" ")
a = [int(aa) for aa in a]
b = input("").split(" ")
b = [int(ab) for ab in b]
c = input("").split(" ")
c = [int(ac) for ac in c]
n = int(input(""))
hav = a + b + c
val = []
for d in range(n):
    temp = int(input(""))
    val.append(temp)
tf = [0,0,0,0,0,0,0,0,0]
i = 0
for e in hav:
    if (e in val) == True:
        tf[i] = 1
    i += 1
tr = [1,1,1]
if tf[0:3] == tr:
    print("Yes")
elif tf[3:6] == tr:
    print("Yes")
elif tf[6:9] == tr:
    print("Yes")
elif (tf[0]+tf[3]+tf[6]) == 3:
    print("Yes")
elif (tf[1]+tf[4]+tf[7]) == 3:
    print("Yes")
elif (tf[2]+tf[5]+tf[8]) == 3:
    print("Yes")
elif (tf[0]+tf[4]+tf[8]) == 3:
    print("Yes")
elif (tf[2]+tf[4]+tf[6]) == 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())

D = [int(input()) for j in range(N)]
D = list(set(D))


for i in range(len(D)):
    if D[i] == A[0]:
        A[0] = -1
    elif D[i] == A[1]:
        A[1] = -1
    elif D[i] == A[2]:
        A[2] = -1
    elif D[i] == B[0]:
        B[0] = -1
    elif D[i] == B[1]:
        B[1] = -1
    elif D[i] == B[2]:
        B[2] = -1
    elif D[i] == C[0]:
        C[0] = -1
    elif D[i] == C[1]:
        C[1] = -1
    elif D[i] == C[2]:
        C[2] = -1
    else:
        continue
    



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[1] == -1 and B[1] == -1 and C[1] == -1)or(A[0] == -1 and B[0] == -1 and C[0] == -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):
A = [list(map(int, input().split())) for i in range(3)]

N = int(input())

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


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

    vertical = [_[i] for _ in A]

    if vertical == [0, 0, 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()
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()))
A = A_1 + A_2 + A_3
check = [0 for i in range(9)]
n = int(input())
for i in range(n):
  b = int(input())
  if b in A:
    check[A.index(b)] += 1
c_1 = check[0] + check[3] + check[6]
c_2 = check[1] + check[4] + check[7]
c_3 = check[2] + check[5] + check[8]
c_4 = check[0] + check[1] + check[2]
c_5 = check[3] + check[4] + check[5]
c_6 = check[6] + check[7] + check[8]
c_7 = check[0] + check[4] + check[8]
c_8 = check[2] + check[4] + check[6]
c = [c_1,c_2,c_3,c_4,c_5,c_6,c_7,c_8]
if 3 in c:
  print('Yes')
else:
  print('No')

Solution (Python):
A = []
A += input().split()
A += input().split()
A += input().split()
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  if b[i] in A:
    A[A.index(b[i])] = '.'
    
if (A[0] == '.' and A[3] == '.' and A[6] == '.') or (A[1] == '.' and A[4] == '.' and A[7] == '.') or (A[2] == '.' and A[5] == '.' and A[8] == '.') or (A[0] == '.' and A[1] == '.' and A[2] == '.') or (A[3] == '.' and A[4] == '.' and A[5] == '.') or (A[6] == '.' and A[7] == '.' and A[8] == '.') or (A[0] == '.' and A[4] == '.' and A[8] == '.') or (A[2] == '.' and A[4] == '.' and A[6] == '.'): 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()))

ans = "No"

n = int(input())

for i in range(n):
    p = int(input())
    if a1.count(p)>0:
        a1[a1.index(p)]=-1
    if a2.count(p)>0:
        a2[a2.index(p)]=-1
    if a3.count(p)>0:
        a3[a3.index(p)]=-1

if max(a1)==-1 or max(a2)==-1 or max(a3)==-1:
    ans="Yes"

if (a1[0]==-1 and a2[0]==-1 and a3[0]==-1) or (a1[1]==-1 and a2[1]==-1 and a3[1]==-1) or ((a1[2]==-1 and a2[2]==-1 and a3[2]==-1)):
    ans="Yes"

if (a1[0]==-1 and a2[1]==-1 and a3[2]==-1) or (a1[2]==-1 and a2[1]==-1 and a3[0]==-1) :
    ans="Yes"

print(ans)

Solution (Python):
A = []
memo = [-1] * 101
for i in range(3):
    a, b, c = map(int, input().split())
    memo[a] = memo[b] = memo[c] = i
    A.append([a, b, c])
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
b = set(b)
ana = [[0] * 3 for _ in range(3)]
for num in b:
    if memo[num] == -1:
        continue
    ana[memo[num]][A[memo[num]].index(num)] = 1

if ana[0][0] == 1 and ana[1][1] == 1 and ana[2][2] == 1:
    print("Yes")
    exit()
if ana[0][2] == 1 and ana[1][1] == 1 and ana[2][0] == 1:
    print("Yes")
    exit()

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

Solution (Python):
A=[input().split() for _ in range(3)]
N=int(input())
B=[input() for _ in range(N)]

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

if A[0][0]==A[1][1]==A[2][2] or A[0][2]==A[1][1]==A[2][0]:
  print("Yes")
  exit()

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

print('No')

Solution (Python):
A = [input().split() for _ in range(3)]
N = int(input())
B = [input() for _ in range(N)]

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

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

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

print('No')

Solution (Python):
Card = [list(map(int, input().split())) for _ in range(3)]
Bingo = [[False]*3 for _ in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        if b in Card[j]:
            Bingo[j][Card[j].index(b)] = True
ans = False
for i in range(3):
    if all(Bingo[i][j] for j in range(3)):
        ans = True

for j in range(3):
    if Bingo[0][j] and Bingo[1][j] and Bingo[2][j]:
        ans = True

if Bingo[0][0] and Bingo[1][1] and Bingo[2][2]:
    ans = True
if Bingo[0][2] and Bingo[1][1] and Bingo[2][0]:
    ans = True

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

Solution (Python):
d=[[int(s) for s in input().split()] for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
for i in range(len(B)):
    for j in range(3):
        for k in range(3):
            if B[i]==d[j][k]:
                d[j][k]=-1
x=0
for i in range(3):
    if d[i][0]==d[i][1]==d[i][2]==-1 or d[0][i]==d[1][i]==d[2][i]==-1:
        x+=1
        print("Yes")
        break
if x==0:
    if d[0][0]==d[1][1]==d[2][2]==-1 or d[0][2]==d[1][1]==d[2][0]==-1:
        print("Yes")
    else:
        print("No")

Solution (Python):
l=[]
for i in range(3):
    l.append(list(map(int,input().split())))
d=list(zip(*l))
s=[]
f=0
n=int(input())
for i in range(n):
    s.append(int(input()))
for i in range(3):
    c=0
    for j in range(3):
        if(l[i][j] in s):
            c+=1
    if(c==3):
        f=1
        break
if(l[1][1] in s and l[0][0] in s and l[2][2] in s):
    f=1
if(l[0][2] in s and l[1][1] in s and l[2][0] in s):
    f=1
for i in range(3):
    c=0
    for j in range(3):
        if(d[i][j] in s):
            c+=1
    if(c==3):
        f=1
        break
if(f==1):
    print("Yes")
else:
    print("No")

Solution (Python):
A = [input().split() for _ in range(3)]
N = int(input())
c = [[False]*3 for _ in range(3)]
for _ in range(N):
    B = input()
    for i in range(3):
        if B in A[i]:
            c[i][A[i].index(B)] = True

def solve(c):
    y = "Yes"
    n = "No"
    for i in range(3):
        if c[i][0] and c[i][1] and c[i][2]:
            return y
        if c[0][i] and c[1][i] and c[2][i]:
            return y
    if c[0][0] and c[1][1] and c[2][2]:
        return y
    if c[0][2] and c[1][1] and c[2][0]:
        return y

    return n

print(solve(c))

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

d=[[0]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      d[i][j]=1
      
if d[0][0]==1 and d[0][1]==1 and d[0][2]==1:
  print('Yes')
elif d[1][0]==1 and d[1][1]==1 and d[1][2]==1:
  print('Yes')
elif d[2][0]==1 and d[2][1]==1 and d[2][2]==1:
  print('Yes')
elif d[0][0]==1 and d[1][1]==1 and d[2][2]==1:
  print('Yes')
elif d[0][0]==1 and d[1][0]==1 and d[2][0]==1:
  print('Yes')
elif d[0][1]==1 and d[1][1]==1 and d[2][1]==1:
  print('Yes')
elif d[0][2]==1 and d[1][2]==1 and d[2][2]==1:
  print('Yes')
elif d[0][2]==1 and d[1][1]==1 and d[2][0]==1:
  print('Yes')
else:
  print('No')