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 = [0]*3
for i in range(3):
    A[i] = list(map(int,input().split()))
N = int(input())
B = []
for _ in range(N):
    B.append(int(input())
             
for k in range(3):
    for j in range(3):
        if A[k][j] in B:
             A[k][j] = 0
answer = 'No'
for i in range(3):
    if sum(A[i])==0:
        answer = 'Yes'
        break
    count = 0
    for j in range(3):
        count += A[j][i]
print(answer)

Submission status: Runtime Error

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

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

for i in range(N):
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == N[i]:
        check[j][k] = 1
        
ans = 'No'
for i in range(3):
  if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
    ans = 'Yes'
    
for i in range(3):
  if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
    ans = 'Yes'
    
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
  ans = 'Yes'
  
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
  ans = 'Yes'
  
print(ans)

Submission status: Runtime Error

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

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

for i in range(N):
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == N[i]:
        check[j][k] = 1
        
ans = 'No'
for i in range(3):
  if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
    ans = 'Yes'
    
for i in range(3):
  if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
    ans = 'Yes'
    
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
  ans = 'Yes'
  
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
  ans = 'Yes'
  
print(ans)

Submission status: Runtime Error

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

for i in range(N):
    for j in range(3):
        for l in range(3):
            if t[i] == s[j][l]
            s[j][l] = 0

if sum(s[0]) == 0 or sum(s[1]) == 0 or sum(s[2]) == 0 or s[0][0]+s[1][0]+s[2][0] == 0 or s[0][1]+s[1][1]+s[2][1] == 0 or s[0][2]+s[1][2]+s[2][2] == 0 or s[0][0]+s[1][1]+s[2][2] == 0 or s[2][0]+s[1][1]+s[0][2] == 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys
li = [list(map(int,input().split())) for i in range(3)]
n = int(input())
cnt = 0
for i in range(2):
    for j in range(2):
        for k in int(input()):
            if li[i][j] == k:
                li[i][j] == -1
            else:
                pass

for a in range(2):
    if li[a][0] == li[a][1] == li[a][2] == -1:
        print("Yes")
        sys.exit()
    else:
        pass
for b in range(2):
    if li[0][[b] == li[1][[b] == li[2][[b] == -1:
        print("Yes")
        sys.exit()
    else:
        pass
if li[0][[0] == li[1][[1] == li[2][[2] == -1:
    print("Yes")
    sys.exit()
else:
    pass
if li[0][[2] == li[1][[1] == li[2][[0] == -1:
    print("Yes")
    sys.exit()
else:
    print("No")

Submission status: Runtime Error

Solution code:
mat = [[False]*3 for i in range(3)]
a_mat = []
for i in range(3):
  a_list = list(map(int, input().split()))
  a_mat.append(a_list)
n = int(input())
for i in range(n):
  b = int(input())
  for x in range(3):
    for y in range(3):
      if a_mat[x][y] == b:
        mat[x][y] = True

if mat[0][0] and mat[0][1] and mat[0][2] ¥
or mat[1][0] and mat[1][1] and mat[1][2] ¥
or mat[2][0] and mat[2][1] and mat[2][2] ¥
or mat[0][0] and mat[1][0] and mat[2][0] ¥
or mat[0][1] and mat[1][1] and mat[2][1] ¥
or mat[0][2] and mat[1][2] and mat[2][2] ¥
or mat[0][0] and mat[1][1] and mat[2][2] ¥
or mat[0][2] and mat[1][1] and mat[2][0]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
a1= list(map(int,input().solit()))
a2= list(map(int,input().solit()))
a3= list(map(int,input().solit()))
a = a1 + a2 + a3

n = int(input())

#bがaにあるか確認して0へ
for _ in range(n):
  b = int(input())
  if b in a:
    a[a.index(b)]=0
  
  
check = 0
for i in range(3):
  #縦横のbingo検索
  if (a[3*i]==a[3*i+1] and a[3*i+1]==a[3*i+2]) or (a[i]==a[i+3] and a[i+3]==a[i+6]):
        check+=1
#ななめ
if (a[0]==a[4] and a[4]==a[8]) or (a[2]==a[4] and a[4]==a[6]):
    check+=1
if check>0:
    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())
listb = [input() for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[1] == A2[2] == A3[3] or A1[3] == A2[2] == A3[1]:
    print('Yes')
    exit()
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())
listb = [input() for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
flg = false
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[1] == A2[2] == A3[3] or A1[3] == A2[2] == A3[1]:
    print 'Yes'
    exit()
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 i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                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 or a[0][2] == a[1][1] == a[2][0] == 0:
    ans = "Yes
print(ans)

Submission status: Runtime Error

Solution code:
import os

card = []
for i in range(3):
    list = [int(i) for i in input().split()]
    card = card + list
n = int(input())
bingo = []
for i in range(n):
    bingo.append(i)

for j in range(9):
    for i in range(n):
    if card[j] is bingo[i]:
        card[j] = -1

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

Submission status: Runtime Error

Solution code:
A = []
[A.extend(map(int, input().split())) for _ in range(3)]
_, *B = map(int, open(0).read().split())
for b in B:
    try:
        i = A.index(b)
        A[i] = 0
    except:
        pass
lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
]
ans = "No"
for line in lines:
    a, b, c = line
    if A[a] == 0 and A[a] == A[b] and A[a] == A[c]:
        ans = "Yes"
print(ans)

Submission status: Runtime Error

Solution code:
A = []
[A.extend(map(int, input().split())) for _ in range(3)]
_, *B = map(int, open(0).read().split())
for b in B:
    try:
        i = A.index(b)
        A[i] = 0
    except Exception:
        pass
lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
]
ans = "No"
for line in lines:
    a, b, c = line
    if A[a] == 0 and A[a] == A[b] and A[a] == A[c]:
        ans = "Yes"
print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    l=[list(map(int, input().split()) )for i in range(3)]
    n=int(input())
    b=[int(input()) for i in range(n)]
    bingo='No'
    for i in range(3):
        if l[i][0] in b and l[i][1] in b and l[i][2] in b:
           bingo='Yes'
        if l[0][i] in b and l[1][i] in b and l[2][i] in b:
            bingo='Yes'
    if (l[0][0] in b and l[1][1] in b and l[2][2] in b) or (l[2][0] in b and l[[1][1] in b and l[0][2] in b]):
        bingo='Yes'
    print(bingo)
resolve()

Submission status: Runtime Error

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

for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == a[j][k]:
        a[j][k] = "0"

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

Submission status: Runtime Error

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

for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == int(a[j][k]):
        a[j][k] = "0"

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

Submission status: Runtime Error

Solution code:
def bingo_check() :
    if list[0][0] and list [1][1] and list[2][2] in list :
        print('Yes')
    elif list[0][2] and list [1][1] and list[2][0] in list :
        print('Yes')
    else:
        for p in range(3):
            if list[0][p] and list [1][p] and list[2][p] in list :
                ptint('Yes')
                break
            elif list[p][0] and list [p][1] and list[p][2] in list :
                print('Yes')
                break
            else :
                continue
        else :
            print('No')

a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
N = int(input())

cnt = 0
bingo = [[a, b, c],[d, e, f],[g, h, i]]
list = []

while cnt < N :
    bin = int(input())
    list.append(bin)
    cnt += 1

if cnt == 1 or cnt == 2 :
    print('No')
elif cnt >= 7 :
    print('Yes')
else :
    bingo_check()

Submission status: Runtime Error

Solution code:
def bingo_check() :
    if list[0][0] and list [1][1] and list[2][2] in list :
        print('Yes')
    elif list[0][2] and list [1][1] and list[2][0] in list :
        print('Yes')
    else :
        for p in range(3):
            if list[0][p] and list [1][p] and list[2][p] in list :
                ptint('Yes')
            elif list[p][0] and list [p][1] and list[p][2] in list :
                print('Yes')
            else :
                print('No')


a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
N = int(input())

cnt = 0
bingo = [[a, b, c],[d, e, f],[g, h, i]]
list = []

while cnt < N :
    bin = int(input())
    list.append(bin)
    cnt += 1

if cnt == 1 or cnt == 2 :
    print('No')
elif cnt == 7 or cnt == 8 or cnt ==9 or cnt == 10 :
    print('Yes')
else :
    bingo_check()

Submission status: Runtime Error

Solution code:
def bingo_check() :
    if list[0][0] and list [1][1] and list[2][2] in list :
        print('Yes')
    elif list[0][2] and list [1][1] and list[2][0] in list :
        print('Yes')
    else :
        for i in range(3):
            if list[0][i] and list [1][i] and list[2][i] in list :
                ptint('Yes')
            elif list[i][0] and list [i][1] and list[i][2] in list :
                print('Yes')
            else :
                print('No')


a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
N = int(input())

cnt = 0
bingo = [[a, b, c],[d, e, f],[g, h, i]]
list = []

while cnt < N :
    bin = int(input())
    list.append(bin)
    cnt += 1

if cnt == 1 or cnt == 2 :
    print('No')
elif cnt == 7 or cnt == 8 or cnt ==9 or cnt == 10 :
    print('Yes')
else :
    bingo_check()

Submission status: Runtime Error

Solution code:
def bingo_check() :
    if list[0][0] and list [1][1] and list[2][2] in list :
        print('Yes')
    elif list[0][2] and list [1][1] and list[2][0] in list :
        print('Yes')
    else :
        for i in range(3):
            if list[0][i] and list [1][i] and list[2][i] in list :
                ptint('Yes')
            elif list[i][0] and list [i][1] and list[i][2] in list :
                print('Yes')
            else :
                print('No')


a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
N = int(input())

cnt = 0
bingo = [[a, b, c],[d, e, f],[g, h, i]]
list = []

while cnt < N :
    bin = int(input())
    list.append(bin)
    cnt += 1

if cnt == 1 or cnt == 2 :
    print('No')
elif cnt == 7 or cnt == 8 or cnt ==9 :
    print('Yes')
else :
    bingo_check()

Submission status: Runtime Error

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

N = int(input())

b_list = []
for i in range(N):
    b_list.append(int(input()))    
        
for b in b_list:
    if b in a_list:
        a_list[a_list.index(b)] = 0
# 123
# 456
# 789
# とした場合のビンゴラインごとのリスト
line_list = [
    a_list[:3],    # 123
    a_list[3:6],   # 456
    a_list[6:9],   # 789
    a_list[::3],   # 147
    a_list[1::3],  # 258
    a_list[2::3],  # 369
    a_list[::4],   # 159
    a_list[2:7:2], # 357    
]
line_sum_list = list(map(sum, line_list))
if 0 in line_sum_list:
    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)]

key = []
for i, v in enumerate(A):
    for k, j in enumerate(v):
        if (j in B):
            key.append([i, k])

ans = [[[0, 0], [1, 0], [2, 0]], [[0, 1], [1, 1], [2, 1]], [[0, 2], [1, 2], [2, 2]], [[0, 0], [1, 1], [2, 2]], [
    [0, 2], [1, 1], [2, 0]], [[0, 0], [0, 1], [0, 2]], [[1, 0], [1, 1], [1, 2]], [[2, 0], [2, 1], [2, 2]]]

for i in ans:
    for j in i:
        if (j in key.sort()):
            print('Yes')
            exit()

print('No')

Submission status: Runtime Error

Solution code:
A = []

for i in range(3):
    a = list(map(int, input().split()))
    A.append(a)

N = int(input())

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

ans = 'No'

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

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

if check[0][0]+check[1][1]+check[2][2] == 3:
    ans = 'Yes'

if check[0][2]+check[1][1]+check[2][0] == 3:
    ans = 'Yes'

print(ans)

Submission status: Runtime Error

Solution code:
A = []

for i in range(3):
    a = list(map(int, input().split()))
    A.append(a)

N = int(input())

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

ans = 'No'

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

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

if check[0][0]+check[1][1]+check[2][2] == 3:
    ans = 'Yes'

if check[0][2]+check[1][1]+check[2][0] == 3:
    ans = 'Yes'

print(ans)

Submission status: Runtime Error

Solution code:
a = []
for i in range(3):
    a.append(map(int,raw_input().split()))
n = input()
for j in range(n):
    b = input()
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k] = 0

res = 'NO'
for l in range(3):
    if sum(a[l]) == 0:
        res = 'Yes'

nl = []

for m in range(3):
    nl.append(a[m][l])

if sum(nl) == 0:
    res = 'Yes'
if sum([a[0][0],a[1][1],a[2][2]]) == 0:
    res = 'Yes'
if sum([a[2][2], a[1][1], a[2][1]]) == 0:
    res = 'Yes'
print res


a,b = map(int,raw_input().split())

Submission status: Runtime Error

Solution code:
a = []
for i in range(3):
    a.append(map(int,raw_input().split()))
n = input()
for j in range(n):
    b = input()
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k] = 0

res = 'NO'
for l in range(3):
    if sum(a[l]) == 0:
        res = 'Yes'
    else:
        nl = []

        for m in range(3):
            nl.append(a[m][l])

        if sum(nl) == 0:
            res = 'Yes'
if sum([a[0][0],a[1][1],a[2][2]]) == 0:
    res = 'Yes'
if sum([a[2][2], a[1][1], a[3][1]]) == 0:
    res = 'Yes'
print res

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())
for i in range(1,n+1):
  b_i = int(input())
for j in range(1,n+1):
  d = [" " if b_j in s else s for s in a]
  e = [" " if b_j in s else s for s in b]
  f = [" " if b_j in s else s for s in c]
if d[0]==d[1]==d[2] or e[0]==e[1]==e[2] or f[0]==f[1]==f[2] or d[0]==e[0]==f[0] or d[1]==e[1]==f[1] or d[2]==e[2]==f[2] or d[0]==e[1]==f[2] or d[2]==e[1]==f[0]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import numpy as np

A = np.array(list(list(map(int, input().split())) for l in range(3)))
N = int(input())
b = np.array(list(int(input()) for l in range(N)))
bingo = np.zeros((3, 3))
bingo = bingo == 1

for b_i in b:
    hantei = A == b_i
    bingo = np.logical_or(bingo, hantei)

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

if (bingo[0,0] and bingo[1,1] and bingo[2,2]) or (bingo[0,2] and bingo[1,1] and bingo[3,1]):
    print('Yes')
    exit()

print('No')

Submission status: Runtime Error

Solution code:
A=[[int(x) for x in inout().split()]for i in range(3)]
n=int(input())
b=list(map(int,input().split()))
for i in range(3):
    if A[i][0] in b and A[i][1] in b and A[i][2] in b:
        print('Yes')
        exit()
    elif A[0][i] in b and A[1][i] in b and A[2][i] in b:
        print('Yes')
        exit()
if A[0][0] in b and A[1][1] in b and A[2][2] in b:
    print('Yes')
    exit()
if A[2][0] in b and A[1][1] in b and A[0][2] in b:
    print('Yes')
    exit()
print('No')

Submission status: Runtime Error

Solution code:
import sys

A = [[0] * 3 for i in range(3)]

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

N = int(input())
for _ in range(N):
    b = int(input())
    if b in A1:
        for a in [i for i, x in enumerate(A1) if x == b]:
            A[0][a] = 1
    if b in A2:
        for a in [i for i, x in enumerate(A2) if x == b]:
            A[1][a] = 1
    if b in A3:
        for a in [i for i, x in enumerate(A3) if x == b]:
            A[2][a] = 1

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

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

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

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

print('No')

Submission status: Runtime Error

Solution code:
import sys

A = [[0] * 3 for i in range(3)]

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

N = int(input())
for _ in range(N):
    b = int(input())
    if b in A1:
        for a in [i for i, x in enumerate(A1) if x == b]:
            A[0][a] = 1
    if b in A2:
        for a in [i for i, x in enumerate(A2) if x == b]:
            A[1][a] = 1
    if b in A3:
        for a in [i for i, x in enumerate(A3) if x == b]:
            A[2][a] = 1

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

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

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

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

al = a1+a2+a3
n =int(input())

for i in range(n):
    b = int(input())
    if b in al:
        al[al.index()] = 0
if al[0] + al[1] + al[2] == 0 or al[3] + al[4] + al[5] == 0 or al[6] + al[7] + al[8] == 0 or al[0] + al[3] + al[6] == 0 or al[1] + al[4] + al[7] == 0 or al[2] + al[5] + al[8] == 0 or al[0] + al[4] + al[8] == 0 or al[2] + al[4] + al[6] == 0:
    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()))

al = a1+a2+a3
n =int(input())

for i in range(n):
    b = int(input())
    if b in al:
        al[al.index()] = 0
if a1[0] + a1[1] + a1[2] == 0 or a2[0] + a2[1] + a2[2] == 0 or a3[0] + a3[1] + a3[2] == 0 or a1[0] + a2[0] + a3[0] == 0 or a1[1] + a2[1] + a3[1] == 0 or a1[2] + a2[2] + a3[2] == 0 or a1[0] + a2[1] + a3[2] == 0 or a1[2] + a2[1] + a3[0] == 0:
    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()))

