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)]
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(A[0][0],A[0][1],A[0][2]) or res(A[1][0],A[1][1],A[1][2]) or res(A[2][0],A[2][1],A[2][2]) or res(A[0][0],A[1][0],A[2][0]) or res(A[0][1],A[1][1],A[2][1]) or res(A[0][2],A[1][2],A[2][2]) or res(A[0][0],A[1][1],A[2][2]) or res(A[0][2],A[1][1],A[2][0]):
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
def isBingo(isOpen):
    cnt1=0
    cnt2=0
    for i in range(3):
        if isOpen[:][i].count(True)==3 or \
            isOpen[i][:].count(True)==3:
            return "Yes"
        if isOpen[i][i]==True:
            cnt1+=1
        if isOpen[i][2-i]==True:
            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())
# b = [int(input().strip()) for _ in range(n)]
isOpen=[[False]*3 for _ in range(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]=True
print(isBingo(isOpen))

Submission status: Wrong Answer

Solution code:
def isBingo(isOpen):
    cnt=0
    for i in range(3):
        if isOpen[:][i].count(True)==3 or \
            isOpen[i][:].count(True)==3:
            return "Yes"
        if isOpen[i][i]==True:
            cnt+=1
    if cnt==3:
        return "Yes"
    else:
        return "No"

bingo = [list(map(int, input().split())) for _ in range(3)]
n = int(input().strip())
# b = [int(input().strip()) for _ in range(n)]
isOpen=[[False]*3 for _ in range(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]=True
print(isBingo(isOpen))

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    A.append(input().split())
N = int(input())
B = []
for i in range(N):
    B = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == B:
                A[j][k] = 0

if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
    print('Yes')
elif A[1][0] == 0 and A[1][0] == 0 and A[1][2] == 0:
    print('Yes')
elif A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
    print('Yes')
elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
    print('Yes')
elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('Yes')
elif 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 = []
for i in range(3):
    A.append(input().split())
N = int(input())
B = []
for i in range(N):
    B = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == B:
                A[j][k] = 0

if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
    print('Yes')
elif A[1][0] == 0 and A[1][0] == 0 and A[1][2] == 0:
    print('Yes')
elif A[2][0] == 0 and A[2][0] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
    print('Yes')
elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
    print('Yes')
elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('Yes')
elif 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=[]
for i in range(3):
    a.append(list(map(int,input().split())))

n=int(input())
for k in range(n):
    bk=int(input())
    for i in range(3):
        for j in range(3):
            if bk==a[i][j]:
                a[i][j]=0
c=0
for i in range(3):
    if a[0][i]==a[1][i] and a[0][i]==a[2][i]:
        c += 1
if a[0]==[0,0,0] or a[1]==[0,0,0] or a[2]==[0,0,0]:
    print("Yes")
elif c!= 0:
    print("yes")
elif (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:
#!/usr/bin/env python3

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

B = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N = int(input())

# print(A)
for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == num:
                B[j][k] = 1

# print(B)
flag = 0
for i in range(3):
    if B[0][i] == 1 and B[1][i] == 1 and B[2][i] == 1:
        flag = 1

for i in range(3):
    if B[i][0] == 1 and B[i][1] == 1 and B[i][2] == 1:
        flag = 1

if B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    flag = 1

if A[0][2] == 1 and A[1][1] == 1 and A[2][0] == 1:
    flag = 1

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

B = [[0]*3]*3
N = int(input())

# print(A)
for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == num:
                B[j][k] = 1


flag = 0
for i in range(3):
    if B[0][i] == 1 and B[1][i] == 1 and B[2][i] == 1:
        flag = 1

for i in range(3):
    if B[i][0] == 1 and B[i][1] == 1 and B[i][2] == 1:
        flag = 1

if B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    flag = 1

if A[0][2] == 1 and A[1][1] == 1 and A[2][0] == 1:
    flag = 1

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

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

b1 = [0] * 3
b2 = [0] * 3
b3 = [0] * 3

for i in b:
    for j in range(3):
        if i == a1[j]:
            b1[j] = 1
for i in b:
    for j in range(3):
        if i == a2[j]:
            b2[j] = 1
for i in b:
    for j in range(3):
        if i == a3[j]:
            b3[j] = 1

print(b1)
print(b2)
print(b3)


if b1[0] == b2[0] == b3[0] ==1 or b1[1] == b2[1] == b3[1] == 1 or b1[2] == b2[2] == b3[2]==1:
    print("Yes")
    exit()
elif b1[0] == b2[1] == b3[2] == 1 or b1[2] == b2[1] == b3[0] ==1:
    print("Yes")
    exit()
elif b1[0] == b1[1] == b1[2] == 1 or b2[0] == b2[1] == b2[2] == 1 or b3[0] == b3[1] == b3[2] == 1:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
#--Bingo
a_11, a_12, a_13 = map(int, input().split(" "))
a_21, a_22, a_23 = map(int, input().split(" "))
a_31, a_32, a_33 = map(int, input().split(" "))
N = int(input())

List = [int(input()) for i in range(N)]

#--horizontal
bingo = [[a_11, a_12, a_13], [a_21, a_22, a_23], [a_31, a_32, a_33], 
        [a_11, a_21, a_31], [a_12, a_22, a_32], [a_13, a_23, a_33],
        [a_11, a_22, a_33], [a_13, a_22, a_31]]

def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr

for num in range(7):
  list_diff = intersect_list(bingo[num], List)
  if (int(len(list_diff)) == 3):
    print("Yes")
    exit()
  else:
    pass

print("No")

Submission status: Wrong Answer

Solution code:
#graph implementation
import math
ls=[]
for i in range(3):
    ls.append(list(map(int,input().split())))
ans=[[0,0,0],[0,0,0],[0,0,0]]
n=int(input())
for i in range(n):
    a=int(input())
    for j in range(3):
        for k in range(3):
            if a==ls[j][k]:
                ans[j][k]=1
res=[]
for i in range(3):
    res.append(sum(ans[i]))
var=0
while var<3:
    for i in range(3):
        res.append(ans[i][var])
    var+=1
res.append(ans[0][0]+ans[1][1]+ans[2][2])
res.append(ans[0][2]+ans[1][1]+ans[2][0])
res.sort()
if res[len(res)-1]==3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
is_bingo = [[False]*3 for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i, ai in enumerate(a):
        for j, aii in enumerate(ai):
            if aii == b:
                is_bingo[i][j] = True
is_bingo_flat = [j for i in is_bingo for j in i]
for i in range(3):
    if all(is_bingo[i]) or all(list(zip(*is_bingo))[i]) or is_bingo_flat[i::3]:
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a11, a12, a13 = map(int,input().split())
a21, a22, a23 = map(int,input().split())
a31, a32, a33 = map(int,input().split())
n=int(input())
b=[0]*n
for i in range(n):
  b[i]=int(input())
  
for i in range(n):
  if b[i] == a11:
    a11=0
  elif b[i] == a12:
    a12 = 0
  elif b[i] == a13:
    a13 = 0
  elif b[i] == a21:
    a21 = 0
  elif b[i] == a22:
    a22 = 0
  elif b[i] == a23:
    a23 = 0
  elif b[i] == a31:
    a31 = 0
  elif b[i] == a32:
    a32 = 0
  elif b[i] == a33:
    a33 = 0
  else:
    pass
  
if a11+a12+a13==0 or a21+a22+a23==0 or a31+a32+a33==0 or a11+a21+a31==0 or a12+a22+a32==0 or a13+a23+a33==0 or a11+a22+a33==0 or a31+a32+a13==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a11, a12, a13 = map(int,input().split())
a21, a22, a23 = map(int,input().split())
a31, a32, a33 = map(int,input().split())
n=int(input())
b=[0]*n
for i in range(n):
  b[i]=int(input())
  
for i in range(n):
  if b[i] == a11:
    a11=0
  elif b[i] == a12:
    a12 = 0
  elif b[i] == a13:
    a13 = 0
  elif b[i] == a21:
    a21 = 0
  elif b[i] == a22:
    a22 = 0
  elif b[i] == a23:
    a23 = 0
  elif b[i] == a31:
    a31 = 0
  elif b[i] == a32:
    a32 = 0
  elif b[i] == a33:
    a33 = 0
  else:
    pass
  
if a11+a12+a13==0 or a21+a22+a23==0 or a31+a32+a33==0 or a11+a21+a31==0 or a12+a22+a32==0 or a13+a23+a33==0 or a11+a22+a33==0 or a31+a32+a33==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
A = []

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

N = int(input())
ans=[]
for _ in range(N):
    b=int(input())
    for i in range(3):
        if(b in A[i]):
            ans.append([i+1,A[i].index(b)+1])
            break
tate=False
if(ans == []):
    print("No")
else:
    counter1=[0,0,0]
    counter2=[0,0,0]
    counter3=0
    for a in ans:
        if(a[0]==1):
            counter1[0]+=1
        elif(a[0] == 2):
            counter1[1]+=1
        elif(a[0] == 3):
            counter1[2]+=1

        if(a[1] == 1):
            counter2[0]+=1
        elif(a[1] == 2):
            counter2[1]+=1
        elif(a[1] == 3):
            counter2[2]+=1
        if(a[0]==a[1]):
            counter3+=1

    if(3 in counter1 or 3 in counter2 or counter3 >=3):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys

ll = [[int(x) for x in input().split()] for y in range(3)]

n = int(input())

for i in range(n):
    b = int(input())
    for ii in range(3):
        if b in ll[ii]:
            ll[ii][ll[ii].index(b)] = 0

for i in range(3):
    if ll[i][0] == ll[i][1] == ll[i][2] == 0:
        print("Yes")
        sys.exit()
    if ll[0][i] == ll[1][i] == ll[2][i] == 0:
        print("Yes")
        sys.exit()

if ll[0][0] == ll[1][1] == ll[2][2] == 0 or ll[0][2] == ll[1][1] == ll[2][0] == 0:
    print("Yes")
    sys.exit()

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


for i in range(3):
    for j in range(3):
        for x in range(N):
            if A[i][j]==b[x]:
                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")
        sys.exit(0)
for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        print("Yes")
        sys.exit(0)
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print("Yes")
    sys.exit(0)
if A[0][2] == 0 and A[1][1] == 0 and A[2][1] == 0:
    print("Yes")
    sys.exit(0)
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=[]
for i in range(N):
    b.append(int(input()))


for i in range(3):
    for j in range(3):
        for x in range(N):
            if A[i][j]==b[x]:
                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")
        sys.exit(0)
for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        print("Yes")
        sys.exit(0)
for i in range(3):
    if A[i][i] == 0 and A[i][i] == 0 and A[i][i] == 0:
        print("Yes")
        sys.exit(0)
for i in range(2,-1,-1):
    if A[i][i] == 0 and A[i][i] == 0 and A[i][i] == 0:
        print("Yes")
        sys.exit(0)
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=[]
for i in range(N):
    b.append(int(input()))


for i in range(3):
    for j in range(3):
        for x in range(N):
            if A[i][j]==b[x]:
                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")
        sys.exit(0)
for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        print("Yes")
        sys.exit(0)
for i in range(3):
    if A[i][i] == 0 and A[i][i] == 0 and A[i][i] == 0:
        print("Yes")
        sys.exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

N =  int(input())

for line in range(N):
	b=int(input())
	for a in range(3):
		for a_1 in range(3):
			if A[a][a_1]==b:
				A[a][a_1]=0
ans=[]
A_r=np.array(A).T.tolist()

for k in range(3):
	if sum(A[k])==0 or sum(A_r[k])==0:
		ans=[0,0,0]
		break
	else:
		ans.append(A[k][k])

if ans==[0,0,0]:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

N =  int(input())

for line in range(N):
	b=int(input())
	for a in range(3):
		for a_1 in range(3):
			if A[a][a_1]==b:
				A[a][a_1]=0
ans=[]
A_r=list(np.array(A).T)
for k in range(3):
	if sum(A[k])==0 or sum(A_r[k])==0:
		ans=[0,0,0]
		break
	else:
		ans.append(A[k][k])

if ans==[0,0,0]:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

N =  int(input())

for line in range(N):
	b=int(input())
	for a in range(3):
		for a_1 in range(3):
			if A[a][a_1]==b:
				A[a][a_1]=0
ans=[]
A_r=list(np.array(A).T)
for k in range(3):
	if sum(A[k])==0 or sum(A_r[k])==0:
		ans=[0,0,0]
		break
	else:
		ans.append(A[k][k])

if sum(ans)==0:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a=n3(3)
n=n0()
b=n2(n)

c=[[False]*3]*3
for k in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j]==b[k]:
                c[i][j]=True
if (c[0][0]==c[0][1]==c[0][2]==True) or (c[1][0]==c[1][1]==c[1][2]==True) or (c[2][0]==c[2][1]==c[2][2]==True) or (c[0][0]==c[1][0]==c[2][0]==True) or (c[0][1]==c[1][1]==c[2][1]==True) or (c[0][2]==c[1][2]==c[2][2]==True) or (c[0][0]==c[1][1]==c[2][2]==True) or (c[0][2]==c[1][1]==c[2][0]==True):
    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())
lst = [int(input()) for i in range(N)]

for l in lst:
    for i in range(3):
        if a[i] == l:
            a[i] = "〇"
        if b[i] == l:
            b[i] = "〇"
        if c[i] == l:
            c[i] = "〇"
            
if a[0] == a[1] == a[2]:
    print("Yes")
elif b[0] == b[1] == [2]:
    print("Yes")
elif c[0] == c[1] == [2]:
    print("Yes")
elif a[0] == b[0] == c[0]:
    print("Yes")
elif a[1] == b[1] == c[1]:
    print("Yes")
elif a[2] == b[2] == c[2]:
    print("Yes")
elif a[0] == b[1] == c[2]:
    print("Yes")
elif a[2] == b[1] == c[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())
lst = [int(input()) for i in range(N)]

for l in lst:
    for i in range(3):
        if a[i] == l:
            a[i] = True
        if b[i] == l:
            b[i] = True
        if c[i] == l:
            c[i] = True
if a[0] == a[1] == a[2]:
    print("Yes")
elif b[0] == b[1] == [2]:
    print("Yes")
elif c[0] == c[1] == [2]:
    print("Yes")
elif a[0] == b[0] == c[0]:
    print("Yes")
elif a[1] == b[1] == c[1]:
    print("Yes")
elif a[2] == b[2] == c[2]:
    print("Yes")
elif a[0] == b[1] == c[2]:
    print("Yes")
elif a[2] == b[1] == c[0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def check(list1):
    if(list1[0][0]==0 and list1[1][1]==0 and list1[2][2]==0):
        return "Yes"
    for i in range(3):
        count=0
        for j in range(3):
            if(list1[i][j]==0):
                count+=1
        if(count==3):
            return "Yes"
    for i in range(3):
        count=0
        for j in range(3):
            if(list1[j][i]==0):
                count+=1
        if(count==3):
            return "Yes"
    return "No" 
list1=[]
for i in range(3):
    list2=list(map(int,input().strip().split()))[:3]
    list1.append(list2)
n=int(input())
list3=[]
for i in range(n):
    list3.append(int(input()))
for i in list3:
    for j in range(3):
        for k in range(3):
            if(list1[j][k]==i):
                list1[j][k]=0
print(check(list1))

Submission status: Wrong Answer

Solution code:
hit = [[0] * 3 for _ in range(3)]
a = [list(map(int, input().split())) for _ 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:
                hit[j][k] = 1
if hit[0][0] == 1 and hit[0][1] == 1 and hit[0][2] == 1:
    print('Yes')
elif hit[1][0] == 1 and hit[1][1] == 1 and hit[1][2] == 1:
    print('Yes')
elif hit[2][0] == 1 and hit[2][1] == 1 and hit[2][2] == 1:
    print('Yes')
elif hit[0][0] == 1 and hit[1][1] == 1 and hit[2][2] == 1:
    print('Yes')
elif hit[2][2] == 1 and hit[1][1] == 1 and hit[2][0] == 1:
    print('Yes')
elif hit[0][0] == 1 and hit[1][0] == 1 and hit[1][2] == 1:
    print('Yes')
elif hit[0][1] == 1 and hit[1][1] == 1 and hit[2][2] == 1:
    print('Yes')
elif hit[2][0] == 1 and hit[2][1] == 1 and hit[2][2] == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
hit = [[0] * 3 for _ in range(3)]
a = [list(map(int, input().split())) for _ 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:
                hit[j][k] = 1
if hit[0][0] == 1 and hit[0][1] == 1 and hit[0][2] == 1:
    print('Yes')
elif hit[1][0] == 1 and hit[1][1] == 1 and hit[1][2] == 1:
    print('Yes')
elif hit[2][0] == 1 and hit[2][1] == 1 and hit[2][2] == 1:
    print('Yes')
elif hit[0][0] == 1 and hit[1][1] == 1 and hit[2][2] == 1:
    print('Yes')
elif hit[2][2] == 1 and hit[1][1] == 1 and hit[2][0] == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

N = int(input())

B = [int(input()) for i in range(N)]

# for i in A:
#     print(*i)

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

# for i in A:
#     print(*i)

ans = False

for i in range(3):
    judge = 0
    for j in range(3):
        judge += A[i][j]
        if judge == 0:
            # ans = True
            print("Yes")
            exit()

for j in range(3):
    judge = 0
    for i in range(3):
        judge += A[i][j]
        if judge == 0:
            print("Yes")
            exit()

judge = 0

for k in range(3):
    judge += A[k][k]
    if judge == 0:
        print("Yes")
        exit()

judge = 0

judge += A[0][2] + A[1][1] + A[2][0]
if judge == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
bingo = [0] * 9

A = input().split()
A += input().split()
A += input().split()

n = int(input())

for i in range(n):
    b = input()
    if b in A:
        bingo[A.index(b)] = 1        
    
ans = 'No'
for i in range(3):
    if bingo[i] == bingo[i + 1] == bingo[i + 2] == 1:
        ans = 'Yes'
        break

for i in range(3):
    if bingo[i] == bingo[i + 3] == bingo[i + 6] == 1:
        ans = 'Yes'
        break
 
if bingo[0] == bingo[4] == bingo[8] == 1:
        ans = 'Yes'

if bingo[2] == bingo[4] == bingo[6] == 1:
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
bingo = [0] * 9

A = input().split()
A += input().split()
A += input().split()

n = int(input())

for i in range(n):
    b = input()
    if b in A:
        bingo[A.index(b)] = 1        
    
ans = 'No'
for i in range(3):
    if bingo[i] == bingo[i + 1] == bingo[i + 2] == 1:
        ans = 'Yes'
        break
    i += 3

for i in range(3):
    if bingo[i] == bingo[i + 3] == bingo[i + 6] == 1:
        ans = 'Yes'
        break
 
if bingo[0] == bingo[4] == bingo[8] == 1:
        ans = 'Yes'

if bingo[2] == bingo[4] == bingo[6] == 1:
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
a_list1, a_list2, a_list3 = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b_list = []
for _ in range(n):
    b_list.append(int(input()))
a_list = a_list1 + a_list2 + a_list3
hit_list = []
for i in range(len(a_list)):
    if a_list[i] in b_list:
        hit_list.append(i)
bingo_list = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[3,4,6]]
ans = 'No'
for bingo in bingo_list:
    if set(bingo) <= set(hit_list):
        ans = 'Yes'
        break
print(ans)

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
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
 
for i in range(3):
    flag=True
    if a[i][i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()
 
for i in range(3):
    if a[i][2-i]!=0:
        print("No")
        exit()
print("Yes")
exit()

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
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
 
for i in range(3):
    flaf=True
    if a[i][i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()
 
for i in range(3):
    if a[i][2-i]!=0:
        print("No")
        exit()
print("Yes")
exit()

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

for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    if a[i][i]!=0:
        flag=False
if flag:
   print("Yes")
   exit()

for i in range(3):
    flag=True
    if a[i][2-i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()
else:
    print("No")
    exit()

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

for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    if a[i][i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()

for i in range(3):
    if a[i][2-i]!=0:
        print("No")
        exit()
print("Yes")
exit()

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

for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    if a[i][i]!=0:
        print("No")
        exit()
print("Yes")
exit()

for i in range(3):
    if a[i][2-i]!=0:
        print("No")
        exit()
print("Yes")
exit()

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

for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    if a[i][i]!=0:
        flag=False
    if flag:
        print("Yes")
        exit()

for i in reversed(range(3)):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
n = int(input())
x = [int(input()) for i in range(n)]

tate = ((a in x)and (b in x)and (c in x)) or ((d in x)and (
    e in x)and (f in x)) or ((g in x)and (h in x)and (i in x))

yoko = ((a in x)and (d in x)and (g in x)) or ((b in x)and (
    e in x)and (h in x)) or ((c in x)and (f in x)and (i in x))

naname = ((a in x)and (e in x)and (i in x)) or ((c in x)and (
    e in x)and (i in x))

bingo = tate or yoko or naname

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

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
n = int(input())
x = [int(input()) for i in range(n)]

tate = ((a in x)and (b in x)and (c in x)) or ((d in x)and (
    e in x)and (f in x)) or ((g in x)and (h in x)and (i in x))

yoko = ((a in x)and (d in x)and (g in x)) or ((b in x)and (
    e in x)and (h in x)) or ((c in x)and (f in x)and (i in x))

naname = ((a and e and i) in x) or ((c and e and g) in x)

bingo = tate or yoko or naname

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

Submission status: Wrong Answer

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

n  = int(input())
br = 0
indx =[]
brindex = []
nwset = ()
sum = 0
for i in range(1,n+1): 
    br = int(input())
    for sets in lst:
        if br in sets: 
            indx.append(lst.index(sets))
            brindex.append(sets.index(br))
nwset = set(brindex)
sum = 0
for num in nwset: 
    sum += num
if indx.count(0) == 3 or indx.count(1) == 3 or indx.count(2) == 3:
    print("Yes")
    
elif brindex.count(0) == 3 or brindex.count(1) == 3 or brindex.count(2) ==3 or sum == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
c = input()
list_ans =(a,b,c)
N = int(input())
bingo_list=[]

for i in range(N):
    bingo = input()
    bingo_list.append(bingo)
    
#横ビンゴ判定
def bingo_row(p,q):
    #p 横のリスト　q 出た値のリスト
    for i in range(3):
        if p[i] in q:
            return True
        else:
            return False
#縦ビンゴ判定
def bingo_column(p,q,r,s):
    #pqr横リスト　s bingo_list
    for i in range(3):
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
            else:
                return False
        else:
            return False
#斜めビンゴ判定
def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2] in s:
            return True
        elif p[2] in s and r[0] in s:
            return True
        else:
            return False
    else:
        return False

    
total = 0
for i in list_ans:
    if bingo_row(i, bingo_list):
        print('Yes')
        break
    elif bingo_column(a,b,c,bingo_list):
        print('Yes')
        break
    elif bingo_slash(a,b,c,bingo_list):
        print('Yes')
        break
    else:
        total += 1
if total == 3:
    print('No')