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:
import numpy as np

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

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

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

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

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

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

card = []
for Ai in A:
    card.extend(Ai)

for bi in b:
    try :
        index = card.index(bi)
        card[index] = True
    except ValueError:
        pass

answer = 'No'
if (card[0] is True and card[1] is True and card[2] is True) or \
    (card[3] is True and card[4] is True and card[5] is True) or \
    (card[6] is True and card[7] is True and card[8] is True) or \
    (card[0] is True and card[3] is True and card[6] is True) or \
    (card[1] is True and card[4] is True and card[7] is True) or \
    (card[2] is True and card[5] is True and card[8] is True) or \
    (card[0] is True and card[4] is True and card[8] is True) or \
    (card[2] is True and card[4] is True and card[6] is True):
    answer = 'Yes'

print(answer)

Submission status: Accepted

Solution code:
import sys

a0, a1, a2 = map(int, input().split())
a3, a4, a5 = map(int, input().split())
a6, a7, a8 = map(int, input().split())
N=int(input())
arr = [int(input()) for _ in range(N)]
bin =[a0,a1,a2,a3,a4,a5,a6,a7,a8]

for i in range(len(arr)):
    for j in range(len(bin)):
        if bin[j] == arr[i]:
            bin[j]=0
    
if bin[0] == 0 and bin[3] == 0 and bin[6] == 0:
    print("Yes")
    exit()

if bin[1] == 0 and bin[4] == 0 and bin[7] == 0:
    print("Yes")
    exit()

if bin[2] == 0 and bin[5] == 0 and bin[8] == 0:
    print("Yes")
    exit()

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

if bin[3] == 0 and bin[4] == 0 and bin[5] == 0:
    print("Yes")
    exit()

if bin[6] == 0 and bin[7] == 0 and bin[8] == 0:
    print("Yes")
    exit()

if bin[0] == 0 and bin[4] == 0 and bin[8] == 0:
    print("Yes")
    exit()

if bin[2] == 0 and bin[4] == 0 and bin[6] == 0:
    print("Yes")
    exit()

print('No')

Submission status: Accepted

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][1] == 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: Accepted

Solution code:
A_1_list = list(map(int, input().split()))
A_1_set = set(A_1_list)
A_2_list = list(map(int, input().split()))
A_2_set = set(A_2_list)
A_3_list = list(map(int, input().split()))
A_3_set = set(A_3_list)
N = int(input())
b_set = {int(input()) for i in range(N)}
A_i_1_set = {A_1_list[0], A_2_list[0], A_3_list[0]}
A_i_2_set = {A_1_list[1], A_2_list[1], A_3_list[1]}
A_i_3_set = {A_1_list[2], A_2_list[2], A_3_list[2]}
A_d_1_set = {A_1_list[0], A_2_list[1], A_3_list[2]} #左上から右下
A_d_2_set = {A_1_list[2], A_2_list[1], A_3_list[0]} #右上から左下

#横１列が揃ったビンゴ
if A_1_set <= b_set or A_2_set <= b_set or A_3_set <= b_set:
    print('Yes')
#縦一列のビンゴ
elif A_i_1_set <= b_set or A_i_2_set <= b_set or A_i_3_set <= b_set:
    print('Yes')
#斜めのビンゴ
elif A_d_1_set <= b_set or A_d_2_set <= b_set:
    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())
ans='No'
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 a in A:
    if a.count(0)==3:
        ans='Yes'
for a in zip(*A):
    if a.count(0)==3:
        ans='Yes'
if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    ans='Yes'
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    ans='Yes'
print(ans)

Submission status: Accepted

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

for _ in range(N):
    b = int(input())
    for i in range(9):
        if b == A[i]:
            C[i] = True
            break

bingo = False
for i in range(3):
    if C[i * 3] and C[i * 3 + 1] and C[i * 3 + 2]:
        bingo = True

    if C[i] and C[i + 3] and C[i + 6]:
        bingo = True

if C[0] and C[4] and C[8]:
    bingo = True

