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:
M=[]
for _i in range(3):
  M.append(list(map(int,input().split())))
n= int(input())

cont_lin = [0,0,0]
cont_col = [0,0,0]
contdp = contds = 0
for a in range(n):
  b= int(input())
  for i in range(3):
    for j in range(3):
      if M[i][j]==b:
          cont_lin[i]+=1
          cont_lin[j]+=1
          if i==j:
              contdp+=1
          if i==2-j:
              contds+=1
achou = False
if (contdp == 3) or (contds==3):
    achou=True
elif (cont_lin[0]==3) or (cont_lin[1]==3) or (cont_lin[2]==3) :
    achou=True  
elif (cont_col[0]==3) or (cont_col[1]==3) or (cont_col[2]==3) :
    achou=True

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

Submission status: Wrong Answer

Solution code:
M=[]
for _i in range(3):
  M.append(list(map(int,input().split())))
n= int(input())
for a in range(n):
  b= int(input())
  for i in range(3):
    for j in range(3):
      if M[i][j]==b:
        M[i][j]=-1
oassiy= False
for i in range(3):
  cont=0
  for j in range(3):
    if M[i][j]==-1:
      cont+=1
  if cont==3:
    break
    oassiy=True

if not oassiy:
 for j in range(3):
  cont=0
  for i in range(3):
    if M[i][j]==-1:
      cont+=1
  if cont==3:
    break
    oassiy=True

if not oassiy:
  cont1 = cont2= 0
  for i in range(3):
    if M[i][i]==-1:
      cont1+=1
    if M[i][2-i]==-1:
      cont2+=1
if (cont1==3) or (cont2==3):
    oassiy=True

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

Submission status: Wrong Answer

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

q = int(input())
val=[]
for i in range(q): val.append(int(input()))

for p in val:
    for i in range(3):
        for j in range(3):
            if p == num[i][j]: num[i][j]=-1

ans='No'

for i in range(3): #colunas
    if(num[0][j] == -1 and num[1][j] == -1 and num[2][j] ==-1): ans='Yes'
    if(num[j][0] == -1 and num[j][1] == -1 and num[j][2] ==-1): ans='Yes'

if(num[0][0] == -1 and num[1][1] == -1 and num[2][2] ==-1): ans='Yes'
if(num[0][2] == -1 and num[1][1] == -1 and num[2][0] ==-1): ans='Yes'


print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
#中央が空いている
if A[1][1]==-1:
  #ななめ
  if A[0][0] == A[2][2] or A[0][2]==A[2][0]:
    print("Yes")
  #たてよこ
  elif A[0][1]==A[2][1] or A[1][0]==A[1][2]:
    print("Yes")
  
#中央が空いていないor中央が空いている場合の特殊パターン
 
#たて
if A[0][0]==A[1][0] and A[1][0]==A[2][0] or A[0][2]==A[1][2]and A[1][2]==A[2][2]:
  print("Yes")
 #よこ
elif len(Counter(A[0]))==1or len(Counter(A[2]))==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    if(a[i] == x):
      a[i] = 0
    elif(b[i] == x):
      b[i] = 0
    elif(c[i] == x):
      c[i] = 0

if(a[0] == 0 and a[1] == 0 and a[2] == 0):
  print('Yes')
elif(b[0] == 0 and b[1] == 0 and b[2] == 0):
  print('Yes')
elif(c[0] == 0 and c[1] == 0 and c[2] == 0):
  print('Yes')
elif(a[0] == 0 and b[0] == 0 and c[0] == 0):
  print('Yes')
elif(a[1] == 0 and b[1] == 0 and c[1] == 0):
  print('Yes')
elif(a[2] == 0 and b[2] == 0 and c[2] == 0):
  print('Yes')
elif(a[0] == 0 and b[1] == 0 and c[2] == 0):
  print('Yes')
elif(a[2] == 0 and b[1] == 0 and c[2] == 0):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    if(a[i] == x):
      a[i] = 0
    elif(b[i] == x):
      b[i] = 0
    elif(c[i] == x):
      c[i] = 0

if(a[0] == 0 and a[1] == 0 and a[2] == 0):
  print('Yes')
