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):
def my_index(l,x):
    if x in l:
        return l.index(x)+1
    else:
        return 0
    
A_1_1,A_1_2,A_1_3=map(int,input().split())
A_2_1,A_2_2,A_2_3=map(int,input().split())
A_3_1,A_3_2,A_3_3=map(int,input().split())
N=int(input())
A=[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]

for i in range(N):
    bi=int(input())
    for j in range(len(A)):
        if A[j]==bi:
            if j==0:
                A_1_1=0
            elif j==1:
                A_1_2=0
            elif j==2:
                A_1_3=0
            elif j==3:
                A_2_1=0
            elif j==4:
                A_2_2=0
            elif j==5:
                A_2_3=0
            elif j==6:
                A_3_1=0
            elif j==7:
                A_3_2=0
            elif j==8:
                A_3_3=0
            else:
                pass
        else:
            pass

bingo_1=[A_1_1,A_1_2,A_1_3]
bingo_2=[A_2_1,A_2_2,A_2_3]
bingo_3=[A_3_1,A_3_2,A_3_3]
bingo_4=[A_1_1,A_2_1,A_3_1]
bingo_5=[A_1_2,A_2_2,A_3_2]
bingo_6=[A_1_3,A_2_3,A_3_3]
bingo_7=[A_1_1,A_2_2,A_3_3]
bingo_8=[A_1_3,A_2_2,A_3_1]

ans=0

if sum(bingo_1)==0:
    ans=1
elif sum(bingo_2)==0:
    ans=1
elif sum(bingo_3)==0:
    ans=1
elif sum(bingo_4)==0:
    ans=1
elif sum(bingo_5)==0:
    ans=1
elif sum(bingo_6)==0:
    ans=1
elif sum(bingo_7)==0:
    ans=1
elif sum(bingo_8)==0:
    ans=1
else:
    ans=0

if ans==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())
b = [int(input()) for i in range(N)]

hit = list()

ans = "No"
for i in range(N):
        if b[i] == A[0]:
                hit.append(1)
        if b[i] == A[1]:
                hit.append(2)
        if b[i] == A[2]:
                hit.append(3)
        if b[i] == B[0]:
                hit.append(4)
        if b[i] == B[1]:
                hit.append(5)
        if b[i] == B[2]:
                hit.append(6)
        if b[i] == C[0]:
                hit.append(7)
        if b[i] == C[1]:
                hit.append(8)
        if b[i] == C[2]:
                hit.append(9)

dct = sorted(hit)


if 1 in dct:
        if 2 in dct:
                if 3 in dct:
                        ans = "Yes"
        if 4 in dct:
                if 7 in dct:
                        ans = "Yes"
        if 5 in dct:
                if 9 in dct:
                        ans = "Yes"
if 2 in dct:
        if 5 in dct:
                if 8 in dct:
                        ans = "Yes"

if 3 in dct:
        if 6 in dct:
                if 9 in dct:
                        ans = "Yes"
        if 5 in dct:
                if 7 in dct:
                        ans = "Yes"

if 4 in dct:
        if 5 in dct:
                if 6 in dct:
                        ans = "Yes"

if 7 in dct:
        if 8 in dct:
                if 9 in dct:
                        ans = "Yes"

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    bingo = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    bn = [int(input()) for _ in range(N)]
    hit = [[0] * 3 for _ in range(3)]
    cnt = 0
    hitz = []
    hzb, hb = False, False
    for b in bn:
        for v, i in enumerate(bingo):
            for w, j in enumerate(i):
                if b == j:
                    if j in hit:
                        continue
                    hit[w][v] = 1
                    cnt += 1
    hitz = list(map(list, zip(*hit)))
    for i in hitz:
        if sum(i) == 3:
            hzb = True
            break
    for i in hit:
        if sum(i) == 3:
            hb = True
            break
    if cnt >= 3 and (
        hzb == True
        or hb == True
        or hit[0][0] == hit[1][1] == hit[2][2] == 1
        or hit[0][2] == hit[1][1] == hit[2][0] == 1
    ):
        print("Yes")

    else:
        print("No")