if C[2] and C[4] and C[6]:
    bingo = True

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	a = []
	for _ in range(3):
		a.append(LI())
	a = np.array(a)
	n = II()
	b = np.array([[False for _ in range(3)] for _ in range(3)])
	for _ in range(n):
		b = np.logical_or(b,a==II())
	if (b[0][0] and b[0][1] and b[0][2]) or (b[1][0] and b[1][1] and b[1][2]) or (b[2][0] and b[2][1] and b[2][2]) or (b[0][0] and b[1][0] and b[2][0]) or (b[0][1] and b[1][1] and b[2][1]) or (b[0][2] and b[1][2] and b[2][2]) or (b[0][0] and b[1][1] and b[2][2]) or (b[0][2] and b[1][1] and b[2][0]) :
		print("Yes")
	else:
		print("No")



if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
stdin = open(0).read().split('\n')
A=list(map(int,stdin[0].split()))
A=A+list(map(int,stdin[1].split()))
A=A+list(map(int,stdin[2].split()))
N=int(stdin[3])
l = [0] * 10
for a in range(9):
    for b in range(N):
        if int(stdin[4+b])==A[a]:
            l[a]=1
if l[0]+l[1]+l[2]==3:print('Yes')
elif l[3]+l[4]+l[5]==3:print('Yes')
elif l[6]+l[7]+l[8]==3:print('Yes')
elif l[0]+l[3]+l[6]==3:print('Yes')
elif l[1]+l[4]+l[7]==3:print('Yes')
elif l[2]+l[5]+l[8]==3:print('Yes')
elif l[0]+l[4]+l[8]==3:print('Yes')
elif l[2]+l[4]+l[6]==3:print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
a=[]
for i in range(3):
    tmp=list(map(int,input().split()))
    a.append(tmp)
n=int(input())
b=[]
for i in range(n):
    tmp=int(input())
    b.append(tmp)
if a[0][0] in b:
    if a[0][1] in b:
        if a[0][2] in b:
            print("Yes")
            exit()
    if a[1][1] in b:
        if a[2][2] in b:
            print("Yes")
            exit()
    if a[1][0] in b:
        if a[2][0] in b:
            print("Yes")
            exit()
if a[0][1] in b:
    if a[1][1] in b:
        if a[2][1] in b:
            print("Yes")
            exit()
if a[0][2] in b:
    if a[1][2] in b:
        if a[2][2] in b:
            print("Yes")
            exit()
    if a[1][1] in b:
        if a[2][0] in b:
            print("Yes")
            exit()
if a[1][0] in b:
    if a[1][1] in b:
        if a[1][2] in b:
            print("Yes")
            exit()
if a[2][0] in b:
    if a[2][1] in b:
        if a[2][2] in b:
            print("Yes")
            exit()
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(' ')))
A = a1+a2+a3
n = int(input())
for q in range(n):
    b = int(input())
    i = 0
    while i < 9:
        if A[i] == b:
            A[i] = 0
        i += 1

ans = 0
counterlist = [(0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)]
for p in counterlist:
    if A[p[0]]+A[p[1]]+A[p[2]] == 0:
        ans += 1
if ans == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import numpy as np

A = np.array([
  list(map(int, input().split()))
  for i in range(3)])
B = A < 0
N = int(input())
for _ in range(N):
  B |= A == int(input())