elif(b[0] == 0 and b[1] == 0 and b[2] == 0):
  print('Yes')
elif(c[0] == 0 and c[1] == 0 and c[2] == 0):
  print('Yes')
elif(a[0] == 0 and b[0] == 0 and c[0] == 0):
  print('Yes')
elif(a[1] == 0 and b[1] == 0 and c[1] == 0):
  print('Yes')
elif(a[2] == 0 and b[2] == 0 and c[2] == 0):
  print('Yes')
elif(a[0] == 0 and b[1] == 0 and c[2] == 0):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import copy

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

A_rep = copy.deepcopy(A)

N = int(input())

B = []
for x in range(N):
    B.append(int(input()))
    #B = int(input())

for x in range(3):   
    for y in range(3):
        for z in B:
            if A_rep[x][y] == z:
                A_rep[x][y] = -1

#print(A)
#print(A_rep)
#print(B)

for x in range(3):
    if max(A_rep[x]) == -1:
        print("Yes")
        exit()

if A_rep[0][0] == -1 and A_rep[1][0] == -1 and A_rep[2][0] == -1:
    print("Yes")
    exit()

if A_rep[0][0] == -1 and A_rep[1][1] == -1 and A_rep[2][2] == -1:
    print("Yes")
    exit()

if A_rep[0][2] == -1 and A_rep[1][1] == -1 and A_rep[2][0] == -1:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
A = [[]]*3
for T in range(0,3):
    A[T] = [int(x) for x in input().split()]
A   = sum(A,[])
ATF = [False]*9

N = int(input())
for TT in range(0,N):
    B = int(input())
    if B in A:
        ATF[A.index(B)] = True

Flag = 0
if   (all(ATF[:3])) or (all(ATF[3:6])) or (all(ATF[6:])):
    Flag = 1
elif (all(ATF[::3])) or (all(ATF[1::3])) or (all(ATF[2::])):
    Flag = 1
elif (all(ATF[::4])) or (all(ATF[2:7:2])):
    Flag = 1

if Flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
a = []
ans = 1
for i in range(3):
    a.append(list(map(int, input().split())))
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] = -1
for k in range(3):
    if a[k] == [-1, -1, -1] or (a[k][0] == a[k][1] == a[k][2] == -1):
        ans = 0
if a[0][0] == a[1][1] == a[2][2] == -1:
    ans = 0
elif a[0][2] == a[1][1] == a[2][0] == -1:
    ans = 0
print('YNeos'[ans::2])

Submission status: Wrong Answer

Solution code:
import sys
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):
    ans = True
    for j in range(3):
        if a[i][j] not in b:
            ans = False
    if ans:
        print("Yes")
        sys.exit()
for j in range(3):
    ans = True
    for i in range(3):
        if a[i][j]  not in b:
            ans = False
    if ans:
        print("Yes")
        sys.exit()
if all([a[0][2] in b, a[1][1] in b, a[2][2] in b]) or all([a[0][2] in b, a[1][1] in b, a[2][0] in b]):
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys
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):
    ans = True
    for j in range(3):
        if a[i][j] not in b:
            ans = False
    if ans:
        print("Yes")
        sys.exit()
for j in range(3):
    ans = True
    for i in range(3):
        if a[i][j]  not in b:
            ans = False
    if ans:
        print("Yes")
        sys.exit()
ans = True
for i in range(3):
    if a[i][i] not in b:
        ans = False
    if ans:
        print("Yes")
        sys.exit()
if all([a[0][2] in b, a[1][1] in b, a[2][2] in b]):
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
bingo = ([(0,0),(0,1),(0,2)],[(1,0),(1,1),(1,2)],
         [(2,0),(2,1),(2,2)],[(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)])

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

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

a = []
for i in range(3):
    for j in range(3):
        if card[i][j] in b:
            a.append((i,j))

flag = False
for line in bingo:
    if line <= a:
        flag = True
        break

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

Submission status: Wrong Answer

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

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

if b[0][0] and b[0][1] and b[0][2] in hit_num:
    print("Yes")
elif b[1][0] and b[1][1] and b[1][2] in hit_num:
    print("Yes")
