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()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
P = [list(map(int,input().split())) for i in range(N)]


Hit = True
Nohit = False

def int_calc(X):
    for i in X:
        if i.is_integer():
            X[X.index(i)] = False
    
for i in P:
    if i in A:
        A[A.index(i)] = Hit
    elif i in B:
        B[B.index(i)] = Hit
    elif i in C:
        C[C.index(i)] = Hit
        
int_calc(A)
int_calc(B)
int_calc(C)
    
if all(A[:]):
    print("Yes")
elif all(B[:]):
    print("Yes")
elif all(C[:]):
    print("Yes")
elif all((A[0],B[0],C[0])):
         print("Yes")
elif all((A[1],B[1],C[1])):
         print("Yes")
elif all((A[2],B[2],C[2])):
         print("Yes")                                               
elif all((A[0],B[1],C[2])):
         print("Yes")
elif all((A[2],B[1],C[0])):
         print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a = []
for i in range(3):
  tmp = input()
  a.append(list(map(int, tmp.split())))

n = int(input())
# print('n', n)
b = []
for j in range(n):
    b.append(int(input()))

# print('a', a)
# print('b', b)

def rep(a):
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
            a[i][j] = 0

def check(a):
    #　たてビンゴ
    # 斜め
    if a[0][0] == 0 & a[1][1] == 0 & a[2][2] == 0:
            print('Yes')
            exit()
    if a[0][2] == 0 & a[1][1] == 0 & a[2][0] == 0:
            print('Yes')
            exit()
    for i in range(3):
        if (a[0][i] == 0 & a[1][i] == 0 & a[2][i] == 0):
            print('Yes')
            exit()
        if a[i] == [0, 0, 0]:
            print('Yes')
            exit()
    print('No')

rep(a)
check(a)

Submission status: Runtime Error

Solution code:
from collections import Counter

a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
n = int(input())
d_list = [int(input()) for k in range(n)]
for n in range(3):
    for p in range(3):
        if d_list[n] == a_list[p]:
            a_list[p] = 555
    for q in range(3):
        if d_list[n] == b_list[q]:
            b_list[q] = 555
    for r in range(3):
        if d_list[n] == c_list[r]:
            c_list[r] = 555

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

elif b_list[0] == b_list[1] == b_list[2]:
    print('Yes')

elif c_list[0] == c_list[1] == c_list[2]:
    print('Yes')

elif　a_list[0] == b_list[0] == c_list[0]:
        print('Yes')
elif　a_list[1] == b_list[1] == c_list[1]:
        print('Yes')
elif　a_list[2] == b_list[2] == c_list[2]:
    print('Yes')
elif a_list[0] == b_list[1] == c_list[2]:
    print('Yes')

elif a_list[2] == b_list[1] == c_list[0]:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c = [input().split() for i in range(3)]

a.extend(b)
a.extend(c)
b = [input() for i in range(10)]
for b1 in b:
    a = ['a' if b1 == s in s else s for s in a]

if a[0] == 'a' and a[1] == 'a' and a[2] == 'a':
    print("Yes")
elif a[3] == 'a' and a[4] == 'a' and a[5] == 'a':
    print("Yes")
elif a[6] == 'a' and a[7] == 'a' and a[8] == 'a':
    print("Yes")
elif a[0] == 'a' and a[3] == 'a' and a[6] == 'a':
    print("Yes")
elif a[1] == 'a' and a[4] == 'a' and a[7] == 'a':
    print("Yes")
elif a[2] == 'a' and a[5] == 'a' and a[8] == 'a':
    print("Yes")
elif a[0] == 'a' and a[4] == 'a' and a[8] == 'a':
    print("Yes")
