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: Accepted

Solution code:

if __name__ == '__main__':
    a = []
    a.extend(list(map(int, input().split(" "))))
    a.extend(list(map(int, input().split(" "))))
    a.extend(list(map(int, input().split(" "))))
    n = int(input())
    # b = []
    for i in range(n):
        b = int(input())
        for j in range(len(a)):
            if a[j] == b:
                a[j] = 0
                break
        # b.append(int(input()))

    # print(a)
    # print(b)

    if a[0] == 0 and a[1] == 0 and a[2] == 0:
        print("Yes")
    elif a[3] == 0 and a[4] == 0 and a[5] == 0:
        print("Yes")
    elif a[6] == 0 and a[7] == 0 and a[8] == 0:
        print("Yes")
    elif a[0] == 0 and a[3] == 0 and a[6] == 0:
        print("Yes")
    elif a[1] == 0 and a[4] == 0 and a[7] == 0:
        print("Yes")
    elif a[2] == 0 and a[5] == 0 and a[8] == 0:
        print("Yes")
    elif a[0] == 0 and a[4] == 0 and a[8] == 0:
        print("Yes")
    elif a[2] == 0 and a[4] == 0 and a[6] == 0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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 = [int(input()) for _ in range(n)]

s11,s12,s13 = -1,-2,-3
s21,s22,s23 = -4,-5,-6
s31,s32,s33 = -7,-8,-9

ans = 'No'
for i in range(n):
    b = int(input())
    if b == a11:
        s11 = 0
    elif b == a12:
        s12 = 0
    elif b == a13:
        s13 = 0
    elif b == a21:
        s21 = 0
    elif b == a22:
        s22 = 0
    elif b == a23:
        s23 = 0
    elif b == a31:
        s31 = 0
    elif b == a32:
        s32 = 0
    elif b == a33:
        s33 = 0

if (s11 == 0 and s12 == 0 and s13 == 0) or \
   (s21 == 0 and s22 == 0 and s23 == 0) or \
   (s31 == 0 and s32 == 0 and s33 == 0) or \
   (s11 == 0 and s21 == 0 and s31 == 0) or \
   (s12 == 0 and s22 == 0 and s32 == 0) or \
   (s13 == 0 and s23 == 0 and s33 == 0) or \
   (s11 == 0 and s22 == 0 and s33 == 0) or \
   (s13 == 0 and s22 == 0 and s31 == 0):
       ans = 'Yes'
        
print(ans)

Submission status: Accepted

Solution code:
a = []
flag = False
for i in range(3):
    t,b,c = map(int,input().split())
    a.append([t,b,c])
n = int(input())
for i in range(n):
    buf = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == buf:
                a[j][k] = 0
for i in range(3):
    if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0 ):
        flag = True
for i in range(3):
    if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
        flag = True
if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0 ):
    flag = True