elif b[2][0] and b[2][1] and b[2][2] in hit_num:
    print("Yes")
elif b[0][0] and b[1][0] and b[2][0] in hit_num:
    print("Yes")
elif b[0][1] and b[1][1] and b[2][1] in hit_num:
    print("Yes")
elif b[0][2] and b[1][2] and b[2][2] in hit_num:
    print("Yes")
elif b[0][0] and b[1][1] and b[2][2] in hit_num:
    print("Yes")
elif b[0][2] and b[1][1] and b[2][0] in hit_num:
    print("Yes")
else:
    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)]

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

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

Submission status: Wrong Answer

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

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

if a[0] == ["*", "*", "*"] or a[1] == ["*", "*", "*"] or a[2] == ["*", "*", "*"]:
  print("Yes")
elif (a[1][1] == "*" and a[0][0] == "*" and a[2][2] == "*") or(a[1][1] == "*" and a[0][2] == "*" and a[2][0] == "*"):
  print("Yes")
else:
  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)]

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

if a[0] == ["*", "*", "*"] or a[1] == ["*", "*", "*"] or a[2] == ["*", "*", "*"]:
  print("Yes")
elif a[1][1] == "*" and (a[0][0] == "*" or a[0][2] == "*") and (a[2][0] == "*" or a[2][2] == "*"):
  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()))
A = [A1,A2,A3]
n = int(input())
B = [int(input()) for i in range(n)]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if B[i] == A[j][k]:
        A[j][k] = "*"
ans = ["*","*","*"]
for i in range(3):
  if A[i] == ans or [A[0][i],A[1][i],A[2][i]] == ans:
    print("Yes")
    exit()
    
if [A[0][0],A[1][1],A[2][2]] == ans or [A[2][0],A[1][1],A[0][2]] == ans:
  print("Yes")
else:
  pass

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()))
A = [A1,A2,A3]
n = int(input())
B = [int(input()) for i in range(n)]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if B[i] == A[j][k]:
        A[j][k] = "*"
        
if A[0] == ["*","*","*"] or A[1] == ["*","*","*"] or A[2] == ["*","*","*"]:
  print("Yes")
  exit()
elif A[0][0] == "*":
  if A[1][0] == "*" and A[2][0] == "*":
    print("Yes")
    exit()
  elif A[1][1] == "*" and A[2][2] == "*":
    print("Yes")
    exit()
elif A[0][1] == "*":
  if A[1][1] == "*" and A[2][1] == "*":
    print("Yes")
    exit()
elif A[0][2] == "*":
  if A[1][1] == "*" and A[2][0] == "*":
    print("Yes")
    exit()
  elif A[1][2] == "*" and A[2][2] == "*":
    print("Yes")
    exit()
else:
  pass

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()))
A = [A1,A2,A3]
n = int(input())
B = [int(input()) for i in range(n)]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if B[i] == A[j][k]:
        A[j][k] = "*"
        
if A[0] == ["*","*","*"] or A[1] == ["*","*","*"] or A[2] == ["*","*","*"]:
  print("Yes")
  exit()
elif A[0][0] == "*":
  if A[1][0] == "*" and A[2][0] == "*":
    print("Yes")
    exit()
  elif A[1][1] == "*" and A[2][2] == "*":
    print("Yes")
    exit()
elif A[0][1] == "*":
  if A[1][1] == "*" and A[2][1] == "*":
    print("Yes")
    exit()
elif A[0][2] == "*":
  if A[1][1] == "*" and A[2][0] == "*":
    print("Yes")
    exit()
  elif A[1][2] == "*" and A[2][2] == "*":
    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()))
A = [A1,A2,A3]
n = int(input())
B = [int(input()) for i in range(n)]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if B[i] == A[j][k]:
        A[j][k] = "*"
        
if A[0] == ["*","*","*"] or A[1] == ["*","*","*"] or A[2] == ["*","*","*"]:
  print("Yes")
elif A[0][0] == "*":
  if A[1][0] == "*" and A[2][0] == "*":
    print("Yes")
  elif A[1][1] == "*" and A[2][2] == "*":
    print("Yes")