if __name__ == "__main__":
    main()

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

b = []

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


for i in range(len(b)):
  for a_i in range(len(A[0])):
    for a_j in range(len(A[1])):
      if A[a_i][a_j] == b[i]:
        A[a_i][a_j] = 0

ok = 0



for j in range(3):
  if all([i == 0 for i in A[j]]):
    ok += 1

for i in range(3):
  if (A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0):
    ok += 1

for i in range(3):
  if A[i][i] != 0:
    break
  if i == 2:
    ok += 1

if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
  ok += 1

if ok > 0:
  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=[int(input()) for i in range(n)]

aa = []
aa.append(a1)
aa.append(a2)
aa.append(a3)

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

if a[0][0] == a[0][1] and a[0][1] == a[0][2] :
  print("Yes")
elif a[1][0] == a[1][1] and a[1][1] == a[1][2] :
  print("Yes")
elif a[2][0] == a[2][1] and a[2][1] == a[2][2] :
  print("Yes")
elif a[0][0] == a[1][0] and a[1][0] == a[2][0]:
  print("Yes")
elif a[0][1] == a[1][1] and a[1][1] == a[2][1]:
  print("Yes")
elif a[0][2] == a[1][2] and a[1][2] == a[2][2]:
  print("Yes")
elif a[0][0] == a[1][1] and a[1][1] == a[2][2]:
  print("Yes")
elif a[0][2] == a[1][1] and a[1][1] == a[2][0]:
  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()))
result = 'No'

n = int(input())
for i in range(n):
	In = int(input())
    
	a1 = ['' if a1[j] == In else a1[j] for j in range(3)]
	a2 = ['' if a2[j] == In else a2[j] for j in range(3)]
	a3 = ['' if a3[j] == In else a3[j] for j in range(3)]
    

for i in range(3):
	if a1[i] == '' and a2[i] == '' and a3[i] == '':
		result = 'Yes'
		break

if a1.count('') == 3:
		result = 'Yes'
if a2.count('') == 3:
		result = 'Yes'
if a3.count('') == 3:
		result = 'Yes'


if a1[0] == '' and a2[1] == '' and a3[2] == '':
		result = 'Yes'
    
if a1[2] == '' and a2[1] == '' and a3[0] == '':
		result = 'Yes'
print(result)

Solution (Python):
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, x = map(int, input().split())
num_count = int(input())
number_list = [0] * num_count
for i in range(num_count):
    number_list[i] = int(input())

bingo_map = [[a, b, c], [d, e, f], [g, h, x]]
bingo_answer = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def bingo(bingo_map, number_list):
    for number in number_list:
        for i, bingo_row in enumerate(bingo_map):
            if number in bingo_row:
                for j, bingo_number in enumerate(bingo_row):
                    if bingo_number == number:
                        bingo_answer[i][j] = 1


def check_bingo():
    return (all(bingo_answer[0]) or all(bingo_answer[1]) or all(bingo_answer[2]) or
    all([bingo_answer[0][0], bingo_answer[1][0], bingo_answer[2][0]]) or
    all([bingo_answer[0][1], bingo_answer[1][1], bingo_answer[2][1]]) or
    all([bingo_answer[0][2], bingo_answer[1][2], bingo_answer[2][2]]) or
    all([bingo_answer[0][0], bingo_answer[1][1], bingo_answer[2][2]]) or
    all([bingo_answer[2][0], bingo_answer[1][1], bingo_answer[0][2]]))

bingo(bingo_map, number_list)

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

Solution (Python):
import math
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = []
a.append(a1)
a.append(a2)
a.append(a3)

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

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

for bt in b:
  for i, at in enumerate(a1):
    if at == bt:
      bingo[0][i] = 1
  for i, att in enumerate(a2):
    if att == bt:
      bingo[1][i] = 1
  for i, attt in enumerate(a3):
    if attt == bt:
      bingo[2][i] = 1

for l in range(3):
  if sum(bingo[l]) == 3:
    print("Yes")
    quit()
  if bingo[0][l] + bingo[1][l] +bingo[2][l] == 3:
    print("Yes")
    quit()