if (
  B.all(axis=0).any() or B.all(axis=1).any() or
  np.diag(B).all() or np.diag(B[::-1]).all()
):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
A11, A12, A13 = list(map(int, input().split()))
A21, A22, A23 = list(map(int, input().split()))
A31, A32, A33 = list(map(int, input().split()))
N = int(input())
b = []
for i in range(N):
    b.append(int(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:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
N = int(input())
e = []
for i in range(N):
    e.append(int(input()))

if A[0] in e and A[1] in e and A[2] in e or \
    B[0] in e and B[1] in e and B[2] in e or \
    C[0] in e and C[1] in e and C[2] in e or \
    A[0] in e and B[1] in e and C[2] in e or \
    C[0] in e and B[1] in e and A[2] in e or \
    A[0] in e and B[0] in e and C[0] in e or \
    A[1] in e and B[1] in e and C[1] in e or \
    A[2] in e and B[2] in e and C[2] in e:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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 B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
    flag = 1

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

Submission status: Accepted

Solution code:
row1 = map(int, raw_input().split())
row2 = map(int, raw_input().split())
row3 = map(int, raw_input().split())

n = input()

state1 = [0,0,0]
state2 = [0,0,0]
state3 = [0,0,0]

for i in range(n):
    x = input()
    if x in row1:
        xId = row1.index(x)
        state1[xId] = 1
    if x in row2:
        xId = row2.index(x)
        state2[xId] = 1
    if x in row3:
        xId = row3.index(x)
        state3[xId] = 1

ans = "No"


if state1[0] == state1[1] == state1[2] == 1:
    ans = "Yes"
if state2[0] == state2[1] == state2[2] == 1:
    ans = "Yes"
if state3[0] == state3[1] == state3[2] == 1:
    ans = "Yes"
if state1[0] == state2[0] == state3[0] == 1:
    ans = "Yes"
if state1[1] == state2[1] == state3[1] == 1:
    ans = "Yes"
if state1[2] == state2[2] == state3[2] == 1:
    ans = "Yes"
if state1[0] == state2[1] == state3[2] == 1:
    ans = "Yes"
if state1[2] == state2[1] == state3[0] == 1:
    ans = "Yes"
print ans

Submission status: Accepted

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

b=[]
for i in range(n):
    b.append(int(input()))
    
def game(n):
    global bingo
    for gyou in bingo:
        for i in range(3):
            if gyou[i]==n:
                gyou[i]=None


for i in b:
    game(i)
    
ans=0
for i in bingo:
    if i==[None]*3:
        ans+=1
        
for i in range(3):
    if [bingo[0][i],bingo[1][i],bingo[2][i]]==[None]*3:
        ans+=1
if [bingo[0][0],bingo[1][1],bingo[2][2]]==[None]*3 or [bingo[0][2],bingo[1][1],bingo[2][0]]==[None]*3:
    ans+=1
if ans==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
A=[]
answer=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=[int(input()) for i in range(N)]
for j in range(N):
    for k in range(3):
        for l in range(3):
            if B[j]==A[k][l]:
                answer[k][l]=1
i=0
J=0
for i in range(3):
    if answer[i][0]==answer[i][1]==answer[i][2]==1:
        print("Yes")
        J=J+1
        break
    elif answer[0][i]==answer[1][i]==answer[2][i]==1:
        J=J+1
        print("Yes")
        break
if J==0 and answer[0][0] == answer[1][1] == answer[2][2] == 1:
    J=J+1
    print("Yes")
if J == 0 and answer[0][2] == answer[1][1] == answer[2][0]== 1:
    J=J+1
    print("Yes")
if J == 0:
    print("No")

Submission status: Accepted

Solution code:
# import numpy as np
# A=np.zeros((3,3))
# A[0][:]=[int(i) for i in input().split()]
# A[1][:]=[int(i) for i in input().split()]
# A[2][:]=[int(i) for i in input().split()]
# N=int(input())
# B=np.zeros((N,1))
# B[:][0]=[int(i) for i in input().splitlines()]
# print(B)

# # A=[]
# # for i in range(3)

A=[]
answer=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=[int(input()) for i in range(N)]
for j in range(N):
    for k in range(3):
        for l in range(3):
            if B[j]==A[k][l]:
                answer[k][l]=1
i=0
J=0
for i in range(3):
    if answer[i][0]==answer[i][1]==answer[i][2]==1:
        print("Yes")
        J=J+1
        break
    elif answer[0][i]==answer[1][i]==answer[2][i]==1:
        J=J+1
        print("Yes")
        break
if J==0 and answer[0][0] == answer[1][1] == answer[2][2] == 1:
    J=J+1
    print("Yes")
if J == 0 and answer[0][2] == answer[1][1] == answer[2][0]== 1:
    J=J+1
    print("Yes")
if J == 0:
    print("No")

Submission status: Accepted

Solution code:
A1, A2, A3 = map(int,input().split())
B1, B2, B3 = map(int,input().split())
C1, C2, C3 = map(int,input().split())

N = int(input())

T1 = []
T2 = []
T3 = []
Y1 = []
Y2 = []
Y3 = []
N1 = []
N2 = []

for i in range(N):
    num = int(input())
    if num == A1:
        T1.append(A1)
        Y1.append(A1)
        N1.append(A1)
    if num == A2:
        T2.append(A2)
        Y1.append(A2)
    if num == A3:
        T3.append(A3)
        Y1.append(A3)
        N2.append(A3)
    if num == B1:
        T1.append(B1)
        Y2.append(B1)
    if num == B2:
        T2.append(B2)
        Y2.append(B2)
        N1.append(B2)
        N2.append(B2)
    if num == B3:
        T3.append(B3)
        Y2.append(B3)
    if num == C1:
        T1.append(C1)
        Y3.append(C1)
        N2.append(C1)
    if num == C2:
        T2.append(C2)
        Y3.append(C2)
    if num == C3:
        T3.append(C3)
        Y3.append(C3)
        N1.append(C3)
    
if len(T1) == 3 or len(T2) == 3 or len(T3) == 3 or len(Y1) == 3 or len(Y2) == 3 or len(Y3) == 3 or len(N1) == 3 or len(N2) == 3:
    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())
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

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

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
bingo = False
for i in range(3):
    if (A[i][0] in B and A[i][1] in B and A[i][2] in B) or (A[0][i] in B and A[1][i] in B and A[2][i] in B):
        bingo = True
if (A[0][0] in B and A[1][1] in B and A[2][2] in B) or (A[0][2] in B and A[1][1] in B and A[2][0] in B):
    bingo = True
print("Yes" if bingo else "No")

Submission status: Accepted

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
for i in range(3):
    if (A[i][0] in B and A[i][1] in B and A[i][2] in B) or (A[0][i] in B and A[1][i] in B and A[2][i] in B):
        print("Yes")
        exit()
if (A[0][0] in B and A[1][1] in B and A[2][2] in B) or (A[0][2] in B and A[1][1] in B and A[2][0] in B):
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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(8):
  list_diff = intersect_list(bingo[num], List)
  if (int(len(list_diff)) == 3):
    print("Yes")
    exit()
  else:
    pass

print("No")

Submission status: Accepted

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]):
        print("Yes")
        break