c=[a_1,a_2,a_3]

N=int(input())

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

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
            
            
i=0
if a[0][0]==0 and a[0][1]==0 and a[0][2]:
    i+=1
if a[1][0]==0 and a[1][1]==0 and a[1][2]:
    i+=1
if a[2][0]==0 and a[2][1]==0 and a[2][2]:
    i+=1
if a[0][0]==0 and a[1][0]==0 and a[2][0]:
    i+=1
if a[0][1]==0 and a[1][1]==0 and a[2][1]:
    i+=1
if a[0][2]==0 and a[1][2]==0 and a[2][2]:
    i+=1
if a[0][0]==0 and a[1][1]==0 and a[2][2]:
    i+=1
if a[0][2]==0 and a[1][1]==0 and a[2][0]:
    i+=1
    
if i>0:
    print("Yes")
elif i==0:
    print("No")

Submission status: Runtime Error

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

n = int(input())

for i in range(n):
    b = int(input())
    
    for r in range(3):
        for c in range(3):
            if a[r][c] == b:
                a[r][c] = 0

a = np.array(a)
sum1 = a.sum(axis=0)
sum2 = a.sum(axis=1)
naname1 = a[0][0] + a[1][1] + a[2][2]
naname2 = a[0][2] + a[1][1] + a[2][0]

