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:
import math

def main():
  A1 = list()
  A2 = list()
  A3 = list()
  
  A1 = list(map(int, input().split()))
  A2 = list(map(int, input().split()))
  A3 = list(map(int, input().split()))
  A = A1 + A2 + A3
  
  N = int(input())
  
  B = list()
  
  for i in range(0, N):
    B = int(input())
    
  for a in range(0, len(A)):
    for b in range(0, N):
      if A[a] == B[b]:
        A[a] += 100
        
  if A[0] + A[1] + A[2] > 300:
    print('Yes')
  elif A[3] + A[4] + A[5] > 300:
    print('Yes')
  elif A[6] + A[7] + A[8] > 300:
    print('Yes')
  elif A[0] + A[3] + A[6] > 300:
    print('Yes')
  elif A[1] + A[4] + A[7] > 300:
    print('Yes')
  elif A[2] + A[5] + A[8] > 300:
    print('Yes')
  elif A[0] + A[4] + A[8] > 300:
    print('Yes')
  elif A[2] + A[4] + A[6] > 300:
    print('Yes')
  else:
    print('No')
main()

Submission status: Runtime Error

Solution code:
import math

def main():
  A1 = list()
  A2 = list()
  A3 = list()
  
  A1 = list(map(int, input().split()))
  A2 = list(map(int, input().split()))
  A3 = list(map(int, input().split()))
  A = A1 + A2 + A3
  
  N = int(input())
  
  B = list()
  
  for i in range(0, N):
    B = int(input())
    
  for a in range(0, len(A)):
    for b in range(0, len(B)):
      if A[a] == B[b]:
        A[a] += 100
        
  if A[0] + A[1] + A[2] > 300:
    print('Yes')
  elif A[3] + A[4] + A[5] > 300:
    print('Yes')
  elif A[6] + A[7] + A[8] > 300:
    print('Yes')
  elif A[0] + A[3] + A[6] > 300:
    print('Yes')
  elif A[1] + A[4] + A[7] > 300:
    print('Yes')
  elif A[2] + A[5] + A[8] > 300:
    print('Yes')
  elif A[0] + A[4] + A[8] > 300:
    print('Yes')
  elif A[2] + A[4] + A[6] > 300:
    print('Yes')
  else:
    print('No')
main()

Submission status: Runtime Error

Solution code:
import math

def main():
  A1 = list()
  A2 = list()
  A3 = list()
  
  A1 = list(map(int, input().split()))
  A2 = list(map(int, input().split()))
  A3 = list(map(int, input().split()))
  A = A1 + A2 + A3
  
  N = int(input())
  
  B = list()
  
  for i in range(0, N):
    B = int(input())
    
  for a in range(0, len(A)):
    for b in range(0, len(B)):
      if A[a] == B[b]:
        A[a] += 100
        
  if A[0] == A[1] and A[1] == A[2]:
    print('Yes')
  elif A[3] == A[4] and A[4] == A[5]:
    print('Yes')
  elif A[6] == A[7] and A[7] == A[8]:
    print('Yes')
  elif A[0] == A[3] and A[3] == A[6]:
    print('Yes')
  elif A[1] == A[4] and A[4] == A[7]:
    print('Yes')
  elif A[2] == A[5] and A[5] == A[8]:
    print('Yes')
  elif A[0] == A[4] and A[4] == A[8]:
    print('Yes')
  elif A[2] == A[4] and A[4] == A[6]:
    print('Yes')
  else:
    print('No')
main()

Submission status: Runtime Error

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

n = int(input())

for j in range(n):
    b = int(input())
    for l in range(3):
        if A[l][0] == b:
            A[l][0] = 0
        if A[l][1] == b:
            A[l][1] = 0
        if A[l][2] == b:
            A[l][2] = 0

if A[0][0]==A[1][1]==A[2][2]==0:
    print("Yes")
elif A[0][2]==A[1][1]==A[2][0]==0:
    print("Yes")     
