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

for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      A[i][j] = 0
  
for i in range(3):
  if A[i][0] + A[i][1] + A[i][2] == 0 or A[0][i] + A[1][i] + A[2][i] == 0 or A[0][0]+A[1][1]+A[2][2] ==0 or A[2][0]+A[1][1]+A[0][2] ==0:
    print('Yes')
    break
  
  else:
    print('No')
    break

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

l = [[(a_i in B) for a_i in a] for a in A]

# print(l)

flag = 0
for y in range(3):
    flag |= all(l[y])

for x in range(3):
    flag |= all([l[x][y] for y in range(3)])

flag |= all([l[y][x] for x, y in [(0, 0), (1, 1), (2, 2)]])

flag |= all([l[y][x] for x, y in [(0, 2), (1, 1), (2, 0)]])

print("Yes" if flag else "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)]

l = [[(a_i in B) for a_i in a] for a in A]

flag = 0
for y in range(3):
    flag |= all(l[y])

for x in range(3):
    flag |= all(l[x][y] for y in range(3))

flag |= all([l[y][x] for x, y in [(0, 0), (1, 1), (2, 2)]])

flag |= all([l[y][x] for x, y in [(0, 2), (1, 1), (2, 0)]])

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

Submission status: Wrong Answer

Solution code:
A = []
B = []
cnt = 0

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

N = int(input())

for i in range(N):
    B.append(int(input()))

for i in range(3):
    for j in range(3):
        for k in B:
            if A[i][j] == k:
                A[i][j] = 0
import sys
for i in range(3):            
    if A[i][0]==0 and A[i][0]==A[i][1] and A[i][1]==A[i][2]:
        print('Yes')
        sys.exit()
    elif A[0][i]==0 and A[0][i]==A[1][i] and A[1][i]==A[2][i]:
        print('Yes')
        sys.exit()
    elif A[0][0]==0 and A[0][0]==A[1][1] and A[1][1]==A[2][2]:
        print('Yes')
        sys.exit()
    elif A[0][2]==0 and A[0][2]==A[1][1] and A[1][1]==A[2][0]:
        print('Yes')
        sys.exit()
    else:
        print('No')
        sys.exit()

Submission status: Wrong Answer

Solution code:
A = []
B = []
cnt = 0

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

N = int(input())

for i in range(N):
    B.append(int(input()))

for i in range(3):
    for j in range(3):
        for k in B:
            if A[i][j] == k:
                A[i][j] = 0

for i in range(3):            
    if A[i][0]==0 and A[i][0]==A[i][1] and A[i][1]==A[i][2]:
        print('Yes')
    
    elif A[0][i]==0 and A[0][i]==A[1][i] and A[1][i]==A[2][i]:
        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[1][1]==A[2][0]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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


if A[0] and B[0] and C[0] in b:
    print("Yes")
    exit()

if A[1] and B[1] and C[1] in b:
    print("Yes")
    exit()

if A[2] and B[2] and C[2] in b:
    print("Yes")
    exit()

if A[0] and A[1] and A[2] in b:
    print("Yes")
    exit()

if B[0] and B[1] and B[2] in b:
    print("Yes")
    exit()

if C[0] and C[1] and C[2] in b:
    print("Yes")
    exit()

if A[0] and B[1] and C[2] in b:
    print("Yes")
    exit()

if C[0] and B[1] and A[2] in b:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

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

for x in range(0,3):
    if A[x] and B[x] and C[x] in b:
        print("Yes")
        exit()

if A[0] and A[1] and A[2] in b:
    print("Yes")
    exit()

if B[0] and B[1] and B[2] in b:
    print("Yes")
    exit()

if C[0] and C[1] and C[2] in b:
    print("Yes")
    exit()

if A[0] and B[1] and C[2] in b:
    print("Yes")
    exit()

if C[0] and B[1] and A[2] in b:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

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

binge=[[False]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if L[i][j] in B:
            binge[i][j]=True

if any(sum(binge[i])==3 for  i in range(3)) or any(sum([binge[i][j] for i in range(3)])==3 for i in range(3)) or sum([binge[i][i]==3 for i in range(3)])==3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
li=[]
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
n=int(input())
for i in range(n):
  j=int(input())
  li.append(j)
bingo=0
yoko1=a and b and c in li
yoko2=d and e and f in li
yoko3=g and h and i in li
yoko=yoko1 or yoko2 or yoko3
tate1=a and d and g in li
tate2=b and e and h in li
tate3=c and f and i in li
tate=tate1 or tate2 or tate3
nana1=a and e and i in li
nana2=c and e and g in li
nana=nana1 or nana2
if yoko or tate or nana:
    bingo=1
print("Yes" if bingo==1 else "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 j in range(n)]
for j in range(n):
  for i in range(3):
    for k in range(3):
      if b[j] == a[i][k]:
        a[i][k]=0
x="yet"
n=0
for i in range(3):
  if a[i][i]==0:
    n+=1
if n==3:
  print("Yes")
  x="done"  

if x=="yet":
  for i in range(3):
    if a[2-i][i]==0:
      n+=1
  if n==3:
    print("Yes")
    x="done"
    
if x=="yet":
  for i in range(3): 
    for k in range(3):  
      if a[i][k]==0:
        n+=1
    if n==3:
      print("Yes")
      x="done"
      break

if x=="yet":
  for k in range(3): 
    for i in range(3):  
      if a[i][k]==0:
        n+=1
    if n==3:
      print("Yes")
      x="done"
      break
if x=="yet":
      print("No")

Submission status: Wrong Answer

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

tate = [[(i,j) for i in range(3)] for j in range(3)]
naname = [[(i,i) for i in range(3)], [(i,2 - i) for i in range(3)]]

atari = set()
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            atari.add((i, j))

if len(atari) < 3:
    print('No')
else:        
    for i in range(3):
        if (a[i][0] in atari and a[i][1] in atari and a[i][2] in atari) or (tate[i][0] in atari and tate[i][1] in atari and tate[i][2] in atari):
            print('Yes')
            exit()
    
    for i in range(2):
        if naname[i][0] in atari and naname[i][1] in atari and naname[i][2] in atari:
            print('Yes')
            exit()
    
    print('No')

Submission status: Wrong Answer

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]:
            print("Yes")
            sys.exit()
        if a[0][i] == a[1][i] == a[2][i]:
            print("Yes")
            sys.exit()
        if i == 0:
            if a[i][0] == a[i+1][1] == a[i+2][2]:
                print("Yes")
                sys.exit()
        elif i == 2:
            if a[i][2] == a[i-1][1] == a[i-2][0]:
                print("Yes")
                sys.exit()
    print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(3):
  n=0  
  for k in range(3):  
      if a[i][k]==0:
        n+=1
  if n==3:
    print("Yes")
    break
if n==0:
  for k in range(3):
    n=0  
    for i in range(3):  
      if a[i][k]==0:
        n+=1
    if n==3:
      print("Yes")
      break
if n==0:
  for i in range(3):  
      if a[i][i]==0:
        n+=1
  if n==3:
    print("Yes")
    
      
  if n==0:
    for i in range(3):
      if a[2-i][i]==0:
        n+=1
    if n==3:
      print("Yes")
    elif n==0:
      print("No")

Submission status: Wrong Answer

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[list(map(int,input().split())) for _ in range(n)]
marked=[]
for i in range(3):
  for j in range(3):
    for k in range(n):
      if b[k]==a[i][j]:
        marked.append(a[i][j])
      if a[0][0] in marked and a[0][1] in marked and a[0][2] in marked:
        print('Yes')
      elif a[1][0] in marked and a[1][1] in marked and a[1][2] in marked:
        print('Yes')
      elif a[2][0] in marked and a[2][1] in marked and a[2][2] in marked:
        print('Yes')
      elif a[0][0] in marked and a[1][0] in marked and a[2][0] in marked:
        print('Yes')
      elif a[0][1] in marked and a[1][1] in marked and a[2][1] in marked:
        print('Yes')
      elif a[0][2] in marked and a[1][2] in marked and a[2][2] in marked:
        print('Yes')
      elif a[0][0] in marked and a[1][1] in marked and a[2][2] in marked:
        print('Yes')
      elif a[0][2] in marked and a[1][1] in marked and a[2][0] in marked:
        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=[0]*n
for i in range(n):
    b[i]=int(input())
for i in range(n):
    for j in range(3):
        if a1[j]==b[i]:
            a1[j]=-1
        if a2[j]==b[i]:
            a2[j]=-1
        if a3[j]==b[i]:
            a3[j]=-1
if sum(a1)==-3 \
    or sum(a2)==-3 \
    or sum(a3)==-3 \
    or (a1[0],a2[0],a3[0])==(-1,-1,-1) \
    or (a1[1],a2[1],a3[1])==(-1,-1,-1) \
    or (a1[2],a2[2],a3[2])==(-1,-1,-1) \
    or (a1[0], a2[1], a3[2]) == (-1, -1, -1) \
    or (a1[2], a2[2], a3[0]) == (-1, -1, -1) :
    print("Yes")

else:
    print("No")
    #print(a1)
    #print(a2)
    #print(a3)

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 = []
for i in range(n):
    x = int(input())
    b.append(x)


for i in b:
    if i in a1:
        a1[a1.index(i)] = 'X'
    if i in a2:
        a2[a2.index(i)] = 'X'
    if i in a3:
        a3[a3.index(i)] = 'X'

if len(set(a1)) == 1 and a1[0] == 'X' or len(set(a2)) == 1 and a2[0] == 'X' or len(set(a3)) == 1 and a3[0] == 'X':
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[0] == a3[0] or a1[1] == 'X' and a1[1] == a2[1] == a3[1] or a1[2] == 'X' and a1[2] == a2[2] == a3[2]:
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[1] == a3[2] or a1[2] == 'X' and a1[2] == a2[1] == a1[0]:
    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 = []
for i in range(n):
    x = int(input())
    b.append(x)


for i in b:
    if i in a1:
        a1[a1.index(i)] = 'X'
    if i in a2:
        a2[a2.index(i)] = 'X'
    if i in a3:
        a3[a3.index(i)] = 'X'

if len(set(a1)) == 1 and a1[0] == 'X' or len(set(a2)) == 1 and a2[0] == 'X' or len(set(a2)) == 1 and a2[0] == 'X':
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[0] == a3[0] or a1[1] == 'X' and a1[1] == a2[1] == a3[1] or a1[2] == 'X' and a1[2] == a2[2] == a3[2]:
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[1] == a3[2] or a1[2] == 'X' and a1[2] == a2[1] == a1[0]:
    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 = []
for i in range(n):
    x = int(input())
    b.append(x)


for i in b:
    if i in a1:
        a1[a1.index(i)] = 'X'
    if i in a2:
        a2[a2.index(i)] = 'X'
    if i in a3:
        a3[a3.index(i)] = 'X'

if len(set(a1)) == 1 and a1[0] == 'X' or len(set(a2)) == 1 and a2[0] == 'X' and len(set(a2)) == 1 and a2[0] == 'X':
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[0] == a3[0] or a1[1] == 'X' and a1[1] == a2[1] == a3[1] or a1[2] == 'X' and a1[2] == a2[2] == a3[2]:
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[1] == a3[2] or a1[2] == 'X' and a1[2] == a2[1] == a1[0]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

  data_map = []
  for _ in range(3):
    data_map.append([0, 0, 0])

  for _ in range(n):
    x = int(input())
    if x == data[0][0]:
      data_map[0][0] = 1
    if x == data[0][1]:
      data_map[0][1] = 1
    if x == data[0][2]:
      data_map[0][2] = 1
    if x == data[1][0]:
      data_map[1][0] = 1
    if x == data[1][1]:
      data_map[1][1] = 1
    if x == data[1][2]:
      data_map[1][2] = 1
    if x == data[2][0]:
      data_map[2][0] = 1
    if x == data[2][1]:
      data_map[2][1] = 1
    if x == data[2][2]:
      data_map[2][2] = 1

  # for i in range(3):
  #   print(*data_map[i])

  # 横
  if sum(data_map[0]) == 3 or sum(data_map[1]) == 3 or sum(data_map[0]) == 3:
    print("Yes")
    return
  
  # ななめ(左->右)
  if data_map[0][0] + data_map[1][1] + data_map[2][2] == 3:
    print("Yes")
    return

  # ななめ(右->左)
  if data_map[0][2] + data_map[1][1] + data_map[2][0] == 3:
    print("Yes")
    return

  # 縦
  if data_map[0][0] + data_map[1][0] + data_map[2][0] == 3:
    print("Yes")
    return
  if data_map[0][1] + data_map[1][1] + data_map[2][1] == 3:
    print("Yes")
    return
  if data_map[0][2] + data_map[1][2] + data_map[2][2] == 3:
    print("Yes")
    return

  print("No")

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

  data_map = []
  for _ in range(3):
    data_map.append([0, 0, 0])

  for _ in range(n):
    x = int(input())
    if x == data[0][0]:
      data_map[0][0] = 1
    if x == data[0][1]:
      data_map[0][1] = 1
    if x == data[0][2]:
      data_map[0][2] = 1
    if x == data[1][0]:
      data_map[1][0] = 1
    if x == data[1][1]:
      data_map[1][1] = 1
    if x == data[1][2]:
      data_map[1][2] = 1
    if x == data[2][0]:
      data_map[2][0] = 1
    if x == data[2][1]:
      data_map[2][1] = 1
    if x == data[2][2]:
      data_map[2][2] = 1

  for i in range(3):
    print(*data_map[i])

  # 横
  if sum(data_map[0]) == 3 or sum(data_map[1]) == 3 or sum(data_map[0]) == 3:
    print("Yes")
    return
  
  # ななめ(左->右)
  if data_map[0][0] + data_map[1][1] + data_map[2][2] == 3:
    print("Yes")
    return

  # ななめ(右->左)
  if data_map[0][2] + data_map[1][1] + data_map[2][0] == 3:
    print("Yes")
    return

  # 縦
  if data_map[0][0] + data_map[1][0] + data_map[2][0] == 3:
    print("Yes")
    return
  if data_map[0][1] + data_map[1][1] + data_map[2][1] == 3:
    print("Yes")
    return
  if data_map[0][2] + data_map[1][2] + data_map[2][2] == 3:
    print("Yes")
    return

  print("No")

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

for i in range(0,N-1):
    for j in range(9):
        if B[i] ==  A[j]:
            A[j] = 0

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

Submission status: 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(b)
for i in range(3):
  for j in range(3):
    for k in range(n):
      if b[k]==a[i][j]:
        a[i][j]=0
print(a)
if (a[0][0]==0 and a[1][0]==0 and a[2][0]==0) or (a[0][1]==0 and a[1][1]==0 and a[2][1]==0) or (a[0][2]==0 and a[1][2]==0 and a[2][2]==0) or a[0]==[0,0,0] or a[1]==[0,0,0] or a[2]==[0,0,0] or (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) or (a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: 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())

for i in range(N):
    b = int(input())
    if b in A1:
        A1[A1.index(b)] = 0
    elif b in A2:
        A2[A2.index(b)] = 0
    elif b in A3:
        A3[A3.index(b)] = 0

if all([x == 0 for x in A1]):
    print('Yes')
    exit()
if all([y == 0 for y in A2]):
    print('Yes')
    exit()
if all([z == 0 for z in A3]):
    print('Yes')
    exit()

for t in range(2):
    if A1[t] == A2[t] == A3[t]:
        print('Yes')
        exit()

if A1[0] == A2[1] == A3[2]:
    print('Yes')
    exit()

if A1[2] == A2[1] == A3[0] == 0:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
bingo = []
b = []

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

n = int(input())

while True:
  try:
    b.append(int(input()))
  except EOFError:
    break

lis1 = [bingo[0][0],bingo[0][1],bingo[0][2]]
lis2 = [bingo[1][0],bingo[1][1],bingo[1][2]]
lis3 = [bingo[2][0],bingo[2][1],bingo[2][2]]

lis4 = [bingo[0][0],bingo[1][0],bingo[2][0]]
lis5 = [bingo[0][1],bingo[1][1],bingo[2][1]]
lis6 = [bingo[0][2],bingo[1][2],bingo[2][2]]

lis7 = [bingo[0][0],bingo[1][1],bingo[2][2]]
lis8 = [bingo[0][2],bingo[1][1],bingo[2][0]]

allList = [lis1,lis2,lis3,lis4,lis5,lis6,lis7,lis8]

print(allList)
for i in allList:
  cnt = 0
  for _ in range(3):
    if i[_] in b:
      cnt +=1
  if cnt ==3:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
b = []

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

n = int(input())

while True:
  try:
    b.append(int(input()))
  except EOFError:
    break

lis1 = [bingo[0][0],bingo[0][1],bingo[0][2]]
lis2 = [bingo[1][0],bingo[1][1],bingo[1][2]]
lis3 = [bingo[2][0],bingo[2][1],bingo[2][2]]

lis4 = [bingo[0][0],bingo[1][0],bingo[2][0]]
lis5 = [bingo[0][1],bingo[1][1],bingo[2][1]]
lis6 = [bingo[0][2],bingo[1][2],bingo[2][2]]

lis7 = [bingo[0][0],bingo[1][1],bingo[2][2]]
lis8 = [bingo[2][2],bingo[1][1],bingo[0][0]]

allList = [lis1,lis2,lis3,lis4,lis5,lis6,lis7,lis8]

for i in allList:
  cnt = 0
  for _ in range(3):
    if i[_] in b:
      cnt +=1
  if cnt ==3:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

for i in range(N):
    b=int(input())
    
    for x in range(3):
        for y in range(3):
            if A[x][y]==b:
                S[x][y]=1

flag=False
for i in range(3):
    if S[i]==[1,1,1]:
        flag=True

for i in range(3):
    s=[]
    for k in range(3):
        s.append(S[i][k])
    if s==[1,1,1]:
        flag=True

s=[]
for i in range(3):
    s.append(S[i][i])

if s==[1,1,1]:
    flag=True
        
s=[]
for i in range(3):
    s.append(S[i][2-i])

if s==[1,1,1]:
    flag=True

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

Submission status: Wrong Answer

Solution code:
li=[]
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
n=int(input())
for i in range(n):
  j=int(input())
  li.append(j)
bingo=0
if (a and b and c) or (d and e and f) or (g and h and i) in li:
    bingo=1
if (a and d and g) or (b and e and h) or (c and f and i) in li:
    bingo=1
if (a and e and i) or (c and e and g) in li:
    bingo=1
print("Yes" if bingo==1 else "No")

Submission status: Wrong Answer

Solution code:
a_list = [input().split(" "),input().split(" "),input().split(" ")]
N = int(input())
for i in range(N):
    b = input()
    for j in range(3):
        for k in range(3):
            if a_list[j][k] == b:
                a_list[j][k] = ""
bingo = False
if a_list[0][0] =="" and  a_list[1][1] =="" and  a_list[2][2] == "":
    bingo = True
for i in range(3):
    if a_list[i][0] == "" and a_list[i][1] == "" and a_list[i][2] == "":
        bingo = True
    elif a_list[0][i] == "" and a_list[1][i] == "" and a_list[2][i] == "":
        bingo = True
if bingo:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
a_list=[]
for i in range(3):
  tmp=list(map(int,input().split()))
  a_list.append(tmp)
a_list=np.array(a_list)
num=int(input())
for i in range(num):
  tmp=int(input())
  a_list[a_list==tmp]=-1
  
yes_no=False
for i in range(3):
  if sum(a_list[i])==-3:
    yes_no=True
    break
  tmp=0
  for j in range(3):
    tmp+=a_list[i][j]
  if tmp==-3:
    yes_no=True
    break
else:
  yes_no=False
tmp=0
tmp2=0
for i in range(3):
  tmp+=a_list[i][i]
  tmp2+=a_list[i][2-i]
if tmp==-3 or tmp2==-3:
  yes_no=True

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

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input=sys.stdin.readline
    mod=10*9+7
    a=[list(map(int,input().rstrip("\n").split())) for _ in range(3)]
    n= int(input().rstrip("\n"))
    for _ in range(n):
        b= int(input().rstrip("\n"))
        for i in range(3):
            for j in range(3):
                if a[i][j]==b:
                    a[i][j]=-1
    
    for i in range(3):
        if a[i][0]==a[i][1]==a[i][2]==-1:
            print("Yes")
        elif a[0][i]==a[1][i]==a[2][i]==-1:
            print("Yes")
    if a[0][0]==a[1][1]==a[2][2]==-1:
        print("Yes")
        exit()
    elif a[0][2]==a[1][1]==a[2][0]==-1:
        print("Yes")
        exit()
    print("No")

Submission status: Wrong Answer

Solution code:
def myAnswer(A:list,B:list,N:int) -> str:
   bingo=[[0,0,0] for i in range(3)]
   for b in B:
      for i,a in enumerate(A):
         if(b in a):
            bingo[i][a.index(b)] = 1
            break
   tate=[0,0,0]
   for n,b in enumerate(bingo):
      if(sum(b) == 3):
         return "Yes"
      for i in range(3):
         tate[i] = b[i]
   if(3 in tate): return "Yes"
   if(bingo[1][1] == 1):
      if((bingo[0][0] == 1 and bingo[2][2] == 1) or (bingo[0][2]==1 and bingo[2][0]==1)):
         return "Yes"
   return "No"

def modelAnswer():
   tmp=1
def main():
   A=[]
   B=[]
   for _ in range(3):
      A.append(list(map(int,input().split())))
   N = int(input())
   for _ in range(N):
      B.append(int(input()))
   print(myAnswer(A[:],B[:],N))

if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:

def myAnswer(A:list,B:list,N:int) -> str:
   bingo=[[0,0,0] for i in range(3)]
   for b in B:
      for i,a in enumerate(A):
         if(b in a):
            bingo[i][a.index(b)] = 1
            break
   tate=[0,0,0]
   for n,b in enumerate(bingo):
      if(sum(b) == 3):
         return "Yes"
      for i in range(3):
         tate[i] = b[i]
   if(3 in tate): return "Yes"
   if(bingo[1][1] == 1):
      if(bingo[0][0] == 1 and bingo[2][2] or bingo[0][2] and bingo[2][0]):
         return "Yes"
   return "No"

def modelAnswer():
   tmp=1
def main():
   A=[]
   B=[]
   for _ in range(3):
      A.append(list(map(int,input().split())))
   N = int(input())
   for _ in range(N):
      B.append(int(input()))
   print(myAnswer(A[:],B[:],N))

if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:

def myAnswer(A:list,B:list,N:int) -> str:
   bingo=[[0,0,0] for i in range(3)]
   for b in B:
      for i,a in enumerate(A):
         if(b in a):
            bingo[i][a.index(b)] = 1
            break
   tate=[0,0,0]
   for n,b in enumerate(bingo):
      if(sum(b) == 3):
         return "Yes"
      for i in range(3):
         tate[i] = b[i]
   if(3 in tate): print(("Yes"))
   if(bingo[1][1] == 1):
      if(bingo[0][0] == 1 and bingo[2][2] or bingo[0][2] and bingo[2][0]):
         return "Yes"
   return "No"

def modelAnswer():
   tmp=1
def main():
   A=[]
   B=[]
   for _ in range(3):
      A.append(list(map(int,input().split())))
   N = int(input())
   for _ in range(N):
      B.append(int(input()))
   print(myAnswer(A[:],B[:],N))

if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def isBingo(isOpen):
    if np.any(np.all(isOpen==1,axis=0)==True) or \
        np.any(np.all(isOpen==1,axis=1)==True):
        return "Yes"
    cnt1=0
    cnt2=0
    for i in range(3):
        print(isOpen[i][i])
        if isOpen[i][i]==1:
            cnt1+=1
        if isOpen[i][2-i]==1:
            cnt2+=1
    if cnt1==3 or cnt2==3:
        return "Yes"
    else:
        return "No"

bingo = [list(map(int, input().split())) for _ in range(3)]
n = int(input().strip())

isOpen=np.zeros([3,3],dtype=int)
for _ in range(n):
    b=int(input().strip())
    for i in range(3):
        for j in range(3):
            if b==bingo[i][j]:
                isOpen[i][j]=1
print(isBingo(isOpen))

Submission status: Wrong Answer

Solution code:
import numpy as np

def isBingo(isOpen):
    if np.any(np.all(isOpen==1,axis=0)==True) or \
        np.any(np.all(isOpen==1,axis=1)==True):
        return "Yes"
    cnt1=0
    cnt2=0
    for i in range(3):
        if isOpen[i][i]==1:
            cnt1+=1
        if isOpen[i][2-i]==1:
            cnt1+=1
    if cnt1==3 or cnt2==3:
        return "Yes"
    else:
        return "No"

bingo = [list(map(int, input().split())) for _ in range(3)]
n = int(input().strip())

isOpen=np.zeros([3,3])
for _ in range(n):
    b=int(input().strip())
    for i in range(3):
        for j in range(3):
            if b==bingo[i][j]:
                isOpen[i][j]=1
print(isBingo(isOpen))

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)]
card = [[False]*3]*3
for num in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == num:
                card[i][j] = True

def res(a,b,c):
    return a and b and c
ans = "No"
if res(card[0][0],card[0][1],card[0][2]) or res(card[1][0],card[1][1],card[1][2]) or res(card[2][0],card[2][1],card[2][2]) or res(card[0][0],card[1][0],card[2][0]) or res(card[0][1],card[1][1],card[2][1]) or res(card[0][2],card[1][2],card[2][2]) or res(card[0][0],card[1][1],card[2][2]) or res(card[0][2],card[1][1],card[2][0]):
    ans = "Yes"
print(ans)