if 0 in sum1 or 0 in sum2 or naname1 == 0 or naname2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
mark = []
for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark.append((j,k))



if ( ((0,0) and (1,1) and (2,2)) or ((0,2) and (1,1) and (2,0)) ) in mark:
    print("Yes")
    exit()
else:
    for i in range(3):
        if ((i,0) and (i,1) and (i,2)) in mark:
            print('Yes')
            exit()
        if ((0,i) and (1,i) and (2,i)) in mark:
            print("Yes")
            exit()

print("No")

Submission status: Runtime Error

Solution code:
d=[list(map(int,input().split()))for i in range(3)]
row=int(input())
num=[int(input()) for j in range(row)]
bingo=0
for a in range(3):
  if d[0][a] and d[1][a] and d[2][a] in num:
    bingo=bingo+1
  elif d[a][0] and d[a][1] and d[a][1] in num:
    bingo=bingo+1
if d[1][1] and d[2][2] and d[3][3] in num:
  bingo=bingo+1
elif d[3][1] and d[2][2] and d[1][3] in num:
  bingo=bingo+1
if bingo>0:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
n , m = map(int,input().split())
dp = [-1 for _ in range(n)]
flag = True 
for _ in range(m):
	i , val =  map(int,input().split())
	if dp[i-1] == -1:
		dp[i-1]=val
	elif dp[i-1]!=val:
		flag = False
		# print(dp[i-1])
		break