elif a[2] == 'a' and a[4] == 'a' and a[6] == 'a':
    print("Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

L_tate = list(zip(*L_yoko))

L_naname = []
L_naname.append([L_yoko[0][0],L_yoko[1][1],L_yoko[2][2]])
L_naname.append([L_yoko[0][2],L_yoko[1][1],L_yoko[2][0]])

a = int(0)
for z in L_tate:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_yoko:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_naname:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

if a == 0:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import sys
s = sys.stdin.readlines()
A1_1,A1_2,A1_3= map(int, s[0].split())
A2_1,A2_2,A2_3= map(int, s[1].split())
A3_1,A3_2,A3_3= map(int, s[2].split())
N=int(s[3].split())
B=[]
for e in s[4:N + 4]:
    B.append(e)
a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
lines = [input().split() for i in range(3)]
 
num = int(input())
bs = []
for i in range(num):
  bs.append(input())
 
hits = []
for i in bs:
  for row_index in range(len(lines)):
    for col_index in range(len(line)):
      if lines[row_index][col_index] == i:
        hits.append((row_index,col_index))
row_hits = (0,0,0)
col_hits = (0,0,0)
stride_hits = (0,0)
 
for hit in hits:
  r = hit[0]
  c = hit[1]
  row_hits[r]+=1
  col_hits[c]+=1
  if r == c:
    stride_hits[0]+=1
  else if (r,c) == (0,2) or (r,c) == (1,1) or (r,c) == (2,0) :
    stride_hits[1]+=1
 
if max(row_hits)>= 3 or max(col_hits)>=3 or max(stride_hits)>= 3:
  print 'Yes'
else:
  print 'No'

Submission status: Runtime Error

Solution code:
list_1 = list(map(int,input().split()))
list_2 = list(map(int,input().split()))
list_3 = list(map(int,input().split()))

#n,m = map(int,raw_input().split())
#list_a = []
#for i in range(M) 
list_a=list_1


for x in list_2:
    list_a.append(x)


for x in list_3:
    list_a.append(x)


N = int(input())
#list_b = [int(x) for x in input().split()]
list_b = list(map(int,input().split()))

list_c = [0,0,0,0,0,0,0,0,0]
for i in range(N):
    for j in range(9):
        if list_a[j] == list_b[i]:
            list_c[j] = 1

flag=0
if list_c[0]==1 and list_c[1]==1 and list_c[2]==1:
    flag=1
if list_c[3]==1 and list_c[4]==1 and list_c[5]==1:
    flag=1
if list_c[6]==1 and list_c[7]==1 and list_c[8]==1:
    flag=1
if list_c[0]==1 and list_c[3]==1 and list_c[6]==1:
    flag=1
if list_c[1]==1 and list_c[4]==1 and list_c[7]==1:
    flag=1
if list_c[2]==1 and list_c[5]==1 and list_c[8]==1:
    flag=1
if list_c[0]==1 and list_c[4]==1 and list_c[8]==1:
    flag=1
if list_c[2]==1 and list_c[4]==1 and list_c[6]==1:
    flag=1
    
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
N = int(input())
d_list = [int(input()) for k in range(N)]
print(a_list)

for n in range(3):
    for p in range(3):
        if d_list[n] == a_list[p]:
            a_list[p] = 555
    for q in range(3):
        if d_list[n] == b_list[q]:
            b_list[q] = 555
    for r in range(3):
        if d_list[n] == c_list[r]:
            c_list[r] = 555

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

elif b_list[0] == b_list[1] == b_list[2]:
    print('Yes')

elif c_list[0] == c_list[1] == c_list[2]:
    print('Yes')

elif　a_list[0] == b_list[0] == c_list[0]:
        print('Yes')
elif　a_list[1] == b_list[1] == c_list[1]:
        print('Yes')
elif　a_list[2] == b_list[2] == c_list[2]:
    print('Yes')
elif a_list[0] == b_list[1] == c_list[2]:
    print('Yes')

elif a_list[2] == b_list[1] == c_list[0]:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

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

Hit = True
Nohit = False

def int_calc(X):
    for i in X:
        if i.is_integer():
            i = False
    
for i in P:
    if i in A:
        A[A.index(i)] = Hit
    elif i in B:
        B[B.index(i)] = Hit
    elif i in C:
        C[C.index(i)] = Hit
        
int_calc(A)
int_calc(B)
int_calc(C)
    
if all(A[:]):
    print("Yes")
elif all(B[:]):
    print("Yes")
elif all(C[:]):
    print("Yes")
elif all((A[0],B[0],C[0])):
         print("Yes")
elif all((A[1],B[1],C[1])):
         print("Yes")
elif all((A[2],B[2],C[2])):
         print("Yes")                                               
elif all((A[0],B[1],C[2])):
         print("Yes")
elif all((A[2],B[1],C[0])):
         print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
bingo = []
bingo.append(list(map(int,input().split())))
bingo.append(list(map(int,input().split())))
bingo.append(list(map(int,input().split())))

print("bingo",bingo)

score = [[0,0,0],[0,0,0],[0,0,0]]
total = 0
selects = [input() for i in range(10)]
print("selects",selects)
for select in selects:
    if select.isnumeric():
        select = int(select)
        print(select)
    else:
        continue
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == select:
                score[i][j] = 1
    print("score", score)
    for i in range(3):
        total += sum(score[i]) == 3
        total += sum(score[:][i]) == 3

    if (score[0][0] + score[1][1] + score[2][2]) == 3:
        total +=1
    if (score[0][2] + score[1][1] + score[2][0]) == 3:
        total +=1
    print("total",total)
    if total > 0:
        print('Yes')
        break

if total == 0:
    print('No')

Submission status: Runtime Error

Solution code:
A = [int(input()) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

if A[1].count(b) == 3 or\
A[2].count(b) == 3 or\
A[3].count(b) == 3 or\
X[A[1][1],A[2][1],A[3][1]].count(b) == 3 or\
X[A[1][2],A[2][2],A[3][2]].count(b) == 3 or\
X[A[1][3],A[2][3],A[3][3]].count(b) == 3 or\
X[A[1][1],A[2][2],A[3][3]].count(b) == 3 or\
X[A[1][3],A[2][2],A[3][1]].count(b) == 3:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
A = list(map(str, input().split()))
A += list(map(str, input().split()))
A += list(map(str, input().split()))
a = []
N = int(input())
for i in range(7):
    a.append(input())
flag = 0
for i  in a:
    if i in A:
        A[A.index(i)] = "0"
B = []
C = []
for i in range(3):
    B.append(A[4*i])
    C.append(A[2*i])
    if "0" in A[i*3:i*3+3]:
        if A.count("0") == 3:
            flag = 1
if "0" in B:
    if B.count("0") == 3:
        flag = 1
if"0"in C:
    if C.count("0") == 3:
        flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
bingo = [int(input()),int(input()),int(input()),int(input()),
         int(input()),int(input()),int(input()),int(input()),int(input())]
a_list= []
N = int(input())
for i in range(0,N):
    b = int(input())
    if b in bingo:
        a_list.append(bingo.index(b))
print(a_list)
if 0 in a_list:
    if 1 in a_list:
        if 2 in a_list:
            yes = 1
    if 3 in a_list:
        if 6 in a_list:
            yes = 1
    if 4 in a_list:
        if 8 in a_list:
            yes = 1
if 1 in a_list:
    if 4 in a_list:
        if 7 in a_list:
            yes = 1
if 2 in a_list:
    if 4 in a_list:
        if 6 in a_list:
            yes = 1
    if 5 in a_list:
        if 8 in a_list:
            yes = 1
if 3 in a_list:
    if 4 in a_list:
        if 5 in a_list:
            yes = 1
if 6 in a_list:
    if 7 in a_list:
        if 8 in a_list:
            yes = 1
if yes == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
lines = [input().split() for i in range(3)]

num = int(input())
bs = []
for i in range(num):
  bs.append(input())

hits = []
for i in bs:
  for row_index in range(len(lines)):
    for col_index in range(len(line)):
      if lines[row_index][col_index] == i:
        hits.append((row_index,col_index))
row_hits = (0,0,0)
col_hits = (0,0,0)
stride_hits = (0,0)

for hit in hits:
  r = hit[0]
  c = hit[1]
  row_hits[r]++
  col_hits[c]++
  if r == c:
    stride_hits[0]++
  else if (r,c) == (0,2) or (r,c) == (1,1) or (r,c) == (2,0) :
    stride_hits[1]++

if max(row_hits)>= 3 or max(col_hits)>=3 or max(stride_hits)>= 3:
  print 'Yes'
else:
  print 'No'

Submission status: Runtime Error

Solution code:
import sys
A1 = [int(e) for e in input().split()]
A2 = [int(e) for e in input().split()]
A3 = [int(e) for e in input().split()]
A = A1 + A2 + A3

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

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

number = [0, 3, 6]
for i in number:
  if A[i] == A[i+1] == A[i+2] == 0:
    print("Yes")
    sys.exit()
number = [0, 1, 2]
for i in number:
  if A[i] == A[i+3] == A[i+6] == 0:
    print("Yes")
    sys.exit()
if A[0] == A[4] == A[8] == 0:
  print("Yes")
  sys.exit()
if A[2] == A[4] == A[6] == 0:
  print("Yes")
  sys.exit()

print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
  int a[3][3];
  int my[3][3];
  int i,j,k;

  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&a[i][j]);
    }
  }

  int n;
  int b[n];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
    //printf("koko");
  }

  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      for(k=0;k<n;k++){
        if(a[i][j]==b[k]){
          my[i][j]=1;
        }
        else{
          my[i][j]=0;
        }
      }
    }
  }

  /*for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      printf("%d",my[i][j]);
    }
  }
  */

  for(i=0;i<3;i++){
    if(my[i][0]==1&&my[i][1]==1&&my[i][2]==1){
      printf("Yes");
      return 0;
    }
    if(my[0][i]==1&&my[1][i]==1&&my[2][i]==1){
      printf("Yes");
      return 0;
    }
  //  printf("kk");
  }

  if(my[0][0]==1&&my[1][1]==1&&my[2][2]==1){
    printf("Yes");
    return 0;
  }

  if(my[0][2]==1&&my[1][1]==1&&my[2][0]==1){
    printf("Yes");
    return 0;
  }

  printf("No");


  return 0;
}

