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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a1,a2,a3 = map(int, input().split())
a4,a5,a6 = map(int, input().split())
a7,a8,a9 = map(int, input().split())
A = [a1,a2,a3,a4,a5,a6,a7,a8,a9]

n = int(input())
for _ in range(n):
    b = int(input())
    if b in A:
        i = A.index(b)
        A[i] = 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[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: Wrong Answer

Solution code:
numbers = []
numbers.extend(list(map(int, input().split(' '))))
numbers.extend(list(map(int, input().split(' '))))
numbers.extend(list(map(int, input().split(' '))))
N = int(input())
answers = set()
for _ in range(N):
    answers.add(int(input()))

results = [False] * 9

for i in range(len(numbers)):
    if numbers[i] in answers:
        results[i] = True

if all(results[0:3]) or all(results[3:6]) or all(results[6:9]):
    print('Yes')
elif all(results[0::3]) or all(results[3::3]) or all(results[6::3]):
    print('Yes')
elif all((results[0], results[4], results[8])) or all((results[2], results[4], results[6])):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
print(A)
print(N)
print(B)
for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                A[j][k] = 0
#print(A)
for i in range(3):
    if (A[i][0] == A[i][1] == A[i][2] == 0):
        print("Yes")
        exit()
    if (A[0][i] == A[1][i] == A[2][i] == 0):
        print("Yes")
        exit()
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()
print("No")

Submission status: Wrong Answer

Solution code:

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
print(A)
print(N)
print(B)
for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                A[j][k] = 0
print(A)
for i in range(3):
    if (A[i][0] == A[i][1] == A[i][2] == 0):
        print("Yes")
        exit()
    if (A[0][i] == A[1][i] == A[2][i] == 0):
        print("Yes")
        exit()
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()
print("No")

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]

con1 = A1[0] in B and A1[1] in B and A1[2] in B
con2 = A2[0]in B and A2[1]in B and A2[2]
con3 = A3[0]in B and A3[1]in B and A3[2]
con4 = A1[0]in B and A2[0]in B and A3[0]
con5 = A1[1]in B and A2[1]in B and A3[1]
con6 = A1[2]in B and A2[2]in B and A3[2]
con7 = A1[0]in B and A2[1]in B and A3[2]
con8 = A1[2]in B and A2[1]in B and A3[0]


if (con1 or con2 or con3 or con4 or con5 or con6 or con7 or con8):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]

con1 = A1[0] in B and A1[1] in B and A1[2] in B
con2 = A2[0]in B and A2[1]in B and A2[2]
con3 = A3[0]in B and A3[1]in B and A3[2]
con4 = A1[0]in B and A2[0]in B and A3[0]
con5 = A1[1]in B and A2[1]in B and A3[1]
con6 = A1[2]in B and A2[2]in B and A3[2]
con7 = A1[0]in B and A2[1]in B and A3[2]
con8 = A1[2]in B and A2[1]in B and A3[0]


if (con1 or con2 or con3 or con4 or con5 or con6 or con7 or con8) in B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
con1 = A1[0] and A1[1] and A1[2]
con2 = A2[0] and A2[1] and A2[2]
con3 = A3[0] and A3[1] and A3[2]
con4 = A1[0] and A2[0] and A3[0]
con5 = A1[1] and A2[1] and A3[1]
con6 = A1[2] and A2[2] and A3[2]
con7 = A1[0] and A2[1] and A3[2]
con8 = A1[2] and A2[1] and A3[0]
if (con1 or con2 or con3 or con4 or con5 or con6 or con7 or con8) in B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

neko = 0
nya = 0
nuko = 0
a = [] 
x = [[0] * 3 for i in range(3)]
for i in range(3):
    a.append([int(x) for x in input().split()])
n = iin()
b = [0] * n
for i in range(n):
    b[i] = iin()

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

Submission status: Wrong Answer

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

neko = 0
nya = 0
nuko = 0
a = [] 
x = [[0] * 3] * 3
for i in range(3):
    a.append([int(x) for x in input().split()])
n = iin()
b = [0] * n
for i in range(n):
    b[i] = iin()

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

Submission status: Wrong Answer

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

neko = 0
nya = 0
nuko = 0
a = [] 
x = [[0] * 3] * 3
for i in range(3):
    a.append([int(x) for x in input().split()])
n = iin()
b = [0] * n
for i in range(n):
    b[i] = iin()

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

Submission status: Wrong Answer

Solution code:
import numpy as np