elif for k in range(3):
    if A[k][0]==A[k][1]==A[k][2]==0:
        print("Yes")
    elif A[0][k]==A[1][k]==A[2][k]==0:
        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())

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

if A[0][0]==A[1][1]==A[2][2]==0:
    print("Yes")
elif A[0][2]==A[1][1]==A[2][0]==0:
    print("Yes")     
elif for k in range(3):
    if A[k][0]==A[k][1]==A[k][2]==0:
        print("Yes")
    elif A[0][k]==A[1][k]==A[2][k]==0:
        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())

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

if A[0][0]==A[1][1]==A[2][2]==0:
    print("Yes")
    exit
elif A[0][2]==A[1][1]==A[2][0]==0:
    print("Yes")
    exit
            
elif for k in range(3):
    if A[k][0]==A[k][1]==A[k][2]==0:
        print("Yes")
        exit
    elif A[0][k]==A[1][k]==A[2][k]==0:
        print("Yes")
        exit

else:
    print("No")

Submission status: Runtime Error

Solution code:

n = int(input())

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

for k in range(3):
    if A[k][0]==A[k][1]==A[k][2]==0:
        print("Yes")
    elif A[0][k]==A[1][k]==A[2][k]==0:
        print("Yes")
        exit
if A[0][0]==A[1][1]==A[2][2]==0:
    print("Yes")
elif A[0][2]==A[1][1]==A[2][0]==0:
    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())

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

for k in range(3):
    if A[k][0]==a[k][1]==a[k][2]==0:
        print("Yes")
    elif A[0][k]==A[1][k]==A[2][k]==0:
        print("Yes")
        exit
if A[0][0]==A[1][1]==A[2][2]==0:
    print("Yes")
elif A[0][2]==A[1][1]==A[2][0]==0:
    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())

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

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

Submission status: Runtime Error

Solution code:
A11, A12, A13 = input().split(' ')
A21, A22, A23 = input().split(' ')
A31, A32, A33 = input().split(' ')
A11 = int(A11)
A12 = int(A12)
A13 = int(A13)
A21 = int(A21)
A22 = int(A22)
A23 = int(A23)
A31 = int(A31)
A32 = int(A32)
A33 = int(A33)
N = int(input())
b = []
for i in range(N):
  bi = int(input())
  b.append(bi)
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 band 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')

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

for i in range(N):
    b = int(input())
    for t in range(3):
        if A1[t] == b:
            A1[t] = -1
        elif A2[t] == b:
            A2[t] = -1
        elif A3[t] == b:
            A3[t] = -1

if A1 == A2 == A3 == [-1, -1, -1] or A1[1] == A2[1] == A3[1] == -1 or A1[2] == A2[2] == A3[2] == -1　or A1[0] == A2[0] == A3[0] == -1 or A1[0] == A2[1] == A3[2] == -1 or A1[2] == A2[1] == A3[0] == -1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Submission status: Runtime Error

Solution code:
a, b = map(str, input().split())

c = a + b
c = int(c)

for i in range(400)[1:]:
    if c == i**2:
        print('Yes')
        break

print('No')

Submission status: Runtime Error

Solution code:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
X = A + B + C
N = int(input())
L = []
for i in range (N):
  K = int(input())
  L.append(K)
ck = 'No'
if A[1] in L and A[2]in L and A[3] in L:
  ck == 'Yes'
elif B[1] in L and B[2]in L and B[3] in L:
  ck == 'Yes'
elif C[1] in L and C[2]in L and C[3] in L:
  ck == 'Yes'
elif A[1] in L and B[1]in L and C[1] in L:
  ck == 'Yes'
elif A[2] in L and B[2]in L and C[2] in L:
  ck == 'Yes'
elif A[3] in L and B[3]in L and C[3] in L:
  ck == 'Yes'
elif A[1] in L and B[2] in L and C[3] in L:
  ck = 'Yes'
elif A[3] in L and B[2] in L and C[1] in L:
  ck = 'Yes'
print(ck)