if bingo[0][0] + bingo[1][1] +bingo[2][2] == 3:
    print("Yes")
    quit()
if bingo[0][2] + bingo[1][1] +bingo[2][0] == 3:
    print("Yes")
    quit()

print("No")

Solution (Python):
a = input().split()
a += input().split()
a += input().split()
n = int(input())
b = set([(input()) for i in range(n)])

bingo = False
if set([a[0], a[1], a[2]]).issubset(b):
	bingo = True
if set([a[3], a[4], a[5]]).issubset(b):
	bingo = True
if set([a[6], a[7], a[8]]).issubset(b):
	bingo = True
if set([a[0], a[3], a[6]]).issubset(b):
	bingo = True
if set([a[1], a[4], a[7]]).issubset(b):
	bingo = True
if set([a[2], a[5], a[8]]).issubset(b):
	bingo = True
if set([a[0], a[4], a[8]]).issubset(b):
	bingo = True
if set([a[2], a[4], a[6]]).issubset(b):
	bingo = True
if bingo:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    A11, A12, A13 = map(int, input().split())
    A21, A22, A23 = map(int, input().split())
    A31, A32, A33 = map(int, input().split())
    N = int(input())
    
    b_list = []
    for i in range(1,N+1) :
        bi = int(input())
        b_list.append(bi)
    if A11 in b_list and A12 in b_list and A13 in b_list :
        print ("Yes")
    elif A21 in b_list and A22 in b_list and A23 in b_list :
        print("Yes")
    elif A31 in b_list and A32 in b_list and A33 in b_list :
        print("Yes")
    elif A11 in b_list and A21 in b_list and A31 in b_list :
        print("Yes")
    elif A12 in b_list and A22 in b_list and A32 in b_list :
        print("Yes")
    elif A13 in b_list and A23 in b_list and A33 in b_list :
        print("Yes")
    elif A11 in b_list and A22 in b_list and A33 in b_list :
        print("Yes")
    elif A13 in b_list and A22 in b_list and A31 in b_list :
        print("Yes")
    else :
        print("No")

if __name__ == '__main__':
    main()

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A=[[] for _ in range(3)]
    for i in range(3):
        A[i]=LI()
    N=I()
    for _ in range(N):
        b=I()
        for i in range(3):
            for j in range(3):
                if A[i][j]==b:
                    A[i][j]=0
                    
    f=0
                
    for i in range(3):
        a=0
        for j in range(3):
            a+=A[i][j]
        if a==0:
            f=1
            
    for j in range(3):
        a=0
        for i in range(3):
            a+=A[i][j]
        if a==0:
            f=1
    a=0        
    for i in range(3):
        a+=A[i][i]
    if a==0:
        f=1
            
    a=A[2][0]+A[1][1]+A[0][2]
    if a==0:
        f=1
        
    if f==1:
        print("Yes")
    else:
        print("No")
            
    
        
        
            
        
                
        
    

main()

Solution (Python):
c = []
A = []
for i in range(3):
  c = input().split()
  c = [int(i) for i in c]
  A.append(c)
N = int(input())
a = 0
b = []
for i in range(N):
  a = int(input())
  b.append(a)




A1 = A[0]
A2 = A[1]
A3 = A[2]
A4 = [A[0][0], A[1][0], A[2][0]]
A5 = [A[0][1], A[1][1], A[2][1]]
A6 = [A[0][2], A[1][2], A[2][2]]
A7 = [A[0][0], A[1][1], A[2][2]]
A8 = [A[0][2], A[1][1], A[2][0]]


A_ = [A1, A2, A3, A4, A5, A6, A7, A8]

count = 0

for i in range(8):
  if set(A_[i]) <= set(b):
    count += 1
    
if count > 0:
  print('Yes')
else:
  print('No')

Solution (Python):
a11, a12 , a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())

A =[a11,a12,a13,a21,a22,a23,a31,a32,a33]
n = int(input())
B =[]
for i in range(n):
    s = int(input())
    B.append(s)

bingo = [[0, 0, 0] for i in range(3)]