a = [list(map(int, input().split())) for _ in range(3)]
a = np.array(a)
n = int(input())

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

at = a.transpose()
flag = True
for i in range(3):
    if sum(a[:][i]) == 0 or sum(at[:][i]) == 0:
        flag = True
        break
diag = a[0][0] + a[1][1] + a[2][2]
diag2 = a[2][0] + a[1][1] + a[0][2]
if diag == 0 or diag2 == 0:
    flag = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np

a = [list(map(int, input().split())) for _ in range(3)]
a = np.array(a)
n = int(input())

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

at = a.transpose()
flag = True
for i in range(3):
    if sum(a[:][i]) == 0 or sum(at[:][i] == 0):
        flag = True
        break
diag = a[0][0] + a[1][1] + a[2][2]
diag2 = a[2][0] + a[1][1] + a[0][2]
if diag == 0 or diag2 == 0:
    flag = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np

a = [list(map(int, input().split())) for _ in range(3)]
a = np.array(a)
n = int(input())

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

at = a.transpose()
flag = True
for i in range(3):
    if sum(a[:][i]) == 0 or sum(at[:][i] == 0):
        flag = True
        break
diag = a[0][0] + a[1][1] + a[2][2]
diag2 = a[2][0] + a[1][1] + a[0][2]
if diag == 0 or diag2 == 0:
    flag = True

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

Submission status: Wrong Answer

Solution code:
B = {}
for i in range(3):
    for j, e in enumerate(input().split()):
        B[e] = (i, j)

L = []
for i in range(8):
    L.append(0)
        
N = int(input())
for i in range(N):
    b = input()
    if b in B:
        L[B[b][0] % 3] += 1
        L[(B[b][0] * 3 + B[b][1]) % 3 + 3] += 1
        if B[b][0] == B[b][1]:
            L[6] += 1
        elif abs(B[b][0] - B[b][1]) == 2:
            L[7] += 1
if 3 in L:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for i in range(N):
    B = input()
    for k in range(3):
        for m in range(3):
            if A[k][m] == B:
                A[k][m] = '-1'


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

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

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

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

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

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

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

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

print('No')

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

ans = 0
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == 0:
        ans = 1
if [0, 0, 0] in a:
    ans = 1
if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = 1

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    A = [list(map(int, input().split()))for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for bn in B:
        for i in range(len(A)):
            for j in range(len(A[i])):
                if bn == A[i][j]:
                    A[i][j] = 0
    for m in range(len(A)):
        if all(A[m][n] == 0 for n in range(len(A))):
            print("Yes")
            exit()
        if all(A[n][m] == 0 for n in range(len(A))):
            print("Yes")
            exit()
        if all(A[n][n] == 0 for n in range(len(A))):
            print("Yes")
            exit()
    print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A = [input().split() for _ in range(3)]
N = int(input())
B = [input() for _ in range(N)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j] == b:
                A[i][j] = '○'
ans = 'No'
for i in range(3):
    if A[i][0] == '○' and A[i][1] == '○' and A[i][2] == '○':
        ans = 'Yes'
    if A[0][i] == '○' and A[1][i] == '○' and A[1][i] == '○':
        ans = 'Yes'
    if A[0][0] == '○' and A[1][1] == '○' and A[2][2] == '○':
        ans = 'Yes'
    if A[0][2] == '○' and A[1][1] == '○' and A[2][0] == '○':
        ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
A = [input().split() for _ in range(3)]
N = int(input())
B = [input() for _ in range(N)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j] == b:
                A[i][j] = '○'
ans = 'No'
for i in range(3):
    if (A[i][0] == '○' and A[i][1] == '○' and A[i][2] == '○') or (A[0][i] == '○' and A[1][i] == '○' and A[1][i] == '○'):
        ans = 'Yes'
if A[0][0] == '○' and A[1][1] == '○' and A[2][2] == '○':
    ans = 'Yes'
if A[0][2] == '○' and A[1][1] == '○' and A[2][0] == '○':
    ans = 'Yes'  
print(ans)

Submission status: Wrong Answer

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])

for pn in pickup_number:
    a[a == pn] = -1

flag = False
if np.sum(a, axis=0).any() == -3 or np.sum(a, axis=1).any() == -3:
    flag = True
if np.sum(a.diagonal()) == -3 or a[0][2] + a[1][1] + a[2][0] == -3:
    flag = True

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

Submission status: Wrong Answer

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])

for pn in pickup_number:
    a[a == pn] = -1