Submission status: Runtime Error

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
X=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    X=['X' if j==y else j for j in x]
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    x=['X' if j==y else j for j in x]
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    if j==y:
        x='X'
    else:
        x=[j for j in x]
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    if j==y:
        x='x'
    else:
        x=[j for j in x]
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    if j==y:
        x='x'
    else:
        x=j
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    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 _ in range(n)]

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

for i in range(3):
    if a[i] == [0,0,0]:
        print('Yes')
        exit()
for i in range(3):
    if a[j0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
        print('Yes')
        exit()
if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    print('Yes')
    exit()
if a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0:
    print('Yes')
    exit()
print('No')

Submission status: Runtime Error

Solution code:
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
M = [int(input()) for i in range(N)]
for m in range(M):
	if M[m] in A:
		A[M[m]] = 0
	elif M[m] in B:
		B[M[m]] = 0
	elif M[m] in C:
		C[M[m]] = 0
for t in range(3):
	if A[t] + B[t] + C[t] == 0:
		print('Yes')
		sys.exit()
if sum(A) == 0 or sum(B) == 0 or sum(C) ==0:
	print('Yes')
	sys.exit()
elif A[0] + B[1] + C[2] == 0:
	print('Yes')
	sys.exit()
elif A[2] + B[1] +C[0] == 0:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
import sys
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
M = [int(input()) for i in range(N)]

for m in range(M):
  if M[m] in A:
    A[M[m]] = 0
  elif M[m] in B:
    B[M[m]] = 0
  elif M[m] in C:
    C[M[m]] = 0

for t in range(3):
  if A[t] + B[t] + C[t] ==0:
    print("Yes")
    sys.exit()
if sum(A) == 0 or sum(B) == 0 or sum(C) ==0:
  print("Yes")
  sys.exit()
elif A[0] + B[1] + C[2] == 0:
  print("Yes")
  sys.exit()
elif A[2] + B[1] +C[0] == 0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import sys
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
M = [int(input()) for i in range(N)]

for m in range(M):
  if M[m] in A:
    A[M[m]] = 0
  elif M[m] in B:
    B[M[m]] = 0
  elif M[m] in C:
    C[M[m]] = 0

for t in range(3):
  if A[t] + B[t] + C[t] ==0:
    print("Yes")
    sys.exit()
if sum(A) == 0 or sum(B) == 0 or sum(c) ==0:
  print("Yes")
  sys.exit()
elif A[0] + B[1] + C[2] == 0:
  print("Yes")
  sys.exit()
elif A[2] + B[1] +C[0] == 0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
  
#たて
if True in [ not False in [A[j][i]==A[j+1][i] for j in range(len(A)-1)] for i in range(len(A[0]))]:
  print("Yes")
#よこ
elif True in [len(Counter(tmpA))==1 for tmpA in A]:
  print("Yes")
#ななめ
elif not False in [A[i][i] == A[i+1][i+1]for i in range(len(A)-1)] or not False in  [A[len(A)-(i+1)][i] == A[len(A)-(i+2)][i+1]for i in range(len(A)-1)]
  print("Yes")
#ダメ
else:
  print("No")

Submission status: Runtime Error

Solution code:
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
  
#たて
if True in [ not False in [A[j][i]==A[j+1][i] for j in range(len(A)-1)] for i in range(len(A[0]))]:
  print("Yes")
#よこ
elif True in [len(Counter(tmpA))==1 for tmpA in A]:
  print("Yes")
#ななめ
elif [A[i][i] == A[i+1][i+1]for i in range(len(A)-1)] or [A[len(A)-(i+1)][i] == A[len(A)-(i+2)][i+1]for i in range(len(A)-1)]
  print("Yes")
#ダメ
else:
  print("No")

Submission status: Runtime Error

Solution code:
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
  
#たて
if True in [[tmpA[i]==tmpA[i] and [i]==[i] for i in range(3)] for tmpA in A]
  print("Yes")
#よこ
elif len(Counter(A[0]))==1 or len(Counter(A[1]))==1 or len(Counter(A[2]))==1:
  print("Yes")
#ななめ
elif A[1][1]==-1 and (A[0][0] == A[2][2] or A[0][2]==A[2][0]):
  print("Yes")
#ダメ
else:
  print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
n = int(input())
b = []
for i in range(n):
    bn = int(input())
    b.append(bn)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -5
for i in range(3):
    if sum(a[i]) == -15:
        bng = 1
for i in range(3):
     cnt = 0
     for j in range(3):
       cnt += a[j][i]
       if cnt == -15:
         bng = 1
        
cnt = 0
for i in range(3):
        cnt += a[i][i]
if cnt == -15:
        bng = 1 
                
if bng == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
n = int(input())
b = []
for i in range(n):
    bn = int(input())
    b.append(bn)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -5
print(*a)
for i in range(3):
    if sum(a[i]) == -15:
        bng = 1
for i in range(3):
     cnt = 0
     for j in range(3):
       cnt += a[j][i]
       if cnt == -15:
         bng = 1
        
cnt = 0
for i in range(3):
        cnt += a[i][i]
if cnt == -15:
        bng = 1 
                
if bng == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A=[]
check=[]
for i in range(3):
    a=list(map(int,input().split()))
    A.append(a)
    check.append([0,0,0])
n=int(input())
for _ in range(n):
    b=map(int(input().split()))
    for i in range(3):
        for j in range(3):
            if b==A[i][j]:
                check[i][j]=1
ok=0
for i in range(3):
    if check[i][0]+check[i][1]+check[i][2]==3:
        ok=1
    if check[0][i]+check[1][i]+check[2][i]:
        ok=1
if [0][0]+[1][1]+[2][2]==3:
    ok=1
if [0][2]+[1][1]+[2][0]:
    ok=1
if ok==1:
    print('Yes')
else:
    print('No')

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)]
 