else:
    if all(is_bingo_flat[::4]) or all(is_bingo_flat[2:7:2]):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
# abc157 b
def ans():
    a = []
    bingo_card = [[0] * 3,[0] * 3,[0] * 3]
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    n = int(input())
    b =[]
    for i in range(n):
        b.append(int(input()))
    for i, v in enumerate(a):
        for j, vv in enumerate(v):
            for k, bingo_value in enumerate(b):
                if vv == bingo_value:
                    bingo_card[i][j] = 1

    for i in range(len(bingo_card)):
        if bingo_card[i][0] * bingo_card[i][1] * bingo_card[i][2] == 1:
            print('Yes')
            return 
    for i in range(len(bingo_card)):
        if bingo_card[0][i] * bingo_card[1][i] * bingo_card[2][i] == 1:
            print('Yes')
            return 
    if bingo_card[0][0]*bingo_card[1][1]*bingo_card[2][2]==1:
        print('Yes')
        return 
    if bingo_card[0][2]*bingo_card[1][1]*bingo_card[2][0]==1:
        print('Yes')
        return 
    print('No')

if __name__ == '__main__':
    ans()

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=[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+a22+a13==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

n = int(input())

for times in range(n):
  b = int(input())
  for cl in range(3):
    for rw in range(3):
      if b == l[cl][rw]:
        l[cl][rw] = 0

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

Submission status: Accepted

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
    counter4=0
    two=False
    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((a[0] == 1 and a[1] == 3) or (a[1]==1 and a[0]==3)):
            counter4+=1
        if(a[0] == 2 and a[1] == 2):
            two=True
    if(3 in counter1 or 3 in counter2 or counter3 >=3 or (two==True and  counter4==2)):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

Size = 3
bingo = False
for row in a:
    if all(item in b for item in row):
        bingo = True
for col in zip(*a):
    if all(item in b for item in col):
        bingo = True
if all(a[i][i] in b for i in range(Size)):
    bingo = True
if all(a[i][Size - 1 - i] in b for i in range(Size)):
    bingo = True
 
print("Yes" if bingo else "No")

Submission status: Accepted

Solution code:
import sys 
A = [input().split() for l in range(3)]
N = int(input())

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

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

for i in range(0,3):
    count = 0
    for j in range(0,3):
        if A[i][j] == '0':
            count += 1
    if count == 3:
        print('Yes')
        sys.exit()

for j in range(0,3):
    count = 0
    for i in range(0,3):
        if A[i][j] == '0':
            count += 1
    if count == 3:
        print('Yes')
        sys.exit()

if A[0][0] == '0' and A[1][1] == '0' and A[2][2] == '0':
    print('Yes')
    sys.exit()
elif A[0][2] == '0' and A[1][1] == '0' and A[2][0] == '0':
    print('Yes')
    sys.exit()
else:
    print('No')
    sys.exit()

Submission status: Accepted

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

for i in B:
    for j in range(len(A)):
        if i == A[j]:
            A[j] = 0
if A[0]+A[1]+A[2] == 0 or A[3]+A[4]+A[5] == 0 or A[6]+A[7]+A[8] == 0 or A[0]+A[3]+A[6] == 0 or A[1]+A[4]+A[7] == 0 or A[2]+A[5]+A[8] == 0 or A[0]+A[4]+A[8] == 0 or A[2]+A[4]+A[6] == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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][0] == 0:
    print("Yes")
    sys.exit(0)