flag = False
if np.sum(a, axis=0)[0] == -3 or np.sum(a, axis=1)[0] == -3:
    flag = True
if np.sum(a.diagonal()) == -3 or a[0][2] + a[1][1] + a[2][0] == -3:
    flag = True

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

Submission status: Wrong Answer

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])
print(pickup_number)
print(a)

for pn in pickup_number:
    a[a == pn] = -1

print(a)

flag = False
if np.sum(a, axis=0)[0] == -3 or np.sum(a, axis=1)[0] == -3:
    flag = True
if np.sum(a.diagonal()) == -3 or np.sum(a[0][2] + a[1][1] + a[2][0]) == -3:
    flag = True

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

Submission status: Wrong Answer

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])
print(pickup_number)
print(a)

for pn in pickup_number:
    a[a == pn] = -1

print(a)

flag = False
if np.sum(a, axis=0)[0] == -3 or np.sum(a, axis=1)[0] == -3:
    flag = True
if np.sum(a.diagonal()) == -3 or np.sum(a[0][2] + a[1][1] + a[2][2]) == -3:
    flag = True

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

Submission status: Wrong Answer

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])

for pn in pickup_number:
    a[a == pn] = -1

flag = False
if np.sum(a, axis=0)[0] == -3 or np.sum(a, axis=1)[0] == -3:
    flag = True
if np.sum(a.diagonal()) == -3 or np.sum(a[0][2] + a[1][1] + a[0][2]) == -3:
    flag = True

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

Submission status: Wrong Answer

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


for x in number_list:
    for i in range(3):
        for j in range(3):
           if  Ai_j[i][j] == x:
               Ai_j[i][j] = '○'


count = 0

if Ai_j[0][0] == Ai_j[0][2] == Ai_j[0][1] == '○': count+=1
if Ai_j[1][0] == Ai_j[1][2] == Ai_j[1][1] == '○': count+=1
if Ai_j[2][0] == Ai_j[2][2] == Ai_j[2][1] == '○': count+=1
if Ai_j[0][0] == Ai_j[1][0] == Ai_j[2][0] == '○': count+=1
if Ai_j[0][1] == Ai_j[1][1] == Ai_j[2][1] == '○': count+=1
if Ai_j[0][2] == Ai_j[1][2] == Ai_j[2][2] == '○': count+=1
if Ai_j[0][0] == Ai_j[1][1] == Ai_j[2][2] == '○': count+=1
if Ai_j[0][2] == Ai_j[1][1] == Ai_j[2][0] == '○': count+=1

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
a_list = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
 
for _ in range(n):
    b = int(input())
    
    for a in a_list:
        for idx, aa in enumerate(a):
            if aa == b:
                a[idx] = 0

# 縦横対角
for i in range(3):
    if list(a_list[i, :]) == [0, 0, 0] or list(a_list[:, i]) == [0, 0, 0]:
        print("Yes")
        sys.exit()
    

# 斜め
if ([a_list[i, i] for i in range(3)] == [0, 0, 0]) or ([a_list[0, 2], a_list[1, 1], a_list[2, 1]] == [0, 0, 0]):
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
a_list = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
 
for _ in range(n):
    b = int(input())
    
    for a in a_list:
        for idx, aa in enumerate(a):
            if aa == b:
                a[idx] = 0

# 縦横対角
for i in range(3):
    if (a_list[i, :] == [0, 0, 0]).any() or (a_list[:, i] == [0, 0, 0]).any():
        print("Yes")
        sys.exit()
    

# 斜め
if ([a_list[i, i] for i in range(3)] == [0, 0, 0]) or ([a_list[0, 2], a_list[1, 1], a_list[2, 1]] == [0, 0, 0]):
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
a =[list(map(int, input().split())) for i in range(3)] 
n = int(input())
for i in range(n):
	b = int(input())
	for j in range(3):
		for k in range(3):
			if a[j][k] == b:
				a[j][k] = 0
				
ans = 'No'
for i in range(3):
	if a[i][0] == a[i][1] == a[i][0] == 0: ans = 'Yes'
	if a[0][i] == a[0][i] == a[0][i] == 0: ans = 'Yes'
if a[0][0] == a[1][1] == a[2][2] == 0: ans = 'Yes'
if a[0][2] == a[1][1] == a[2][0] == 0: ans = 'Yes'
	
print(ans)

Submission status: Wrong Answer

Solution code:
a = [0]*3

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

n = int(n)
b_ = [0]*n
for i in range(0,n):
  b_[i] = input()
 