if dp[0]==0:
	flag = False
if flag:
	for i in range(n):
		if dp[i]==-1:
			dp[i]=0
	if dp[0]==0:
		dp[0]=1
	for x in dp:
		print(str(x),end="")
else:
	print("-1")

Submission status: Runtime Error

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

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

bingo = []
for t in range(N):
    for i in range(3):
        if b[t] in A[i]:
            j = A[i].index(b[t])
            #bingo.append((i, j))
            A[i][j] = True

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

for j in range(3):
    if A[0][j] == A[1][j] == A[2][j]:
        answer = "Yes"
if A[0][0] == A[1][1] == A[2][2]:
    answer = "Yes"

if A[2][0] == A[1][1] == A[0][2]:
    answer = "Yes"
    

print(answer)

Submission status: Runtime Error

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

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -1
bingo = 0

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -1:
        bingo = 1
        
for j in range(3):
    if a[0][j] == a[1][j] == a[2][j] == -1:
        bingo = 1

if a[0][0] == a[1][1] == a[2][2] == -1 or a[0][2] == a[1][1] == a[2][0]:
    bingo = 1

if bingo == True:
    print('Yes')

else:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
i,j,k,c,z=0,0,0,0,0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]=="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]=="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]=="x":
        c+=1
    if a[z]][0]==a[z][1]==a[z][1s]=="x":
        c+=1