print("No")

Submission status: Accepted

Solution code:
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
 
bingo = [[0 for i in range(3)] for j in range(3)]
 
for i in range(N):
  key = int(input())
  for j in range(3):
    for k in range(3):
      if card[j][k] == key:
        bingo[j][k] += 1

for i in range(3):
  if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
    print('Yes')
    exit()
for i in range(3):
  if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
    print('Yes')
    exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
for i in range(3):
  a = list(map(int,input().split()))
  for j in range(3):
    d[a[j]] = 3*i+j+1
f = [False for _ in range(10)]

N = int(input())
for _ in range(N):
  b = int(input())
  f[d[b]] = True
  
ans = False

for i in range(3):
  ans = ans or (f[3*i+1] and f[3*i+2] and f[3*i+3])
  ans = ans or (f[i+1] and f[i+4] and f[i+7])
  
ans = ans or (f[1] and f[5] and f[9])
ans = ans or (f[3] and f[5] and f[7])

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

Submission status: Accepted

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

bingo = [[0]*3 for _ in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if card[j][k] == An[i]:
                bingo[j][k] += 1

for i in range(3):
    if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
        print('Yes')
        exit()
for i in range(3):
    if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
        print('Yes')
        exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
a1_list = list(map(int, input().split()))
a2_list = list(map(int, input().split()))
a3_list = list(map(int, input().split()))
# a = [a1_list, a2_list, a3_list]
n = int(input())
b_list = []
for i in range(n):
    b_list.append(int(input()))


def is_bingo(a_coor):
    if a_coor[0][0] + a_coor[1][0] + a_coor[2][0] == 0:
        return True
    elif a_coor[0][1] + a_coor[1][1] + a_coor[2][1] == 0:
        return True
    elif a_coor[0][2] + a_coor[1][2] + a_coor[2][2] == 0:
        return True
    elif a_coor[0][0] + a_coor[0][1] + a_coor[0][2] == 0:
        return True
    elif a_coor[1][0] + a_coor[1][1] + a_coor[1][2] == 0:
        return True
    elif a_coor[2][0] + a_coor[2][1] + a_coor[2][2] == 0:
        return True
    elif a_coor[0][0] + a_coor[1][1] + a_coor[2][2] == 0:
        return True
    elif a_coor[2][0] + a_coor[1][1] + a_coor[0][2] == 0:
        return True
    return False


for b in b_list:
    a1_list = [0 if a==b else a for a in a1_list]
    a2_list = [0 if a==b else a for a in a2_list]
    a3_list = [0 if a==b else a for a in a3_list]
if is_bingo([a1_list, a2_list, a3_list]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

for i in range(3):
    if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
        print('Yes')
        exit()
for i in range(3):
    if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
        print('Yes')
        exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')