for num in b:
  for x in range(3):
    for y in range(3):
      if a[x][y] == num:
        a[x][y] = 0
 
if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][1],a[2][2]]) == 0 or sum([a[2][0],a[1][1],a[0][2]]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][0],a[2][0]]) == 0 or sum([a[0][1],a[1][1],a[2][1]]) == 0 or sum([a[0][2],a[1][2],a[2][2]]) == 0:
  print("Yes")                                                 
else:
  print("No")
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

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

if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][1],a[2][2]]) == 0 or sum([a[2][0],a[1][1],a[0][2]]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][0],a[2][0]]) == 0 or sum([a[0][1],a[1][1],a[2][1]]) == 0 or sum([a[0][2],a[1][2],a[2][2]]) == 0:
  print("Yes")                                                 
else:
  print("No")

Submission status: Runtime Error

Solution code:
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input)
B = [list(input()) for i in range(N) ]
for i in range(3) :
    for j in range(3):
        if A[i][j] in B :
            A[i][j] = -1
for k in range(3):
    if a[k] == [-1, -1, -1] or (a[0][k] == a[1][k] == a[2][k] == -1):
        print('Yes')
    elif a[0][0] == a[1][1] == a[2][2] == -1:
        print('Yes')
    elif a[0][2] == a[1][1] == a[2][0] == -1:
        print('Yes')
    else :
        print('No')

Submission status: Runtime Error

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

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

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

if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[3]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][1],a[2][2]]) == 0 or sum([a[2][0],a[1][1],a[0][2]]):
  print("Yes")
elif sum([a[0][0],a[1][0],a[2][0]]) == 0 or sum([a[0][1],a[1][1],a[2][1]]) == 0 or sum([a[0][2],a[1][2],a[2][2]]) == 0:
  print("Yes")                                                 
else:
  print("No")

Submission status: Runtime Error

Solution code:
import numpy as np


A = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
for _ in range(n):
  b = int(input())
  A = np.where(A == b, 0, A)
  
x = np.all(A[[0, 1, 2], [0, 1, 2]] == 0)
y = np.all(A[[0, 1, 2], [2, 1, 0]] == 0)
z = np.any(np.sum(A, axis=0) == 0)
w = np.any(np.sum(A, axis=1) == 0)