if c!=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())
b=[int(input() for i in range(n))]
flag =False
for i in range(3):
  if all(a[i][j] in b for j in range(3)):
    flag=True
  if all(a[j][i] in b for j in range(3)):
    flag=True
if all(a[j][j] in b for j in range(3)) or all(a[i][2-i] in b for i in range(3)) :
  flag=True
if(flag):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import numpy as np

a = [int(a) for a in input().split()]
b = [int(b) for b in input().split()]
c = [int(c) for c in input().split()]

C = np.array(a + b + c)

N = int(input())
for _ in range(N):
    b = int(input())
    C[C == b] = 0
C = C.reshape([3, 3])
bingo = 0
if 0 in np.sum(C, axis=1):
    bingo = 1
if 0 in np.sum(C, axis=0):
    bingo = 1
if np.sum(np.diag(C)) == 0 or np.sum(np.diag(np.flip(C, axis=1))) == 0:
    bingo = 1
if bingo == 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys

def main():
    a = [list(map(int,input().split())) for _ in range(3)]
    num = int(input())
    b = []
    for i in range(num):
        x = int(input())
        b.append(x)
    
    for i in range(3):
        for j in range(3):
            for n in range(num):
                if a[i][j] == b[n]:
                    a[i][j] = 0
                    break

    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2]:
            flag = 1
        if a[0][i] == a[1][i] == a[2][i]:
            flag = 1
        if i == 0:
            if a[i][0] == a[i+1][1] == a[i+2][2]:
                flag = 1
        elif i == 2:
            if a[i][2] == a[i-1][1] == a[i-2][0]:
                flag = 1

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys

def main():
    a = [list(map(int,input().split())) for _ in range(3)]
    num = int(input())
    b = []
    for i in range(num):
        x = int(input())
        b.append(x)
    
    for i in range(3):
        for j in range(3):
            for n in range(num):
                if a[i][j] == b[n]:
                    a[i][j] = 0
                    break

    j = 0
    """
    for i in range(3):
        if a[i][j] == a[i][j+1] == a[i][j+2]:
            print("Yes")
            sys.exit()
        if a[j][i] == a[j+1][i] == a[j+2][i]:
            print("Yes")
            sys.exit()
        if i == 0:
            if a[i][j] == a[i+1][j+1] == a[i+2][j+2]:
                print("Yes")
                sys.exit()
        elif i == 2:
            if a[i][j+2] == a[i-1][j+1] == a[i-2][j]:
                print("Yes")
                sys.exit()
    print("No")
    """
    for i in range(3):
        if a[i][0]==a[i][1]==a[i][2]:
            flag = 1
    for i in range(3):
        if a[0][i]==a[1][i]==a[2][i]:
            flag = 1
    if a[0][0]==a[1][1]==a[2][2]:
        flag = 1
    if a[2][0]==a[1][1]==a[0][2]:
        flag = 1    
    if flag == 1:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()