for i in B:
    for s, k in enumerate(A):
        if i == k:
            bingo[int(s/3)][s % 3] = 1

if (bingo[0][0] == 1 and bingo[0][1] == 1 and bingo[0][2] ==1 ) or \
(bingo[1][0] == 1 and bingo[1][1] == 1 and bingo[1][2] ==1) or \
    (bingo[2][0] == 1 and bingo[2][1] == 1 and bingo[2][2] ==1) or \
        (bingo[0][0] == 1 and bingo[1][0] == 1 and bingo[2][0] ==1) or \
            (bingo[0][1] == 1 and bingo[1][1] == 1 and bingo[2][1] ==1) or \
                (bingo[0][2] == 1 and bingo[1][2] == 1 and bingo[2][2] ==1) or \
                    (bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] ==1) or \
                        (bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] ==1):
    print("Yes")
else:
    print("No")

Solution (Python):

a = []
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    a.append(a1)
    a.append(a2)
    a.append(a3)
    
n = int(input())
b = []
for i in range(n):
    bb = int(input())
    b.append(bb)
    
for i in range(n):
    while a.count(b[i]) > 0:
        a[a.index(b[i])] = 0
        
if a[0] == a[3] == a[6] == 0:
    print('Yes')
elif a[1] == a[4] == a[7] == 0:
    print('Yes')
elif a[2] == a[5] == a[8] == 0:
    print('Yes')
elif a[0] == a[1] == a[2] == 0:
    print('Yes')
elif a[3] == a[4] == a[5] == 0:
    print('Yes')
elif a[6] == a[7] == a[8] == 0:
    print('Yes')
elif a[0] == a[4] == a[8] == 0:
    print('Yes')
elif a[2] == a[4] == a[6] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):



bingo_list = [[],[], []]
bingo_list[0] = list(map(int, input().split()))
bingo_list[1] = list(map(int, input().split()))
bingo_list[2] = list(map(int, input().split()))
n = int(input())
b_list = [int(input()) for i in range(n)]

selected_num_list = []


for b in b_list:
    for i in range(3):
        for j in range(3):
            if b == bingo_list[i][j]:
                selected_num_list.append((i, j))


bingo_flag = False
for i in range(3):
    line_flag = False
    for j in range(3):
        if (i, j) in selected_num_list:
            line_flag = True
        else:
            line_flag = False
            break
    if line_flag == True:
        bingo_flag = True
        break


for i in range(3):
    row_flag = False
    for j in range(3):
        if (j, i) in selected_num_list:
            row_flag = True
        else:
            row_flag = False
            break
    if row_flag == True:
        bingo_flag = True
        break


cross_flag = False
for i in range(3):
    for j in range(3):
        if i == j:
            if (i, j) in selected_num_list:
                cross_flag = True
            else:
                cross_flag = False
    if cross_flag == False:
        break


if cross_flag == True:
    bingo_flag = True


cross_flag = False
if (0, 2) in selected_num_list:
    if (1, 1) in selected_num_list:
        if (2, 0) in selected_num_list:
            bingo_flag = True



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

Solution (Python):
a = [input().split() for l in range(3)]
N=int(input())
b = [input() for i in range(N)]
if((b.count(a[0][0])==1 and b.count(a[0][1])==1 and b.count(a[0][2])==1) or 
   (b.count(a[1][0])==1 and b.count(a[1][1])==1 and b.count(a[1][2])==1) or
   (b.count(a[2][0])==1 and b.count(a[2][1])==1 and b.count(a[2][2])==1) or
   (b.count(a[0][0])==1 and b.count(a[1][0])==1 and b.count(a[2][0])==1) or
   (b.count(a[0][1])==1 and b.count(a[1][1])==1 and b.count(a[2][1])==1) or
   (b.count(a[0][2])==1 and b.count(a[1][2])==1 and b.count(a[2][2])==1) or
   (b.count(a[0][0])==1 and b.count(a[1][1])==1 and b.count(a[2][2])==1) or
   (b.count(a[2][0])==1 and b.count(a[1][1])==1 and b.count(a[0][2])==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 = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))