print(['Yes', 'No'][!x and !y and !z and !w])

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
a = []
for i in range(3):
    a += list(map(int, input().split()))
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(9):
    if a[i] in b:
        a[i] = -1
for j in range(3):
    if (a[j] == -1 and a[j+1] == -1 and a[j+2] == -1) or (a[3*j] == -1 and a[3*(j+1)] == -1 and a[3*(j+2)] == -1):
        print('Yes')
        quit()
if (a[0] == -1 and a[4] == -1 and a[8] == -1) or (a[2] == -1 and a[4] == -1 and a[6] == -1):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys
bingo_size = 3
a = []
an = set()
for _ in range(3):
  a.append(list(map(int, input().split())))
  for i in a[_]:
    an.add(i)

n = int(input())
b = set()
for _ in range(n):
  bi = int(input())
  if bi in an:
    b.add(bi)

for hi in range(3):
  ok = True
  for _ in range(3):
    if a[hi][_] not in b:
      ok = false
      break
    if ok:
      print("Yes")
      sys.exit()

for wi in range(3):
  ok = True
  for _ in range(3):
    if a[_][wi] not in b:
      ok = False
      break
  if ok:
    print("Yes")
    sys.exit()

if all([a[0][0] in b, a[1][1] in b, a[2][2] in b]) or all([a[0][2] in b, a[1][1] in b, a[2][0] in b]):
           print("Yes")
           sys.exit()
           
print("No")

Submission status: Runtime Error

Solution code:
import sys
bingo_size = 3
a = []
an = set()
for _ in range(3):
  a.append(list(map(int, input().split())))
  for i in a[_]:
    an.add(i)

n = int(input())
b = set()
for _ in range(n):
  bi = int(input())
  if bi in an:
    b.add(bi)

for hi in range(3):
  ok = True
  for _ in range(3):
    if a[hi][_] not in b:
      ok = false
      break
    if ok:
      print("Yes")

for wi in range(3):
  ok = True
  for _ in range(3):
    if a[_][wi] not in b:
      ok = false
      break
  if ok:
    print("Yes")

if all([a[0][0] in b, a[1][1] in b, a[2][2] in b]) or all([a[0][2] in b, a[1][1] in b, a[2][0] in b]):
           print("Yes")
           
print("No")

Submission status: Runtime Error

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

n = int(input())
b = list()
i = 0

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

if a11 in b:
    a11 = 'T'

if a12 in b:
    a12 = 'T'

if a13 in b:
    a13 = 'T'

if a21 in b:
    a21 = 'T'

if a22 in b:
    a22 = 'T'

if a23 in b:
    a23 = 'T'

if a31 in b:
    a31 = 'T'

if a32 in b:
    a32 = 'T'

if a33 in b:
    a33 = 'T'

if a11 == 'T':
    if a12 == 'T':
        if a13 == 'T':
            print('Yes')
            exit()
    
    if a22 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()
    
    if a21 == 'T':
        if a31 == 'T':
            print('Yes')
            exit()

elif a12 == 'T':
    if a22 == 'T':
        if a32 == 'T':
            print('Yes')
            exit()

elif a13 == 'T':
    if a22 == 'T':
        if a31 == 'T':
            print('Yes')
            exit()

     if a23 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()

elif a21 == 'T':
    if a22 == 'T':
        if a23 == 'T':
            print('Yes')
            exit()

elif a31 == 'T':
    if a32 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()

else:
    print('No')

Submission status: Runtime Error

Solution code:
A=[list(map(int,input().split())) for i in range(3)]
AB=[[0 for i in range(3)] for j in range(3)]
N=int(input())
for i in range(N):
    x=input()
    for j in range(3):
        for k in range(3):
            if A[i][j]==x:
                AB[i][j]=1
