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.



Sample input:
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30


Sample output:
Yes

Submission status: Runtime Error

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

b = set(int(input() for _ in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

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

Submission status: Runtime Error

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

b = set(int(input() for i in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

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

Submission status: Runtime Error

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(int(input())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return
    for i in range(3):
        if all(a[i][j] == 0 for j in range(3)) or all(a[j][i] == 0 for j in range(3)):
            print("Yes")
            return
    print("No")
B()

Submission status: Runtime Error

Solution code:
def B():
    mat = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    #b = [list(map(int,input().split())) for i in range(n)]
    for bingo in  (int(input()) for _ in range(N)):
        for i in range(3):
            for j in range(3):
                if mat[i][j] == bingo:
                    mat[i][j] = 0
    for i in range(3):
        if all(mat[i][j] == 0 for j in range(3)):
            print('Yes')
            break
        if all(mat[j][i] == 0 for j in range(3)):
            print('Yes')
            break
    else:
        if mat[0][0] == mat[1][1] == mat[2][2] == 0 or\
                mat[0][2] == mat[1][1] == mat[2][0] == 0:
            print('Yes')
        else:
            print('No')
B()

Submission status: Runtime Error

Solution code:
def B():
    mat = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if mat[i][j] == bingo:
                    mat[i][j] = 0
for i in range(3):
    if all(mat[i][j] == 0 for j in range(3)):
        print('Yes')
        break
    if all(mat[j][i] == 0 for j in range(3)):
        print('Yes')
        break
else:
    if mat[0][0] == mat[1][1] == mat[2][2] == 0 or\
            mat[0][2] == mat[1][1] == mat[2][0] == 0:
        print('Yes')
    else:
        print('No')
B()

Submission status: Runtime Error

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    for i in range(3):
        if all(a[i][j] == 0 for in range(3)):
            print("Yes")
            return
        if all(a[j][i] == 0 for in range(3)):
            print("Yes")
            return
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return

    print("No")
B()

Submission status: Runtime Error

Solution code:
L = ()
L.append(set(map(int, input().split())))
L.append(set(map(int, input().split())))
L.append(set(map(int, input().split())))
L.append((L[0][0], L[1][0], L[2][0]))
L.append((L[0][1], L[1][1], L[2][1]))
L.append((L[0][2], L[1][2], L[2][2]))
L.append((L[0][0], L[1][1], L[2][2]))
L.append((L[0][2], L[1][1], L[2][0]))
N = int(input())
B = (int(input()) for i in range(N))
if any(B >= l for l in L):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

i = 0
while i<N:
  b = int(input())
  j=0
  while j<3:
    k=0
    while k<3:
      if A[j][k]==b:
        A[j][k]=0
      k+=1
    j+=1
  i+=1

flag = False
i = 0
while i<3:
  if A[i][0]+A[i][1]+A[i][2] == 0:
    flag = True
    break
  if A[0][i]+A[1][i]+A[2][i] == 0:
    flag = True
    break
  i += 1

if A[0][0]+A[1][1]+A[2][2] == 0:
  flag = Trueå
if A[2][0]+A[1][1]+A[0][2] == 0:
  flag = True

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

Submission status: Runtime Error

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

for i in range(3):
    for j in range(3):
      for k in b:
        if k == a[i][j]:
          a[i][j] = 101
          break
      
if a[1] == [101,101,101] or a[2] == [101,101,101] or a[3] == [101,101,101]:
  print('Yes')
  exit()
elif (a[1][1]==101 and a[2][1] ==101 and a[3][1] == 101) or (a[1][2]==101 and a[2][2] ==101 and a[3][2] == 101) and (a[1][3]==101 and a[2][3] ==101 and a[3][3] == 101):
  print('Yes')
  exit()
elif (a[1][1]==101 and a[2][2] ==101 and a[3][3] == 101) or (a[1][3]==101 and a[2][2] ==101 and a[3][1] == 101):
  print('Yes')
  exit()
else:
  print('No')

Submission status: Runtime Error

Solution code:
A = []
for _ in range(3):
  A　+= list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if 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 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
for _ in range(3):
  A += list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if 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 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
for _ in range(3):
  A　+= list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if 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 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
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
aa = [0] * 9
n = int(input())
for i in range(n):
    b = int(input())
    a_dash = map(lambda x: x-b, a)
    try:
        index = a_dash.index(0)
        aa[index] = 1
    except ValueError:
        pass
print(aa)
if aa[0] == aa[1] == aa[2] == 1:
    print('Yes')
elif aa[3] == aa[4] == aa[5] == 1:
    print('Yes')
elif aa[6] == aa[7] == aa[8] == 1:
    print('Yes')
elif aa[0] == aa[3] == aa[6] == 1:
    print('Yes')
elif aa[1] == aa[4] == aa[7] == 1:
    print('Yes')
elif aa[2] == aa[5] == aa[8] == 1:
    print('Yes')
elif aa[0] == aa[4] == aa[8] == 1:
    print('Yes')
elif aa[2] == aa[4] == aa[6] == 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

for i in range(N):
    b[i]=int(input())
    
for i in range(N):
    if a11==b[i]:
        a11=0
    if a12==b[i]:
        a12=0
    if a13==b[i]:
        a13=0
    if a21==b[i]:
        a21=0
    if a22==b[i]:
        a22=0
    if a23==b[i]:
        a23=0
    if a31==b[i]:
        a31=0
    if a32==b[i]:
        a32=0
    if a33==b[i]:
        a33=0 
        
if a11+a12+a13==0 or a21+a22+a23==0 or a31+a32+a33==0 or a11+a21+a31==0 or a12+a22+a32==0 or a13+a23+a33==0 or a11+a22+a33==0 or a31+a22+a33==0:
    print('Yes')
    else:
        print('No')

Submission status: Runtime Error

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

for i in range(N-1):
    b[i]=int(input())
    
for i in range(N-1):
    if a11==b[i]:
        a11=0
    if a12==b[i]:
        a12=0
    if a13==b[i]:
        a13=0
    if a21==b[i]:
        a21=0
    if a22==b[i]:
        a22=0
    if a23==b[i]:
        a23=0
    if a31==b[i]:
        a31=0
    if a32==b[i]:
        a32=0
    if a33==b[i]:
        a33=0 
        
if a11+a12+a13==0 or a21+a22+a23==0 or a31+a32+a33==0 or a11+a21+a31==0 or a12+a22+a32==0 or a13+a23+a33==0 or a11+a22+a33==0 or a31+a22+a33==0:
    print('Yes')
    else:
        print('No')

Submission status: Runtime Error

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

for i in range(N-1):
    b[i]=int(input())

    
for i in range(N-1):
    if a11==b[i]:
        a11=0
    if a12==b[i]:
        a12=0
    if a13==b[i]:
        a13=0
    if a21==b[i]:
        a21=0
    if a22==b[i]:
        a22=0
    if a23==b[i]:
        a23=0
    if a31==b[i]:
        a31=0
    if a32==b[i]:
        a32=0
    if a33==b[i]:
        a33=0 
        
if a11+a12+a13==0 or a21+a22+a23==0 or a31+a32+a33==0 or a11+a21+a31==0 or a12+a22+a32==0 or a13+a23+a33==0 or a11+a22+a33==0 or a31+a22+a33==0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
an = np.array(a)
n = int(input())
c = [[0]*3 for i in range(3)]
for i in range(n):
    b = int(input())
    if b in a:
        pos = tuple(nd[0] for nd in np.where(an == b))
        c[pos[0]][pos[1]] = 1
for i in range(3):
    if (c[i][0] == 1 and c[i][1] == 1 and c[i][2] == 1) or (c[0][i] == 1 and c[1][i] == 1 and c[2][i] == 1):
        print('Yes')
        break
else:
    if (c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1) or (c[0][2] == 1 and c[1][1] == 1 and c[2][0] == 1):
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
a1,a2,a3 = map(int,input().split())
b1,b2,b3 = map(int,input().split())
c1,c2,c3 = map(int,input().split())
N = int(input())
b =  [int(input()) for _ in range(N)]

if a1 and a2 and a3 in b or
    b1 and b2 and b3 in b or
    c1 and c2 and c3 in b or
    a1 and b1 and c1 in b or
    a2 and b2 and c2 in b or
    a3 and b3 and c3 in b or
    a1 and b2 and c3 in b or
    a3 and b2 and c1 in b:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:

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(3):
    for j in range(3):
        for x in range(N):
            if A[i][j]==b[x]:
                A[i][j]=0

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

Submission status: Runtime Error

Solution code:
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
a = [[0] * 3] * 3
x = [[0] * 3] * 3
for i in range(3):
    for j in range(3):
        a[i][j] = iin()
n = iin()
b = [0] * n
for i in range(n):
    b[i] = iin()

for i in range(3):
    for j in range(3):
        for f in range(3):
            if a[i][j] == b[f]:
                x[i][j] = 1
for i in range(3):
    if sum(x[i]) == 3:
        neko = neko + 1
    nya = x[0][i] + x[1][i] + x[2][i]
    if nya == 3:
        neko = neko + 1
nya = x[0][0]+ x[1][1] + x[2][2]
if nya == 3:
    neko = neko + 1
nya = x[0][2]+ x[1][1] + x[2][0]
if nya == 3:
    neko = neko + 1
if neko > 0:
    py()
else:
    pn()

Submission status: Runtime Error

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

flag = False
for i in range(3):
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        flag = True
        break
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        flag = True
        break
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    flag = True
    
print("Yes" if flag else "No")

Submission status: Runtime Error

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

n = int(input())
for i in range(n):
    b = int(input())
    for j in a:
        if b in j:
            a[a.index(j)][j.index(b)] = 0

ans = 0
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == 0:
        ans = 1
    elif a[i][0] == a[i][1] == a[i][2] == 0:
        ans = 1
if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = 1
if a[0][3] == a[1][1] == a[2][0] == 0:
    ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a=[]
b=[]
for _ in range(3):
    a.append(list(map(int,input().split())))
for _ in range(int(input())):
    b.append(int(input()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==a[k][j]:
                a[k][j]=0
if (a[0][0]==0 and a[0][1]==0 and a[0][2]==0)or(a[1][0]==0 and a[1][1]==0 and a[1][2]==0) or (a[2][0]==0 and a[2][1]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][0]==0 and a[2][0]==0) or (a[0][1]==0 and a[1][1]==0 and a[2][1]==0) or (a[0][2]==0 and a[1][2]==0 and a[2][2]==0) or (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):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
 
for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
      	called_row = exist_list.index(True)
       	A[called_row] = [0 if x==called_num else x for x in A[called_row]]
    
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった
 
if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
 
for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
      	called_row = exist_list.index(True)
    
    A[called_row] = [0 if x==called_num else x for x in A[called_row]]
    
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった
 
if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np
A = np.array([])
for i in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

for n in range(N):
    called_num = int(input())
    called_row = [called_num in A[i] for i in range(3)].index(True)
    
    A[called_row] = [0 if x==called_num else x for x in A[called_row]]
    
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった

if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
s = list(map(int, [input() for i in range(n)]))
l = [
  [0, 0, 0]
  , [0, 0, 0]
  , [0, 0, 0]
]
n = []
for i in range(0, 3):
  for j in range(0, n):
    if a1[i] == s[j]:
      l[0][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a2[i] == s[j]:
      l[1][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a3[i] == s[j]:
      l[2][i] = i+1
for i in l:
  for j in i:
    if j != 0:
      n.append(j)
count = 0
for i in range(0, 3):
  if l[i][0] and l[i][1] and l[i][2]:
    count += 1
if (l[0][0] and l[1][1] and l[2][2]) or (l[2][0] and l[1][1] and l[0][2]):
  count += 1
else:
  for i in range(1, 4):
    if n.count(i) == 3:
      count += 1
print('Yes' if count >= 1 else 'No')

Submission status: Runtime Error

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
s = list(map(int, [input() for i in range(n)]))
l = [
  [0, 0, 0]
  , [0, 0, 0]
  , [0, 0, 0]
]
for i in range(0, 3):
  for j in range(0, n):
    if a1[i] == s[j]:
      l[0][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a2[i] == s[j]:
      l[1][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a3[i] == s[j]:
      l[2][i] = i+1
count = 0
for i in range(0, 3):
  if l[i][0] and l[i][1] and l[i][2]:
    count += 1
if (l[0][0] and l[1][1] and l[2][2]) or (l[2][0] and l[1][1] and l[0][2]):
  count += 1
else:
  for i in range(1, 4):
    if n.count(i) == 3:
      count += 1
print('Yes' if count >= 1 else 'No')

Submission status: Runtime Error

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
s = list(map(int, [input() for i in range(n)]))
l = [
  [0, 0, 0]
  , [0, 0, 0]
  , [0, 0, 0]
]
for i in range(0, 3):
  for j in range(0, n):
    if a1[i] == s[j]:
      l[0][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a2[i] == s[j]:
      l[1][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a3[i] == s[j]:
      l[2][i] = i+1
for i in l:
  for j in i:
    if j != 0:
      n.append(j)
count = 0
for i in range(0, 3):
  if l[i][0] and l[i][1] and l[i][2]:
    count += 1
if (l[0][0] and l[1][1] and l[2][2]) or (l[2][0] and l[1][1] and l[0][2]):
  count += 1
else:
  for i in range(1, 4):
    if n.count(i) == 3:
      count += 1
print('Yes' if count >= 1 else 'No')

Submission status: Runtime Error

Solution code:
import sys
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
s = list(map(int, [input() for i in range(n)]))
l = [
  [0, 0, 0]
  , [0, 0, 0]
  , [0, 0, 0]
]
for i in range(0, 3):
  for j in range(0, n):
    if a1[i] == s[j]:
      l[0][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a2[i] == s[j]:
      l[1][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a3[i] == s[j]:
      l[2][i] = i+1
for i in l:
  for j in i:
    if j != 0:
      n.append(j)
for i in range(0, 3):
  if l[i][0] and l[i][1] and l[i][2]:
    print('Yes')
    sys.exit()
if (l[0][0] and l[1][1] and l[2][2]) or (l[2][0] and l[1][1] and l[0][2]):
  print('Yes')
  sys.exit()
else:
  for i in range(1, 4):
    if n.count(i) == 3:
      print('Yes')
      sys.exit()
print('No')

Submission status: Runtime Error

Solution code:
import sys
A=[list(map(int,input().split())) for i in range()]
N=int(input())
b=[list(map(int,input().split())) for i in range(N)]
flat=[j for i in A for j in i]
for i,value in enumerate(flat):
    if [value] in b:
         flat[i]=-1
for i in range(3):
    if flat[i]==flat[i+1]==flat[i+2]==-1:
        print('Yes')
        sys.exit()
    if flat[i]==flat[i+3]==flat[i+6]==-1:
        print('Yes')
        sys.exit()
if flat[0]==flat[4]==flat[8]==-1 or flat[2]==flat[4]==flat[6]==-1:
    print('Yes')
    sys.exit()
print('No')

Submission status: Runtime Error

Solution code:
f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[3] == 'X':
    ans += 1
elif f[2] == 'X' and s[1] == 'X' and t[0] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
elif ans == 0:
    print('No')

Submission status: Runtime Error

Solution code:

f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[3] == 'X':
    ans += 1
elif f[3] == 'X' and s[2] == 'X' and t[1] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
elif ans == 0:
    print('No')

Submission status: Runtime Error

Solution code:
f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[3] == 'X':
    ans += 1
elif f[3] == 'X' and s[2] == 'X' and t[1] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[3] == 'X':
    ans += 1
elif f[3] == 'X' and s[2] == 'X' and t[1] == 'X':
    ans += 1
    
if ans < 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
la=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=list(map(int,input().split()))
 
for list in la:
  for _ in range(3):
     if list[_] in b:
        list[_]=101
for list in la:
  if all(aa==101 for aa in list):
     print('Yes')
     exit()
tate=[[]]*3
for list in la:
   for _ in range(3):
       tate[_].append(list[_])
for t in tate:
   if all(tt==101 for tt in t):
       print('Yes')
       exit()
 
elif all(xx==101 for xx in [la[0][0],la[1][1],la[2][2]]):
  print('Yes')
  exit()
 
elif all(yy==101 for yy in [la[0][2],la[2][2],la[2][0]]):
  print('Yes')
  exit()
print('No')

Submission status: Runtime Error

Solution code:
la=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=list(map(int,input().split())
 
for list in la:
  for _ in range(3):
     if list[_] in b:
       list[_]=101

for list in l:
  if all(aa==101 for aa in list):
     print('Yes')
     exit()

tate=[[]]*3
for list in lists:
   for _ in range(3):
       tate[_].append(list[_])
for t in tate:
   if all(tt==101 for tt in t):
       print('Yes')
       exit()
if all(xx==101 for xx in [la[0][0],la[1][1],la[2][2]]):
  print('Yes')
if all(yy==101 for yy in [la[0][2],la[2][2],la[2][0]]):
  print('Yes')
  exit()
print('No')

Submission status: Runtime Error

Solution code:
a = list(list(map(int , input().split())) for l in range(3))
n = int(input())

for i in range(input()):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b: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[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Submission status: Runtime Error

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

for b in B:
    for x in range(3):
        for y in range(3) :
            if a[x][y] == b:
                a[x][y] = 0

if A[0][0] * A[1][0] * A[2][0] == 0 or A[0][1] * A[1][1] * A[2][1] == 0 or A[0][2] * A[1][2] * A[2][2] == 0 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][1] * A[2][2] == 0 or A[0][2] * A[1][1] * A[2][0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 157b
a = []
b = []
check_list = [False] * 9
for _ in range(3);
  a.extend(list(map(int, input().split())))
n = int(input())
for _ in range(n);
  b.append(int(input()))

for _b in b:
  if _b in a:
    check_list[a.index(_b)] = True

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

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,inout().split())
N=int(input())
L=[int(input()) for i in range(N)]
if a in L and b in L and c in L:
  print('Yes')
elif d in L and e in L and  f in L:
  print('Yes')
elif g in L and h in L and  i in L:
  print('Yes')
elif a in L and d in L and  g in L:
  print('Yes')
elif b in L and e in L and  h in L:
  print('Yes')
elif c in L and f in L and  i in L:
  print('Yes')
elif a in L and e in L and  i in L:
  print('Yes')
elif c in L and e in L and  g in L:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input9())
r = []
for _ in range(3):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 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)

Submission status: Runtime Error

Solution code:
a0,a1,a2=map(int,input().split())
a3,a4,a5=map(int,input().split())
a6,a7,a8=map(int,input().split())
N=int(input())
b=[int(input()) for _ in range(N)]
A=[a0,a1,a2,a3,a4,a5,a6,a7,a8]

for i in range(N):
  for p in range(9):
    if b[i]=A[p]:
      A[p]=0
  
if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 or A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
a0,a1,a2=map(int,input().split())
a3,a4,a5=map(int,input().split())
a6,a7,a8=map(int,input().split())
N=int(input())
b=[int(input()) for _ in range(N)]
A=[a0,a1,a2,a3,a4,a5,a6,a7,a8]

for i in range(N):
  for p in range(9):
    if b[i]=A[p]:
      A[p]=0
  
if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 0r A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
a0,a1,a2=map(int,input().split())
a3,a4,a5=map(int,input().split())
a6,a7,a8=map(int,input().split())
N=int(input())
b=[int(input()) for _ in range(N)]
A=[a0,a1,a2,a3,a4,a5,a6,a7,a8]

for i in range(N):
  for p in range(9):
    if b[i]=A[p]:
      A=0
  
if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 0r A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
bs = [int(input()) for _ in range(N)]

A = np.array([A1, A2, A3])
mask = np.zeros_like(A)
for b in bs:
    mask += (A==b).astype(int)

mask = mask>0
if np.any(np.all(mask, axis=0)):
    print('Yes')
elif np.any(np.all(mask, axis=1)):
    print('Yes')
elif np.all(np.diag(mask)):
    print('Yes')
# elif np.all(np.diag(mask.T)):
elif np.logical_and(mask[0][2], mask[1][1], mask[2][0]):
    print('Yes')
else:
    print('No')