elif A[0][1] == "*":
  if A[1][1] == "*" and A[2][1] == "*":
    print("Yes")
elif A[0][2] == "*":
  if A[1][1] == "*" and A[2][0] == "*":
    print("Yes")
  elif A[1][2] == "*" and A[2][2] == "*":
    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())
m = [[0]*3 for i in range(3)]
ans,l,r = 0,1,1
for _ in range(N):
  b = int(input())
  for i in range(3):
    if b in A[i]:
      m[i][A[i].index(b)]=1
                
for i in range(3):
  l *= m[i][i]
  t,y = 1,1
  for j in range(3):
    y *= m[j][i]
    t *= m[i][j]
    if i+j == 2:
      r *= m[i][j]
  if t or y or r or l:
    ans=1

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

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
m = [[0]*3 for i in range(3)]
ans,l,r,t = 0,0,0,0
for _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j]==b:
        m[i][j]=1
                
for i in range(3):
  t = sum(A[i])
  l += m[i][i]
  y = 0
  for j in range(3):
    y += m[j][i]
    if i+j == 2:
      r += m[i][j]
  if t==3 or y==3 or r==3 or l==3:
    ans=1

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

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
m = [[0]*3 for i in range(3)]
ans,l,r,t,y = 0,0,0,0,0
for _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j]==b:
        m[i][j]=1
                
for i in range(3):
  t = sum(A[i])
  l += m[i][i]
  for j in range(3):
    y += A[i][j]
    if i+j == 2:
      r += m[i][j]
  if t==3 or y==3 or r==3 or l==3:
    ans=1

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

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
m = [[0]*3 for i in range(3)]
ans,l,r = 0,0,0
for _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j]==b:
        m[i][j]=1/3
                
for i in range(3):
  if sum(m[i])==1:
    ans = 1
  if sum([m[j][i] for j in range(3)])==1:
    ans = 1
  l += m[i][i]
  for j in range(3):
    if i+j == 2:
      r += m[i][j]

print('Yes' if ans or l or r else 'No')

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
ans,l,r = 0,0,0
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] = 1/3
        
for i in range(3):
  if sum(A[i]):
    ans = 1
  if sum([A[j][i] for j in range(3)]):
    ans = 1
  l += A[i][i]
  for j in range(3):
    if i+j == 2:
      r += A[i][j]

print('Yes' if ans or l or r else 'No')

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
ans = 0
hn,mn = [0]*3,[0]*3
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
        
for i in range(3):
  if sum(A[i])==0:
    ans = 1
  if sum([A[i][j] for j in range(3)])==0:
    ans = 1
  if A[i][i]==0:
    hn[i] = 1
  for j in range(3):
    if i+j == 2:
      if A[i][j]==0:
        mn[i] = 1

print('Yes' if ans or all(hn) or all(mn) else 'No')

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
ans = False
skw1 = False
skw2 = False
for _ in range(N):
  b = int(input())
  for i in range(3):
    if b in A[i]:
      A[i][A[i].index(b)]=0
for i in range(3):
  if all([a==0 for a in A[i]]):
    ans = True
  if all([a[i]==0 for a in A]):
    ans = True
  if A[i][i]==0:
    skw1 = True
  else:
    skw1 = False
  for j in range(3):
    if i+j == 2:
      if A[i][j]==0:
        skw2 = True
      else:
        skw2 = False

print('Yes' if ans or skw1 or skw2 else 'No')

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
ans = False
skw = False
for _ in range(N):
  b = int(input())
  for i in range(3):
    if b in A[i]:
      A[i][A[i].index(b)]=0
for i in range(3):
  if all([a==0 for a in A[i]]):
    ans = True
  if all([a[i]==0 for a in A]):
    ans = True
  if A[i][i]==0:
    skw1 = True
  else:
    skw1 = False
  for j in range(3):
    if i+j == 2:
      if A[i][j]==0:
        skw2 = True
      else:
        skw2 = False

print('Yes' if ans==True or skw1==True or skw2==True else 'No')

Submission status: Wrong Answer