c=1
for i in range(3):
    if A[i][0]*A[i][1]*A[i][2]==1:
        c=0
        print("Yes")
        break
    if A[0][i]*A[1][i]*A[2][i]==1:
        c=0
        print("Yes")
        break
    if A[0][0]*A[1][1]*A[2][2]==1:
        c=0
        print("Yes")
        break
    if A[0][2]*A[1][1]*A[2][0]==1:
        c=0
        print("Yes")
        
if c==1:
    print("No")

Submission status: Runtime Error

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

arr = np.array([[0] * 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:
                arr[i][j] += 1

# horizontal
done = False
print(arr)

if not done:
    curr_sum = 0
    for i in range(3):
        if sum(arr[i]) == 3:
            curr_sum += 1
    if curr_sum > 0:
        done = True
        print("Yes")

# vertical
if not done:
    curr_sum = 0
    for i in range(3):
        if sum(arr.T[i]) == 3:
            curr_sum += 1
    if curr_sum > 0:
        done = True
        print("Yes")

# diagonal
if not done:
    curr_sum = 0
    if np.trace(arr) == 3:
        curr_sum += 1
    arr = np.flip(arr)
    if np.trace(arr) == 3:
        curr_sum += 1
    if curr_sum > 0:
        done = True
        print("Yes")

if not done:
    print("No")

Submission status: Runtime Error

Solution code:
a=[]
for i in range(3):
  a1,a2,a3=map(int,input().split())
  a.append(a1,a2,a3)
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(9):
    if a[j]==b:
      a[j]=0
if a[0]==0 and a[1]==0 and a[2]==0:
  print("Yes")
elif a[3]==0 and a[4]==0 and a[5]==0:
  print("Yes")
elif a[6]==0 and a[7]==0 and a[8]==0:
  print("Yes")
elif a[0]==0 and a[3]==0 and a[6]==0:
  print("Yes")
elif a[1]==0 and a[4]==0 and a[7]==0:
  print("Yes")
elif a[2]==0 and a[5]==0 and a[8]==0:
  print("Yes")
elif a[0]==0 and a[4]==0 and a[8]==0:
  print("Yes")
elif a[2]==0 and a[4]==0 and a[6]==0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import math
h,w = map(int, input().split())
print(1 if h==1 or w==1 else math.ceil(h*w/2) )

Submission status: Runtime Error

Solution code:
#Bingo
card = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
a = [[0]*3 for _ in range(3)]
for bi in b:
    for i in range(3):
        for j in raneg(3):
            if bi == card[i][j]:
                a[i][j] = 1
                
ans = 'No'
#tate
for i in range(3):
    if a[0][i] == 1 and a[1][i] == 1 and a[2][i] == 1:
        ans = 'Yes'
            
#yoko
for i in range(3):
    if a[i][0] == 1 and a[i][1] == 1 and a[i][2] == 1:
        ans = 'Yes'
    
#naname
if a[0][0] == 1 and a[1][1] == 1 and a[2][2] == 1:
    ans = 'Yes'
if a[1][3] == 1 and a[2][2] == 1 and a[3][1] == 1:
    ans ='Yes'
print(ans)

Submission status: Runtime Error

Solution code:
a=[]
for i in range(3):
  aa=list(map(str,input().split()))
  a.append(aa)
  
n=int(input())
ln=[]
for i in range(n):
  lnn=input()
  ln.append(lnn)
  
visited=[[0]*3 for i in range(3)]

for i in range(3):
  for j in range(3):
    for k in range(n):
      if ln[k] in a[i][j]:
        visited[i][j]=1

for j in range(3):
  if all([visited[i][j] for i in range(3)])==1:
    print('Yes')
    exit()
    
for i in range(3):
  if all([visited[i][j] for j in range(3)])==1:
    print('Yes')
    exit()
    
if visited[0][0]==1 and visited[1][1]==1 and visited[2][2]==1:
  print('Yes')
  exis()
  
if visited[0][2]==1 and visited[1][1]==1 and visited[2][0]==1:
  print('Yes')
  exis()
  
print('No')

Submission status: Runtime Error

Solution code:
a = list(list(map(int,input().split())) for _ 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')