Submission status: Runtime Error

Solution code:
n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))
n3 = list(map(int, input().split()))
arr = []
z=0
for i in range(10):
    arr.append(int(input()))
    if arr[i] == n1[0] or arr[i] == n1[1] or arr[i] == n1[2] or arr[i] == n2[0] or arr[i] == n2[1] or arr[i] == n2[2] or arr[i] == n3[0] or arr[i] == n3[1] or arr[i] == n3[2]:
        z+=1
if z >= 3: print("Yes")
else: print("No")

Submission status: Runtime Error

Solution code:
A1 = [int(e) for e in input().split()]
A2 = [int(e) for e in input().split()]
A3 = [int(e) for e in input().split()]
A = A1 + A2 + A3

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

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

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

print("No")

Submission status: Runtime Error

Solution code:
matrix = []
# For user input
for i in range(3):  # A for loop for row entries
    a = []
    for j in range(3):  # A for loop for column entries
        a.append(int(input()))
    matrix.append(a)

# For printing the matrix
# for i in range(3):
#     for j in range(3):
#         print(matrix[i][j], end=" ")
#     print()

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

if matrix[0][0] in b:
    if matrix[1][1] in b:
        if matrix[2][2] in b:
            print("Yes")
else: print("No")

Submission status: Runtime Error

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N =int(input())
B = []
for _ in range(N+4):
    B.append(input())