Solution code:
import sys
matrix = [input().split() for i in range(3)]
matrix.append([matrix[0][0], matrix[1][1], matrix[2][2]])
matrix.append([matrix[0][2], matrix[1][1], matrix[2][0]])
N = int(input())
bingo = [input() for i in range(N)]

for i in matrix:
    if i[0] in bingo and i[1] in bingo and i[2] in bingo:
        print('Yes')
        sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
for _ in range(3):
    A.append([int(x) for x in input().split()])
A = np.array(A)
R = np.zeros((3,3))
N = int(input())
B = []

for _ in range(N):
    b = int(input())
    x, y = np.where(A == b)
    if len(x) > 0:
        for i in range(len(x)):
            R[x[i], y[i]] = 1

#列
row1 = (np.sum(R, axis=1) > 3).sum()
row2 = (np.sum(R, axis=0) > 3).sum()

c1 = R[0][0] + R[1][1] + R[2][2]
c2 = R[0][2] + R[1][1] + R[2][0]

if row1 > 0 or row2 > 0 or c1 >= 3 or c2 >= 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
for _ in range(3):
    A.append([int(x) for x in input().split()])
A = np.array(A)
R = np.zeros((3,3))
N = int(input())
B = []

for _ in range(N):
    b = int(input())
    x, y = np.where(A == b)
    if len(x) > 0:
        for i in range(len(x)):
            R[x[i], y[i]] = 1

#列
row1 = (np.sum(R, axis=1) > 3).sum()
row2 = (np.sum(R, axis=0) > 3).sum()

#斜め
c1 = R[0][0] + R[1][1] + R[2][2]
c2 = R[0][2] + R[1][1] + R[2][0]

if row1 > 0 or row2 > 0 or c1 > 3 or c2 > 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
for _ in range(3):
    A.append([int(x) for x in input().split()])
A = np.array(A)
R = np.zeros((3,3))
N = int(input())
B = []

for _ in range(N):
    b = int(input())
    x, y = np.where(A == b)
    if len(x) > 0:
        for i in range(len(x)):
            R[x[i], y[i]] = 1

#列
row1 = np.sum(R, axis=1).sum()
row2 = np.sum(R, axis=0).sum()

#斜め
c1 = R[0][0] + R[1][1] + R[2][2]
c2 = R[0][2] + R[1][1] + R[2][0]

if row1 > 0 or row2 > 0 or c1 > 3 or c2 > 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
for _ in range(3):
    A.append([int(x) for x in input().split()])
A = np.array(A)
R = np.zeros((3,3))
N = int(input())
B = []

for _ in range(N):
    b = int(input())
    x, y = np.where(A == b)
    if len(x) > 0:
        for i in range(len(x)):
            R[x[i], y[i]] = 1

#列
row1 = np.sum(R, axis=1).sum()
row2 = np.sum(R, axis=0).sum()

#斜め
c1 = R[0][0] + R[1][1] + R[2][2]
c2 = R[0][2] + R[1][1] + R[2][0]
print(R)
if row1 > 0 or row2 > 0 or c1 > 3 or c2 > 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
for _ in range(3):
    A.append([int(x) for x in input().split()])
A = np.array(A)
R = np.zeros((3,3))
N = int(input())
B = []

for _ in range(N):
    b = int(input())
    x, y = np.where(A == b)
    if len(x) > 0:
        R[x[0], y[0]] = 1

#列
row1 = np.sum(R, axis=1).sum()
row2 = np.sum(R, axis=0).sum()

#斜め
c1 = R[0][0] + R[1][1] + R[2][2]
c2 = R[0][2] + R[1][1] + R[2][0]

if row1 > 0 or row2 > 0 or c1 > 3 or c2 > 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                bingo[i][j] = True
for i in range(3):
    if A[i] == [True, True, True]:
        print("Yes")
        flag = True
        break
    elif A[0][i] and A[1][i] and A[2][i]:
        print("Yes")
        flag = True
        break
    elif (A[0][0] and A[1][1] and A[2][2]) or (A[0][2] and A[1][1] and A[2][0]):
        print("Yes")
        flag = True
        break

if not flag:
    print("No")

Submission status: Wrong Answer

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

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

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

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

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