if(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
    flag = True

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

Submission status: Accepted

Solution code:
import sys

A = [ int(x) for x in input().split(" ")]
A += [ int(x) for x in input().split(" ")]
A += [ int(x) for x in input().split(" ")]
N = int(input())
b = [None]*N
for i in range(N):
    b[i] = int(input())

Ans = [-1000]*9

for i in range(len(A)):
    for bb in b:
        if bb==A[i]:
            Ans[i] = bb
            break

if(0<=Ans[0]+Ans[1]+Ans[2]):
    print("Yes")
    exit(0)
if(0<=Ans[3]+Ans[4]+Ans[5]):
    print("Yes")
    exit(0)
if(0<=Ans[6]+Ans[7]+Ans[8]):
    print("Yes")
    exit(0)
if(0<=Ans[0]+Ans[3]+Ans[6]):
    print("Yes")
    exit(0)
if(0<=Ans[1]+Ans[4]+Ans[7]):
    print("Yes")
    exit(0)
if(0<=Ans[2]+Ans[5]+Ans[8]):
    print("Yes")
    exit(0)
if(0<=Ans[0]+Ans[4]+Ans[8]):
    print("Yes")
    exit(0)
if(0<=Ans[2]+Ans[4]+Ans[6]):
    print("Yes")
    exit(0)
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = []
for _ in range(3):
    A += list(map(int, input().split()))
B = [False]*9
N = int(input())
for _ in range(N):
    n = int(input())
    if n in A:
        B[A.index(n)] = True

def check():
    if all(B[:3]) or all(B[3:6]) or all(B[6:9]):
        return True
    for i in range(3):
        if B[0+i] and B[3+i] and B[6+i]:
            return True
    if B[0] and B[4] and B[8]:
        return True
    if B[2] and B[4] and B[6]:
        return True
    return False

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

Submission status: Accepted

Solution code:
la=[]
for i in range(3):
    la.append(list(map(int,input().split())))
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if la[j][k]==b:
                la[j][k]=-1
f=0
for i in range(3):
    for j in range(3):
        if la[i][j]!=-1:
            break
    else:
        f=1
        break
if f==0:
    for i in range(3):
        for j in range(3):
            if la[j][i]!=-1:
                break
        else:
            f=1
            break
if f==0:
    if la[0][0]==-1 and la[1][1]==-1 and la[2][2]==-1:
        f=1
    elif la[0][2]==-1 and la[1][1]==-1 and la[2][0]==-1:
        f=1
if f==1:
    print('Yes')
else:
    print("No")

Submission status: Accepted

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

li = [[False] * 3 for i in range(3)]

for i in range(n):
    m = int(input())
    for j in range(3):
        for k in range(3):
            if sheet[j][k] == m:
                li[j][k] = True


# check
ans = False
for i in range(3):
    tmp = li[0][i] & li[1][i] & li[2][i]
    if tmp:
        ans = True
        break
for i in range(3):
    tmp = li[i][0] & li[i][1] & li[i][2]
    if tmp:
        ans = True
        break

tmp = li[0][0] & li[1][1] & li[2][2]
if tmp:
    ans = True
tmp = li[0][2] & li[1][1] & li[2][0]
if tmp:
    ans = True

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

Submission status: Accepted

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

bingo=False

for i in range(3):
    if aa[i][0] & aa[i][1] & aa[i][2]:
        bingo=True

for i in range(3):
    if aa[0][i] & aa[1][i] & aa[2][i]:
        bingo=True

if aa[0][0] & aa[1][1] & aa[2][2]:
    bingo=True

if aa[0][2] & aa[1][1] & aa[2][0]:
    bingo=True

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

Submission status: Accepted

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

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

cnt = 0
for i in range(3):
    if sum(ans[i]) == 0:
        cnt = 1
        break
    elif ans[0][i] + ans[1][i] + ans[2][i] == 0:
        cnt = 1
        break
    elif ans[0][0] + ans[1][1] + ans[2][2] == 0:
        cnt = 1
        break
    elif ans[0][2] + ans[1][1] + ans[2][0] == 0:
        cnt = 1
        break

if cnt == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Submission status: Accepted

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


N = int(input())

for i in range(N):
    n = int(input())
    for p in range(3):
        for q in range(3):
            if bingo[p][q] == n:
                bingo[p][q] = 101
                break

ans = False

#print(bingo)
for a in bingo:
    if a[0] == a[1] and a[1] == a[2]:
        ans = True

for i in range(3):
    if bingo[0][i] == bingo[1][i] and bingo[1][i] == bingo[2][i]:
        ans = True

if bingo[0][2] == bingo[1][1] and bingo[1][1] == bingo[2][0]:
    ans = True

if bingo[0][0] == bingo[1][1] and bingo[1][1] == bingo[2][2]:
    ans = True

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

Submission status: Accepted

Solution code:
A = []
b = []

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 c in b:
    for i in range(3):
        for j in range(3):
            if A[i][j] == c:
                A[i][j] = 0

# 横チェック
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        print('Yes')
        exit()

# 縦チェック
for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 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: Accepted

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

N = int(input())
b = [0]*N
for i in range(N):
	b[i] = int(input())

for i in range(N):
	b_temp = b[i]
	for k in range(3):
		for j in range(3):
			if a[k][j] == b_temp:
				c[k][j] = 1
	for k in range(3):
		if c[k][0]*c[k][1]*c[k][2] == 1:
			print("Yes")
			exit()
		if c[0][k]*c[1][k]*c[2][k] == 1:
			print("Yes")
			exit()
	if c[0][0]*c[1][1]*c[2][2] == 1:
		print("Yes")
		exit()
	if c[2][0]*c[1][1]*c[0][2] == 1:
		print("Yes")
		exit()
print("No")

Submission status: Accepted

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

for i in range(3):
    A[i] = [int(s) for s in input().split()]

N = int(input())

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

ans = "No"
# yoko
for i in range(3):
    if sum(A[i]) == 0:
        ans = "Yes"

# tate
x = A[0][0] + A[1][0] + A[2][0]
if x == 0:
    ans = "Yes"
x = A[0][1] + A[1][1] + A[2][1]
if x == 0:
    ans = "Yes"
x = A[0][2] + A[1][2] + A[2][2]
if x == 0:
    ans = "Yes"

# naname
x = A[0][0] + A[1][1] + A[2][2]
if x == 0:
    ans = "Yes"
x = A[0][2] + A[1][1] + A[2][0]
if x == 0:
    ans = "Yes"


print(ans)

Submission status: Accepted

Solution code:
SEL = 0
A = [[int(j) for j in input().split(' ')] for i in range(3)]
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]:
        A[i][j] = SEL
 