loopflag = False
result.sort()

if N >= 3:
    for i in range(len(result)):
        for j in range(len(result)):
            for k in range(len(result)):
                if (i!=j and j!=k and k!=i):
                    if((result[i] % 3 == result[j] % 3 == result[k] % 3 ) or (result[i] // 3 == result[j] // 3 == result[k] // 3) or (result[i] == 0 and result[j] == 4 and result[k] ==8 ) or (result[i] == 2 and result[j]  == 4 and result[k] == 6 )):
                        loopflag = True
    if loopflag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]
a3 = [int(x) for x in input().split()]
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
res = []
for x in b:
    for i in range(3):
        if x == a1[i]:
            res += "1"
        if x == a2[i]:
            res += "2"
        if x == a3[i]:
            res += "3"
    if x == a1[0] or x == a2[0] or x == a3[0]:
        res += "4"
    if x == a1[1] or x == a2[1] or x == a3[1]:
        res += "5"
    if x == a1[2] or x == a2[2] or x == a3[2]:
        res += "6"
    if x == a1[0] or x == a2[1] or x == a3[2]:
        res += "7"
    if x == a1[2] or x == a2[1] or x == a3[0]:
        res += "8"
if res.count("1")>=3 or res.count("2")>=3 or res.count("3")>=3 or res.count("4")>=3 or res.count("5")>=3 or res.count("6")>=3 or res.count("7")>=3 or res.count("8")>=3:
    print("Yes")
else:
    print("No")

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


n = int(input())
li = []
for i in range(n):
    li.append(int(input()))
    
for i in range(3):
    if (L[i][0] in li) and (L[i][1] in li) and (L[i][2] in li ):
        print("Yes")
        exit()
if (L[0][0] in li) and (L[1][1] in li) and (L[2][2] in li ):
    print("Yes")
    exit()
if (L[0][2] in li) and (L[1][1] in li) and (L[2][0] in li ):
    print("Yes")
    exit()
for i in range(3):
    if (L[0][i] in li) and (L[1][i] in li) and (L[2][i] in li ):
        print("Yes")
        exit()

print("No")

Solution (Python):
row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
num=int(input())
list=[int(input()) for i in range(num)]

for n in list:
  row1 = [0 if i == n else i for i in row1]
  row2 = [0 if i == n else i for i in row2]
  row3 = [0 if i == n else i for i in row3]


if row1.count(0) == 3 or row2.count(0) == 3 or row3.count(0) == 3:
  print('Yes')


elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[1]==0 and row2[1]==0 and row3[1]==0:
  print('Yes')
elif row1[2]==0 and row2[2]==0 and row3[2]==0:
  print('Yes')


elif row2[1] == 0:
  if row1[0] == 0 and row3[2] == 0:
    print('Yes')
  elif row1[2] == 0 and row3[0] == 0:
    print('Yes')
  else:
    print('No')
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 range(len(b)):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[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'
    break
  if a[0][i]+a[1][i]+a[2][i] == 0:
    ans = 'Yes'
    break

if a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
    ans = 'Yes'

print(ans)

Solution (Python):
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
A = [a,b,c]
N = int(input())
b = []
temp = []
for _ in range(N):
    inp = int(input())
    for y, row in enumerate(A):
        try:
            temp.append([y, row.index(inp)])
            break
        except ValueError:
            pass
if ([0,0] in temp and [1,0] in temp and [2,0] in temp) or([0,1] in temp and [1,1] in temp and [2,1] in temp)or([0,2] in temp and [1,2] in temp and [2,2] in temp)or([0,0] in temp and [0,1] in temp and [0,2] in temp)or([1,0] in temp and [1,1] in temp and [1,2] in temp)or([2,0] in temp and [2,1] in temp and [2,2] in temp)or([0,0] in temp and [1,1] in temp and [2,2] in temp)or([0,2] in temp and [1,1] in temp and [2,0] in temp):
	print("Yes")
else:
    print("No")

Solution (Python):
A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
if A11 in b and A12 in b and A13 in b:
    print('Yes')
elif A21 in b and A22 in b and A23 in b:
    print('Yes')
elif A31 in b and A32 in b and A33 in b:
    print('Yes')
elif A11 in b and A21 in b and A31 in b:
    print('Yes')
elif A12 in b and A22 in b and A32 in b:
    print('Yes')
elif A13 in b and A23 in b and A33 in b:
    print('Yes')
elif A11 in b and A22 in b and A33 in b:
    print('Yes')
elif A13 in b and A22 in b and A31 in b:
    print('Yes')
else:
    print('No')

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for l in range(n)]
a = a[0] + a[1] + a[2]
A = [False]*9
for h in range(len(a)):
  A[h] = a[h] in b
flag = 'No'
for k in range(3):
  if A[k*3] ==  A[k*3+1] ==  A[k*3+2] == True:
    flag = 'Yes'
  if A[k] == A[k+3] ==  A[k+6] == True:
    flag = 'Yes'
  if A[0] ==  A[4] == A[8] == True:
    flag = 'Yes'
  if A[2] ==  A[4] ==  A[6] == True:
    flag = 'Yes'
print(flag)

Solution (Python):
data=[]
for i in range(3):
    a=list(map(int,input().split()))
    data.append(a)
n=int(input())
cnt=[0]*8
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if b==data[j][k]:
                cnt[j]+=1
                cnt[k+3]+=1
                if j==k:
                    cnt[6]+=1
                if j+k==2:
                    cnt[7]+=1
ans="No"
for i in range(8):
    if cnt[i]==3:
        ans="Yes"
        break
print(ans)

Solution (Python):
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = np.array([A1, A2, A3])

N = int(input())
for i in range(N):
    B = int(input())
    A[A==B] = 0
    
result = 'No'
for i in range(3):
    if A[i].sum()==0:
        result = 'Yes'
        break
    elif A[:, i].sum()==0:
        result = 'Yes'
    else:
        pass
if np.diag(A).sum()==0:
    result = 'Yes'
elif (A[0, 2]+A[1, 1]+A[2, 0])==0:
    result = 'Yes'

print(result)

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = []
for i in range(N):
	b.append(int(input()))
	
yoko = A
tate = [[], [], []]
for row in A:
	for i in range(3):
		tate[i].append(row[i])
naname = [[A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]]

all = yoko + tate + naname

y = 0
chk = 0
for kumi in all:
	for k in kumi:
		if k in b:
			chk += 1
		else:
			continue
	if chk == 3:
		print("Yes")
		y = 1
		break
	else:
		chk = 0
		
if y == 0:
	print("No")

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        A[j][k] = "x"
      else:
        pass
if A[0] == ["x","x","x"]:
  print("Yes")
elif A[1] == ["x","x","x"]:
  print("Yes")
elif A[2] == ["x","x","x"]:
  print("Yes")
elif A[0][0] == "x" and A[1][0] == "x" and A[2][0] == "x":
  print("Yes")
elif A[0][1] == "x" and A[1][1] == "x" and A[2][1] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][2] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][0] == "x" and A[1][1] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][1] == "x" and A[2][0] == "x":
  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):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']
Yn=['Yes','No']
 
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase


input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a


class UnionFind:
    def __init__(self, n):
        
        
        self.table = [-1] * n
        self.cnt = [1] * n
 
    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            
            self.table[x] = self._root(self.table[x])
            return self.table[x]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.cnt[r1]+=self.cnt[r2]
            if d1 == d2:
                self.table[r1] -= 1
                
        else:
            self.table[r1] = r2
            self.cnt[r2]+=self.cnt[r1]
    
    def __str__(self):
        rt=[i if j<0 else j for i,j in enumerate(self.table)]
        return str(rt)

show_flg=False
show_flg=True

mr={}
mc={}
A=[[0]*3 for i in range(3)]
for i in range(3):
    a=LI()
    for j in range(3):
        mr[a[j]]=i
        mc[a[j]]=j

n=I()
for i in range(n):
    b=I()
    if b in mr:
        A[mr[b]][mc[b]]=1

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


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

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

print('No')