a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Runtime Error

Solution code:
A = []
A.append(int(e) for e in input().split())
A.append(int(e) for e in input().split())
A.append(int(e) for e in input().split())

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

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

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

print("No")

Submission status: Runtime Error

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

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

    flag = False
    for i in range(3):
        for j in range(3):
                if(j+2 < 3 and A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j+2 < 3 and A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
                if(i-2 >= 0 and j-2 >= 0 and A[i][j] == 0 and A[i-1][j-1] == 0 and A[i-2][j-2] == 0):
                    flag = True
                    break
                if(i-2 >= 0 and j+1 < 3 and A[i][j] == 0 and A[i-1][j+1] == 0 and A[i-2][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j-2 >= 0 and A[i][j] == 0 and A[i+1][j-1] == 0 and A[i+2][j-2] == 0):
                    flag = True
                    break
        if(flag):
            break

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
A = []
A.append(int(e)) for e in input().split()
A.append(int(e)) for e in input().split()
A.append(int(e)) for e in input().split()

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

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

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

print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

    flag = False
    for i in range(3):
        for j in range(3):
                if(j+2 < 3 and A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j+2 < 3 and A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
                if(i-2 >= 0 and j-2 >= 0 and A[i][j] == 0 and A[i-1][j-1] == 0 and A[i-2][j-2] == 0):
                    flag = True
                    break
                if(i-2 >= 0 and j+1 < 3 and A[i][j] == 0 and A[i-1][j+1] == 0 and A[i-2][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j-2 >= 0 and A[i][j] == 0 and A[i+1][j-1] == 0 and A[i+2][j-2] == 0)
        if(flag):
            break

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
bingo = []
bingo.append(list(map(int,input().split())))
bingo.append(list(map(int,input().split())))
bingo.append(list(map(int,input().split())))

#print(bingo)

score = [[0,0,0],[0,0,0],[0,0,0]]
total = 0
selects = [input() for i in range(10)]
#print(selects)
for select in selects:
    if len(select) > 0:
        select = int(select)
        #print(select)
    else:
        continue
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == select:
                score[i][j] = 1
    #print("score", score)
    for i in range(3):
        total += sum(score[i]) == 3
        total += sum(score[:][i]) == 3

    if (score[0][0] + score[1][1] + score[2][2]) == 3:
        total +=1
    if (score[0][2] + score[1][1] + score[2][0]) == 3:
        total +=1
    #print("total",total)
    if total > 0:
        print('Yes')
        break

if total == 0:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N = map(int, input().split())
B = []
for _ in range(N):
    B.append(input())

a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Runtime Error

Solution code:
matrix = []
# For user input
for i in range(3):  # A for loop for row entries
    a = []
    for j in range(3):  # A for loop for column entries
        a.append(int(input()))
    matrix.append(a)

# For printing the matrix
# for i in range(3):
#     for j in range(3):
#         print(matrix[i][j], end=" ")
#     print()

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

if matrix[0][0] in b:
    if matrix[1][1] in b:
        if matrix[2][2] in b:
            print("Yes")
else: print("No")

if matrix[0][2] in b:
    if matrix[1][1] in b:
        if matrix[2][0] in b:
            print("Yes")
else: print("No")

if matrix[0][0] in b:
    if matrix[1][0] in b:
        if matrix[2][0] in b:
            print("Yes")
else: print("No")

if matrix[0][1] in b:
    if matrix[1][1] in b:
        if matrix[2][1] in b:
            print("Yes")
else: print("No")

if matrix[0][2] in b:
    if matrix[1][2] in b:
        if matrix[2][2] in b:
            print("Yes")
else: print("No")

if matrix[0][0] in b:
    if matrix[0][1] in b:
        if matrix[0][2] in b:
            print("Yes")
else: print("No")

if matrix[1][0] in b:
    if matrix[1][1] in b:
        if matrix[1][2] in b:
            print("Yes")
else: print("No")

if matrix[2][0] in b:
    if matrix[2][1] in b:
        if matrix[2][2] in b:
            print("Yes")
else: print("No")