if (A[0][0] == A[0][1] == A[0][2] == SEL or
    A[1][0] == A[1][1] == A[1][2] == SEL or
    A[2][0] == A[2][1] == A[2][2] == SEL or 
    A[0][0] == A[1][0] == A[2][0] == SEL or
    A[0][1] == A[1][1] == A[2][1] == SEL or
    A[0][2] == A[1][2] == A[2][2] == SEL or
    A[0][0] == A[1][1] == A[2][2] == SEL or
    A[0][2] == A[1][1] == A[2][0] == SEL):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a = []
for _ in range(3):
    tmp = [int(x) for x in input().split()]
    for x in tmp:
        a.append(x)
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))

for x in b:
    for i in range(9):
        if x == a[i]:
            a[i] = "O"

if a[0] == "O" and a[3] == "O" and a[6] == "O":
    print("Yes")
elif a[1] == "O" and a[4] == "O" and a[7] == "O":
    print("Yes")
elif a[2] == "O" and a[5] == "O" and a[8] == "O":
    print("Yes")
elif a[0] == "O" and a[1] == "O" and a[2] == "O":
    print("Yes")
elif a[3] == "O" and a[4] == "O" and a[5] == "O":
    print("Yes")
elif a[6] == "O" and a[7] == "O" and a[8] == "O":
    print("Yes")
elif a[0] == "O" and a[4] == "O" and a[8] == "O":
    print("Yes")
elif a[2] == "O" and a[4] == "O" and a[6] == "O":
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

N = int(input())

C = [[False for _ in range(3)] for _ in range(3)]
for i in range(N):
    B = int(input())
    for j in range(3):
        if B in A[j]:
            bi = A[j].index(B)
            C[j][bi] = True

ans = 'No'

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

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

# NANAME
if C[0][0] + C[1][1] + C[2][2] == 3:
    ans = 'Yes'

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

print(ans)

Submission status: Accepted

Solution code:
a11, a12, a13 = input().split()
a21, a22, a23 = input().split()
a31, a32, a33 = input().split()
n = int(input()) 
b = []
for _ in range(n):
    b.append(input())
if a11 in b and a12 in b and a13 in b:
  print("Yes")
elif a21 in b and a22 in b and a23 in b:
  print("Yes")
elif a31 in b and a32 in b and a33 in b:
  print("Yes")
elif a11 in b and a21 in b and a31 in b:
  print("Yes")
elif a12 in b and a22 in b and a32 in b:
  print("Yes")
elif a13 in b and a23 in b and a33 in b:
  print("Yes")
elif a11 in b and a22 in b and a33 in b:
  print("Yes")
elif a13 in b and a22 in b and a31 in b:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