b = [int(i) for i in b_]

for i in range(0,3):
  for j in range(0,3):
    if(a[i][j] in b):
      a[i][j] = 10000
    else:
      continue

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

Submission status: Wrong Answer

Solution code:
a = [0]*3

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

n = int(n)
b_ = [0]*n
for i in range(0,n):
  b_[i] = input()
 
b = [int(i) for i in b_]

for i in range(0,3):
  for j in range(0,3):
    if(a[i][j] in b):
      a[i][j] = 1000
    else:
      continue

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

Submission status: Wrong Answer

Solution code:
a = [0]*3

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

n = int(n)
b_ = [0]*n
for i in range(0,n):
  b_[i] = input()
 
b = [int(i) for i in b_]

for i in range(0,3):
  for j in range(0,3):
    if(a[i][j] in b):
      a[i][j] = 1000
    else:
      continue

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

Submission status: Wrong Answer

Solution code:
card = [list(map(int,input().split())) for c in range(3)]
N = int(input())
nums = [int(input()) for n in range(N)]
tmp = []
ans =0
for index,c in enumerate(card):
	for index2,c2 in enumerate(c):
		for n in nums:
			if n == c2:
				tmp.append([index,index2])
ind = [[False,False,False],[False,False,False],[False,False,False]]
for t in tmp:
	ind[t[0]][t[1]] = True
if ind[0][0] == True and ind[1][1] == True and ind[2][2] == True or \
	ind[0][2] == True and ind[1][1] == True and ind[2][0] == True:
	ans += 1
    
if all([i == True for i in ind]):
	ans += 1
if any([i == True for i in ind]):
	list1 = []
	for i in ind:
		list1.append(i.index(True))
        
	if list1 == [0,0,0] or list1 == [1,1,1] or list1 == [2,2,2]:
		ans += 1
if ans >= 1:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().split())) for i in range(3)]
n=int(input())
B=[int(input()) for i in range(n)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=0
ans='No'
for i in range(3):
    if A[i].count(0)==3:
        ans='Yes'
for i in range(3):
    temp=[A[i][0],A[i][1],A[i][2]]
    if temp.count(0)==3:
        ans='Yes'
if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    ans='Yes'
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    ans='Yes'
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

a = [list(map(int, input().split())) for _ in range(3)]
marked = [[False, False, False] for _ in range(3)]

Q = int(input())
for i in range(Q):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                marked[j][k] = True

print(marked)

for i in range(3):
    if marked[i][0] == marked[i][1] == marked[i][2] == True:
        print("Yes")
        exit()
    if marked[0][i] == marked[1][i] == marked[2][i] == True:
        print("Yes")
        exit()
if marked[0][0] == marked[1][1] == marked[2][2] == True:
    print("Yes")
    exit()
if marked[0][2] == marked[1][1] == marked[2][0] == True:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

bingo = []
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
#print(a)
for i in range(3):
    for j in range(3):
        if a[i][j] == 0 and a[i][j] == 0 and a[i][j] == 0 :
            print("Yes")
            exit()
        elif a[j][i] == 0 and a[j][i] == 0 and a[j][i] == 0 :
            print("Yes")
            exit()
        elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
            print("Yes")
            exit()
        elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
            print("Yes")
            exit()
    else:
        print("No")
        exit()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
A = list()
for i in range(3):
  A += list(map(int, input().split()))
  
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(len(A)):
    if A[j] == b:
      A[j] = 0

for i in range(3):
  if A[3*i:3*i+3] == [0, 0, 0]:
    print('Yes')
    exit()
  elif [A[i], A[i+3], A[i+6]] == [0, 0, 0]:
    print('Yes')
    exit()
  elif [A[0], A[4], A[8]] == [0, 0, 0] or [A[2], A[4], A[6]] == [0, 0, 0]:
    print('Yes')
    exit()
  else:
    print('No')
    exit()

Submission status: Wrong Answer

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


for _ in range(N):
    B = int(input())
    for i in range(3):
      for j in range(3):
          if A[i][j] == B:
              A[i][j] == 0
        
bingo = False
for row in A:
  if sum(row) == 0:
    bingo = True
for col in zip(*A):
  if sum(col) == 0:
    bingo= True
if sum(A[i][i] for i in range(3) )== 0:
  bingo =True
if sum(A[i][3 - i - 1] for i in range(3)) == 0:
  bingo = True
  
print("Yes" if bingo == True else "No")

Submission status: Wrong Answer

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