c1=set(a[0::3])
c2=set(a[1::3])
c3=set(a[2::3])
c4=set([a1[0],a2[1],a3[2]])
c5=set([a1[2],a2[1],a3[0]])
c=[set(a1),set(a2),set(a3),c1,c2,c3,c4,c5]
j = any(len(b&x)==3 for x in c)
print('Yes' if j else 'No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
A=[]
ans=[False for _ in range(9)]
for _ in range(3):
    A.extend([int(i) for i in input().split()])
n=int(input())
b=[]
for _ in range(n):
    b.append(int(input()))
for i in range(9):
    if A[i] in b:
        ans[i] =True
        
rule=[(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6),(0,1,2),(3,4,5),(6,7,8)]
for r in rule:
    for n in r:
        if ans[n]:
            pass
        else:
            break
    else:
        print("Yes")
        sys.exit()
else:
    print("No")
    sys.exit()

Submission status: Accepted

Solution code:
import numpy as np
card = []
for i in range(3):
  card.append(list(map(int, input().split())))
card = np.array(card)
n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if (card[i, j] == b):
                card[i, j] = 0
flag = 0
for i in range(3):
  if (sum(card[i,:]) == 0):
    flag = 1
  if (sum(card[:,i]) == 0):
    flag = 1
if (card[0,0]+card[1,1]+card[2,2] == 0):
  flag = 1
if (card[0,2]+card[1,1]+card[2,0] == 0):
  flag = 1
if (flag == 1):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

flag = False
for i in range(3):
    if sum(A[i]) == 0:
        flag = True

for i in range(3):
    s = A[0][i] + A[1][i] + A[2][i]
    if s == 0:
        flag = True

s = A[0][0] + A[1][1] + A[2][2]
if s == 0:
    flag = True
s = A[0][2] + A[1][1] + A[2][0]
if s == 0:
    flag = True

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

Submission status: Accepted

Solution code:
maze = []
maze.append(list(map(int, input().split())))
maze.append(list(map(int, input().split())))
maze.append(list(map(int, input().split())))

num = int(input())
for _ in range(num):
    num = int(input())
    for row in maze:
        if num in row:
            idx = row.index(num)
            row[idx] = "X"

if maze[0][0] == "X" and maze[1][1] == "X" and maze[2][2] == "X":
    print("Yes")
elif maze[0][2] == "X" and maze[1][1] == "X" and maze[2][0] == "X":
    print("Yes")
elif maze[0][0] == "X" and maze[0][1] == "X" and maze[0][2] == "X":
    print("Yes")
elif maze[1][0] == "X" and maze[1][1] == "X" and maze[1][2] == "X":
    print("Yes")
elif maze[2][0] == "X" and maze[2][1] == "X" and maze[2][2] == "X":
    print("Yes")
elif maze[0][0] == "X" and maze[1][0] == "X" and maze[2][0] == "X":
    print("Yes")
elif maze[0][1] == "X" and maze[1][1] == "X" and maze[2][1] == "X":
    print("Yes")
elif maze[0][2] == "X" and maze[1][2] == "X" and maze[2][2] == "X":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = []

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

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

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

for bb in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == bb:
                AA[i][j] = 1
                
ans = 'No'

for i in AA:
    if sum(i) == 3:
        ans='Yes'

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

Submission status: Accepted

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

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

for i in range(N):
    for r in range(3):
        for c in range(3):
            if BINGO[r][c] == b[i]:
                BINGO[r][c] = 0

if sum(BINGO[0])==0:
    print('Yes')
elif sum(BINGO[1])==0:
    print('Yes')
elif sum(BINGO[2])==0:
    print('Yes')
elif BINGO[0][0]+BINGO[1][0]+BINGO[2][0]==0:
    print('Yes')
elif BINGO[0][1]+BINGO[1][1]+BINGO[2][1]==0:
    print('Yes')
elif BINGO[0][2]+BINGO[1][2]+BINGO[2][2]==0:
    print('Yes')
elif BINGO[0][0]+BINGO[1][1]+BINGO[2][2]==0:
    print('Yes')
elif BINGO[0][2]+BINGO[1][1]+BINGO[2][0]==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
bingo=np.array([list(map(int,input().split())) for _ in range(3)])
n=int(input())
call=[int(input()) for _ in range(n)]
#k=[list(map(int,input().split())) for _ in range(n)]
#bingo=[[] for _ in range(100)]
for i in range(3):
    f=True
    yoko=bingo[i]
    for each in yoko:
        if not each in call:
            f=False
            break
    if f:
        print("Yes")
        exit()
for i in range(3):
    f=True
    tate=bingo[:,i]
    for each in tate:
        if not each in call:
            f=False
            break

    if f:
        print("Yes")
        exit()
hoge=[]
huga=[]
for i in range(3):
    for j in range(3):
        if i==j:
            hoge.append(bingo[i][j])
        if i==2-j:
            huga.append(bingo[i][j])
f=True
for each in hoge:
    if not each in call:
        f=False
if f:
    print("Yes")
    exit()
for each in huga:
    if not each in call:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def chk(arr):
  if arr[0][1] and arr[1][1] and arr[2][1]:
    return True
  if arr[3][1] and arr[4][1] and arr[5][1]:
    return True
  if arr[6][1] and arr[7][1] and arr[8][1]:
    return True
  if arr[0][1] and arr[3][1] and arr[6][1]:
    return True
  if arr[1][1] and arr[4][1] and arr[7][1]:
    return True
  if arr[2][1] and arr[5][1] and arr[8][1]:
    return True
  if arr[0][1] and arr[4][1] and arr[8][1]:
    return True
  if arr[2][1] and arr[4][1] and arr[6][1]:
    return True
  return False

arr = [(int(_), False) for _ in input().split()]
arr.extend([(int(_), False) for _ in input().split()])
arr.extend([(int(_), False) for _ in input().split()])

n = int(input())

for _ in range(n):
  i = int(input())
  if arr.count((i, False)) == 1:
    index = arr.index((i, False))
    arr[index] = (i, True)

if chk(arr):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import numpy as np

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

for i in b:
    a[a == i] = -1

if any(np.all(a == -1, axis=0)) or any(np.all(a == -1, axis=1)):
    print('Yes')
elif a[0][0] == a[1][1] == a[2][2] == -1 or a[0][2] == a[1][1] == a[2][0] == -1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = []
for i in range(3):
  a.append(list(map(int,input().split())))
for i in range(int(input())):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = 0
def bingo():
  for i in range(3):
    if sum(a[i]) == 0 or a[0][i] + a[1][i] + a[2][i] == 0:
      return 'Yes'
  if a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0:
    return 'Yes'
  return 'No'
print(bingo())

Submission status: Accepted

Solution code:
B=[]
for _ in range(3):B+=list(map(int,input().split()))
S=set(int(input()) for _ in range(int(input())))
for i,b in enumerate(B):
    if b in S:B[i]=0
if B[0]+B[1]+B[2]==0 or B[3]+B[4]+B[5]==0 or B[6]+B[7]+B[8]==0 or B[0]+B[3]+B[6]==0 or B[1]+B[4]+B[7]==0 or B[2]+B[5]+B[8]==0 or B[0]+B[4]+B[8]==0 or B[2]+B[4]+B[6]==0:
    print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
import numpy as np
import math as m

def main(**kwargs):
    r = "No"

    if (A[0][0] in B) and (A[0][1] in B) and (A[0][2] in B):
        r = "Yes"
    
    if (A[1][0] in B) and (A[1][1] in B) and (A[1][2] in B):
        r = "Yes"
    
    if (A[2][0] in B) and (A[2][1] in B) and (A[2][2] in B):
        r = "Yes"
    
    if (A[0][0] in B) and (A[1][0] in B) and (A[2][0] in B):
        r = "Yes"
    
    if (A[0][1] in B) and (A[1][1] in B) and (A[2][1] in B):
        r = "Yes"
    
    if (A[0][2] in B) and (A[1][2] in B) and (A[2][2] in B):
        r = "Yes"
    
    if (A[0][0] in B) and (A[1][1] in B) and (A[2][2] in B):
        r = "Yes"
    
    if (A[0][2] in B) and (A[1][1] in B) and (A[2][0] in B):
        r = "Yes"
    
    return r

if __name__ == "__main__":
    A = np.zeros((3, 3), dtype="int")
    cin = np.array(input().split(" ")).astype("int")
    A[0][0], A[0][1], A[0][2] = cin
    cin = np.array(input().split(" ")).astype("int")
    A[1][0], A[1][1], A[1][2] = cin
    cin = np.array(input().split(" ")).astype("int")
    A[2][0], A[2][1], A[2][2] = cin

    cin = np.array(input().split(" ")).astype("int")
    n, *_ = cin

    B = np.zeros(n, dtype="int")

    for i in range(n):
        cin = np.array(input().split(" ")).astype("int")
        B[i], *_ = cin
    
    cout = main(A=A, n=n, B=B)
    print(cout)

Submission status: Accepted

Solution code:
a = [[int(i) for i in input().split()] for i in range(3)]
n = int(input())
b = list(int(input()) for i in range(n))
a1 = []
for i in range(3):
    for j in range(3):
        a1.append(a[i][j])
for i in range(n):
    if b[i] in a1:
        w = a1.index(b[i])
        a1[w] = -1
ans = 0
if a1[0] == a1[1] == a1[2] == -1 or a1[3] == a1[4] == a1[5] == -1 or a1[6] == a1[7] == a1[8] == -1:
    ans = 1
elif a1[0] == a1[3] == a1[6] == -1 or a1[1] == a1[4] == a1[7] == -1 or a1[2] == a1[5] == a1[8] == -1:
    ans = 1
elif a1[0] == a1[4] == a1[8] == -1 or a1[2] == a1[4] == a1[6] == -1:
    ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

n = int(input())

for i in range(n):
    m = int(input())
    for j in range(3):
        for k in range(3):
            if(data[j][k] == m):
                data[j][k] = True

if(data[0][0] == True and data[1][1] == True and data[2][2]):
    print("Yes")

elif(data[0][2] == True and data[1][1] == True and data[2][0]):
    print("Yes")

elif(data[0] == [True, True, True]):
    print("Yes")
elif(data[1] == [True, True, True]):
    print("Yes")
elif(data[2] == [True, True, True]):
    print("Yes")

elif(data[0][0]==True and data[1][0]==True and data[2][0]==True):
    print("Yes")
elif(data[0][1]==True and data[1][1]==True and data[2][1]==True):
    print("Yes")
elif(data[0][2]==True and data[1][2]==True and data[2][2]==True):
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
import sys

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

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

if (A1[0] in a) and (A1[1] in a) and (A1[2] in a):
  print("Yes")
  sys.exit()
  
elif (A2[0] in a) and (A2[1] in a) and (A2[2] in a):
  print("Yes")
  sys.exit()
  
elif (A3[0] in a) and (A3[1] in a) and (A3[2] in a):
  print("Yes")
  sys.exit()
  
elif (A1[0] in a) and (A2[0] in a) and (A3[0] in a):
  print("Yes")
  sys.exit()

elif (A1[1] in a) and (A2[1] in a) and (A3[1] in a):
  print("Yes")
  sys.exit()
  
elif (A1[2] in a) and (A2[2] in a) and (A3[2] in a):
  print("Yes")
  sys.exit()
 
elif (A1[0] in a) and (A2[1] in a) and (A3[2] in a):
  print("Yes")
  sys.exit()

elif (A1[2] in a) and (A2[1] in a) and (A3[0] in a):
  print("Yes")
  sys.exit()
  
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from pprint import pprint

bingo = [[] for _ in range(3)]
for i in range(3):
    bingo[i] = list(map(int, sys.stdin.readline().strip().split()))

N = int(sys.stdin.readline().strip())
B = set()
for _ in range(N):
    B.add(int(sys.stdin.readline().strip()))

bingo_flag = False
for i in range(3):
    tmp = []
    for j in range(3):
        if bingo[i][j] not in B:
            break
    else:
        bingo_flag = True

for i in range(3):
    for j in range(3):
        if bingo[j][i] not in B:
            break
    else:
        bingo_flag = True

for i in range(3):
    if bingo[i][i] not in B:
        break
else:
    bingo_flag = True

for i in range(3):
    if bingo[2-i][i] not in B:
        break
else:
    bingo_flag = True


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

Submission status: Accepted

Solution code:
def main():
    aa=[]
    for _ in range(3):
        aa.append(list(map(int,input().split())))
    n=int(input())
    bb=[]
    for _ in range(n):
        bb.append(int(input()))
    for i in range(3):
        if all(a in bb for a in aa[i]):
            print('Yes')
            return
        if all(a[i] in bb for a in aa):
            print('Yes')
            return
    if all(aa[i][i] in bb for i in range(3)):
        print('Yes')
        return
    if all(aa[2-i][i] in bb for i in range(3)):
        print('Yes')
        return
    print('No')

main()

Submission status: Accepted

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

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

if (A[0][0]==A[0][1]==A[0][2]==0) or (A[1][0]==A[1][1]==A[1][2]==0) or (A[2][0]==A[2][1]==A[2][2]==0) or (A[0][0]==A[1][0]==A[2][0]==0) or (A[0][1]==A[1][1]==A[2][1]==0)  or (A[0][2]==A[1][2]==A[2][2]==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')
else:
    print('No')

Submission status: Accepted

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

for b in b_list:
    for i, line in enumerate(a_list):
        for j, ele in enumerate(line):
            if ele == b:
                a_list[i][j] = -1
f = False
for i in range(3):
    if a_list[i][0] + a_list[i][1] + a_list[i][2] == -3:
        f = True
    elif a_list[0][i] + a_list[1][i] + a_list[2][i] == -3:
        f = True
if a_list[0][0] + a_list[1][1] + a_list[2][2] == -3:
    f = True
elif a_list[0][2] + a_list[1][1] + a_list[2][0] == -3:
    f = True

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

Submission status: Accepted

Solution code:
A = []
for _ in range(3):
    a1, a2, a3 = map(int, input().split())
    A += [(a1, a2, a3)]

n = int(input())
B = []
for _ in range(n):
    B += [int(input())]

for i in range(3):
    A += [(A[0][i], A[1][i], A[2][i])]
A += [(A[0][0], A[1][1], A[2][2])]
A += [(A[0][2], A[1][1], A[2][0])]

ans = 'No'
for x in A:
    _ans = [1 for _x in x if _x in B]
    if len(_ans) == 3:
        ans = 'Yes'
        break

print(ans)