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.

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
A = A[0] + A[1] + A[2]
N = int(input())
for i in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
lines = [
            [A[0], A[3], A[6]],
            [A[1], A[4], A[7]],
            [A[2], A[5], A[8]],
            [A[0], A[1], A[2]],
            [A[3], A[4], A[5]],
            [A[6], A[7], A[8]],
            [A[0], A[4], A[8]],
            [A[2], A[4], A[6]],
        ]
if [0, 0, 0] in lines:
    print('Yes')
else:
    print('No')

Solution (Python):
array_1 = []
for i in range(3):
    line = input().rstrip().split(' ')
    array_1.append(line)
    


bool_array = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(False)
    bool_array.append(tmp)



num = int(input().rstrip())
for i in range(num):
    input_line = input().rstrip()
    for j in range(3):
        for k in range(3):
            if array_1[j][k] == input_line:
                bool_array[j][k] = True

ans = "No"
for i in range(3):
    if bool_array[i][0] and bool_array[i][1] and bool_array[i][2]:
        ans = 'Yes'

for i in range(3):
    if bool_array[0][i] and bool_array[1][i] and bool_array[2][i]:
        ans = 'Yes'

if bool_array[0][0] and bool_array[1][1] and bool_array[2][2]:
    ans = 'Yes'

if bool_array[0][2] and bool_array[1][1] and bool_array[2][0]:
    ans = 'Yes'
    
    
print(ans)

Solution (Python):
a=[];c=[];d=0;p=0;q=0;r=0;m=0;l=0
for i in range(3) :
    b=list(map(int,input().split()))
    a.append(b)
n=int(input())
for i in range(n) :
    z=int(input())
    c.append(z)
for i in range(len(a)) :
    for j in range(len(a)) :
        if a[i][j] in c :
            a[i][j]=1
for i in range(len(a)) :
    if a[i][0]+a[i][1]+a[i][2]==3 :
        d+=1
for i in range(len(a)) :
    p=p+a[i][0];q=q+a[i][1];r=r+a[i][2]
if p==3 or q==3 or r==3 :
    d+=1
for i in range(len(a)) :
    for j in range(len(a)) :
        if i==j :
            l=l+a[i][j]
        elif i+j==(len(a))-1 :
            m=m+a[i][j]
m=m+a[1][1]
if l==3 or m==3 :
    d+=1
if d==0 :
    print("No")
else :
    print("Yes")

Solution (Python):
list1 = input().split(" ")
list2 = input().split(" ")
list3 = input().split(" ")
count = int(input())
correct = ['o','o','o']
answer = "No"
for i in range(count):
	num = input()
	list1 = ['o' if i == num else i for i in list1]
	list2 = ['o' if i == num else i for i in list2]
	list3 = ['o' if i == num else i for i in list3]
	vlist1 = [list1[0],list2[0],list3[0]]
	vlist2 = [list1[1],list2[1],list3[1]]
	vlist3 = [list1[2],list2[2],list3[2]]
	xlist1 = [list1[0],list2[1],list3[2]]
	xlist2 = [list1[2],list2[1],list3[0]]
	if list1 == correct:
		answer = "Yes"
		break
	elif list2 == correct:
		answer = "Yes"
		break
	elif list3 == correct:
		answer = "Yes"
		break
	elif vlist1 == correct:
		answer = "Yes"
		break
	elif vlist2 == correct:
		answer = "Yes"
		break
	elif vlist3 == correct:
		answer = "Yes"
		break
	elif xlist1 == correct:
		answer = "Yes"
		break
	elif xlist2 == correct:
		answer = "Yes"
		break    
print(answer)

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
d = [[0]*3 for _ in range(3)]

for  _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        d[i][j] = 1
        
ans = "No"
 
for i in range(3):
  if sum(d[i]) == 3:
    ans = "Yes"
    break
  if sum([D[i] for D in d]) == 3:
    ans = "Yes"
    break
if sum([d[i][i] for i in range(3)]) == 3:
  ans = "Yes"
 
if sum([d[i][2 - i] for i in range(3)]) == 3:
  ans = "Yes"
  
print(ans)

Solution (Python):



from math import *
from copy import *
from string import *				
from random import *				
from sys import stdin
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
from collections import defaultdict 

'''

'''

def solve(l):
	n = len(l)
	

L = []
for i in range(3):
	l = list(map(int, stdin.readline().rstrip().split()))
	L.append(l)


N = int(input())
for _ in range(N):
	q = int(input())
	for i in range(3):
		for j in range(3):
			if(L[i][j] == q):
				L[i][j] = -1
f = 0
for i in range(3):
	if(L[i] == [-1,-1,-1]):
		f = 1
if(not f):
	if(L[0][0] == L[1][0] == L[2][0] == -1):
		f = 1
	if(L[0][1] == L[1][1] == L[2][1] == -1):
		f = 1
	if(L[0][2] == L[1][2] == L[2][2] == -1):
		f = 1
	if(L[0][0] == L[1][1] == L[2][2] == -1):
		f = 1
	if(L[0][2] == L[1][1] == L[2][0] == -1):
		f = 1
	


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

Solution (Python):
a1=list(map(int, input().split()))
a2=list(map(int, input().split()))
a3=list(map(int, input().split()))
n=int(input())
a=[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(n):
  b = int(input())
  if b in a1:
    a[0][a1.index(b)] = 1
  elif b in a2:
    a[1][a2.index(b)] = 1
  elif b in a3:
    a[2][a3.index(b)] = 1
ans = 'No'
if a[0] == [1, 1, 1]:
  ans = 'Yes'
elif a[1] == [1, 1, 1]:
  ans = 'Yes'
elif a[2] == [1, 1, 1]:
  ans = 'Yes'
elif a[0][0]==1 and a[1][0]==1 and a[2][0]==1:
  ans = 'Yes'
elif a[0][1]==1 and a[1][1]==1 and a[2][1]==1:
  ans = 'Yes'
elif a[0][2]==1 and a[1][2]==1 and a[2][2]==1:
  ans = 'Yes'
elif a[0][0]==1 and a[1][1]==1 and a[2][2]==1:
  ans = 'Yes'
elif a[0][2]==1 and a[1][1]==1 and a[2][0]==1:
  ans = 'Yes'
print(ans)

Solution (Python):
A = []
for i in range(3):
    A.append([int(x) for x in input().split()])



N = int(input())

for i in range(N):
    b = int(input())

    for m in range(3):
        for n in range(3):
            if A[n][m] == b:
                A[n][m] = '○'

ans = 'No'

for i in range(3):
    if A[i][0] == A[i][1] and A[i][2] == A[i][1] and A[i][0] == '○':
        ans = 'Yes'
        
    if A[0][i] == A[1][i] and A[2][i] == A[1][i] and A[0][i] == '○':
        ans = 'Yes'

if A[0][0] == A[1][1] and A[2][2] == A[1][1] and A[0][0] == '○':
    ans = 'Yes'
    
if A[2][0] == A[1][1] and A[0][2] == A[1][1] and A[2][0] == '○':
    ans = 'Yes'

print(ans)

Solution (Python):
A=tuple(tuple(int(i) for i in input().split()) for j in range(3))
TF=[[False for i in range(3)] for j in range(3)]
N=int(input())
for i in range(N):
  b=int(input())
  for p in range(3):
    for q in range(3):
      if A[p][q] == b:
        TF[p][q]=True
ans=False
for i in range(3):
  if all(TF[i][j] for j in range(3)):
    ans=True
  if all(TF[j][i] for j in range(3)):
    ans=True
if all(TF[j][j] for j in range(3)):
  ans=True
if all(TF[j][-(j+1)] for j in range(3)):
  ans=True
print('Yes' if ans else 'No')

Solution (Python):
bingo = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
ans = []
for m in range(n):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b[m]:
                ans.append([i,j])
for i,j in ans:
    bingo[i][j] = -1
lists = []
cnt = 0

i = 0 
j = 0
if bingo[0][0] == -1 and bingo[0][1] == -1 and bingo[0][2] == -1:
                cnt = 1
if bingo[1][0] == -1 and bingo[1][1] == -1 and bingo[1][2] == -1:
                cnt = 1
if bingo[2][0] == -1 and bingo[2][1] == -1 and bingo[2][2] == -1:
                cnt = 1
if bingo[0][0] == -1 and bingo[1][0] == -1 and bingo[2][0] == -1:
                cnt = 1
if bingo[0][1] == -1 and bingo[1][1] == -1 and bingo[2][1] == -1:
                cnt = 1
if bingo[0][2] == -1 and bingo[1][2] == -1 and bingo[2][2] == -1:
    cnt = 1
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
                cnt = 1
if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1:
                cnt = 1

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

Solution (Python):
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[False]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                card[i][j] = True

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

    
if __name__ == "__main__":
    main()

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
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
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Solution (Python):
def ii():return int(input())
def mi():return map(int,input().split())

a=[]
for _ in range(3):
  a+=list(mi())
n=ii()
b=[]
for i in range(n):
  b+=ii(),

def ana(x):
  if x in b:
    return 1
  else:
    return 0

c=[ana(aa) for aa in a]

oks="012 345 678 036 147 258 048 246".split()

for ok in oks:
  res=1
  for j in list(ok):
    res*=c[int(j)]
  if res==1:
    print("Yes")
    exit()
print("No")

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
tab = [a, b, c]
tab += [[a[0], b[0], c[0]]]
tab += [[a[1], b[1], c[1]]]
tab += [[a[2], b[2], c[2]]]
tab += [[a[0], b[1], c[2]]]
tab += [[a[2], b[1], c[0]]]

n = int(input())
p = []
for _ in range(n):
  x = int(input())
  p.append(x)

for v in tab:  
  x = 0
  for i in v:
    if i in p:
      x += 1
  if x == 3:
    print('Yes')
    exit()
print('No')

Solution (Python):
C = []
C.append(list(map(int, input().split())))
C.append(list(map(int, input().split())))
C.append(list(map(int, input().split())))

B = [[0,0,0],[0,0,0],[0,0,0]]
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if C[j][k]==b:
        B[j][k]=1
  
ans = 'No'

for j in range(3):
  if B[j][0] == 1 and B[j][1] == 1 and B[j][2] == 1:
    ans = "Yes"


for j in range(3):
  if B[0][j] == 1 and B[1][j] == 1 and B[2][j] == 1:
    ans = "Yes"

if B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
  ans ="Yes"
if B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
  ans = 'Yes'

print(ans)

Solution (Python):
A = []
for i in range(3):
    a = input().split()
    a = [int(x) for x in a]
    A.append(a)
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
T = 'No'
for i in range(3):
    if sum(A[i]) == 0:
        T = 'Yes'
        break
    s = 0
    for j in range(3):
        s += A[j][i]
    if s == 0:
        T = "Yes"
if A[0][0]+A[1][1]+A[2][2] == 0 or A[0][2]+A[1][1]+A[2][0] == 0:
    T = 'Yes'
print(T)

Solution (Python):
A = [input().split() for i in range(3)]
B = [[False]*3 for i in range(3)]
n = int(input())
for i in range(n) :
    b = input()
    for j in range(3) :
        for k in range(3) :
            if A[j][k] == b :
                B[j][k] = True

res = "No"
for i in range(3) :
    if B[i][0] == B[i][1] == B[i][2] == True :
        res = "Yes"
    elif B[0][i] == B[1][i] == B[2][i] == True :
        res = "Yes"

if B[0][0] == B[1][1] == B[2][2] == True :
    res = "Yes"
elif B[2][0] == B[1][1] == B[0][2] == True :
    res = "Yes"

print(res)

Solution (Python):
(lambda A:(lambda N:(lambda
C:(lambda d:(lambda B:print
(["No","Yes"][3 in{sum(B[2:
8:2]),sum(B[::4])}|{sum(B[i
*3:i*3+3])for i in range(3)
} | { sum(B[i::3] )for i in
range(3)} ] ) ) ( list(map(
lambda x:d[x],A))))([x in C
for x in range(101)]))({int
(input())for x in range(N)}
))(int(input())))(list(map(
int,input().split()))+list(
map(int,input().split())) +
list(map(int,input().split())))

Solution (Python):
import numpy as np
import sys


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

B = []
for l in sys.stdin:
    if l == '\n':
        break
    l = l.rstrip('\n')
    B.append(int(l))


for i in B:
    A = np.where(A == i, 0, A)

A = np.where(A == B[0], 0, A)


bingo = False

if A[0][0]+A[1][1]+A[2][2] == 0 or A[0][2]+A[1][1]+A[2][0] == 0:
    bingo = True

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

    
    if A[0][i]+A[1][i]+A[2][i]==0:
        bingo = True
        break

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

Solution (Python):




sheet = []
for i in range(3):
    sheet += list(map(int, input().split()))
answer = [False for i in range(9)]




n = int(input())



bs = [int(input()) for i in range(n)]



for b in bs:
    for i in range(9):
        if sheet[i] == b:
            answer[i] = True



res = "No"

for i in range(3):
    if answer[i] and answer[i+3] and answer[i+6]:
        res = "Yes"
    elif answer[3*i] and answer[1+3*i] and answer[2+3*i]:
        res = "Yes"

if answer[0] and answer[4] and answer[8]:
    res= "Yes"
if answer[2] and answer[4] and answer[6]:
    res = "Yes"

print(res)

Solution (Python):
SIZE = 3
A = [[int(i) for i in input().split()] for j in range(SIZE)]
N = int(input())
B = [int(input()) for j in range(N)]


def rotate_counterclockwise(matrix):
    """2次元リストを反時計回りに回転"""
    return list(map(list, zip(*matrix)))[::-1]


for b in B:
    for row in range(SIZE):
        for col in range(SIZE):
            if A[row][col] == b:
                A[row][col] = 0
ans = 'No'
for _ in range(2):
    
    for row in range(SIZE):
        if sum(A[row]) == 0:
            ans = 'Yes'
    if sum(A[k][k] for k in range(SIZE)) == 0:
        ans = 'Yes'
    
    A = rotate_counterclockwise(A)

print(ans)

Solution (Python):
A=[]
B=[False]*9
for i in range(3):
    A+=[int(i) for i in input().split()]
n=int(input())
for _ in range(n):
    b=int(input())
    for i in range(9):
        if b==A[i]:
            B[i]=True
C=[[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
ans=False
for a,b,c in C:
    if B[a-1] and B[b-1] and B[c-1]:
        ans=True
print("Yes" if ans else "No")

Solution (Python):
from collections import defaultdict
def a():
    A = []
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[int(input())] = 1

    B = list(map(lambda x:d[x],A))

    if sum(B[::4]) == 3:
        return 1
    
    if sum(B[2:8:2]) == 3:
        return 1
    
    for i in range(3):
        if sum(B[i*3:i*3+3]) == 3:
            return 1
        if sum(B[i::3]) == 3:
            return 1
    
    return 0

print(["No","Yes"][a()])

Solution (Python):
a,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = []
for j in range(n):
    A.append(int(input()))
if (a in A) and (b in A) and (c in A):
    print("Yes")
elif d in A and e in A and f in A:
    print("Yes")
elif g in A and h in A and i in A:
    print("Yes")
elif a in A and d in A and g in A:
    print("Yes")
elif b in A and e in A and h in A:
    print("Yes")
elif c in A and f in A and i in A:
    print("Yes")
elif a in A and e in A and i in A:
    print("Yes")
elif c in A and e in A and g in A:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines






def main():
	A=[]
	for i in range(3):
		A+=list(map(int,input().split()))
	n=int(input())
	
	for i in range(n):
		b=int(input())
		for j in range(9):
			if b==A[j]:
				A[j]=0
	
	ans="No"
	
	for i in range(3):
		if A[i]==A[i+3]==A[i+6]==0:
			ans="Yes"
		if A[i*3]==A[i*3+1]==A[i*3+2]==0:
			ans="Yes"
	
	if A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:
		ans="Yes"
		
	print(ans)
	
	
	
	
	
	
	
	

if __name__ == "__main__":
	main()

Solution (Python):
A=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for k in range(n):
  s=int(input())
  for i in range(3):
    for j in range(3):
      if s == A[i][j]:
        A[i][j]=0   
if 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 [0,0,0] in A:
  print("Yes")
  
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  
elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
  print("Yes")
  
else:
  print("No")

Solution (Python):
li_a = list(map(int,input().split()))
li_b = list(map(int,input().split()))
li_c = list(map(int,input().split()))
n = int(input())
li_num=[int(input()) for i in range(n)]
 
li_card = [li_a, li_b, li_c]
 
ans = False
 





 
for m in li_num:
    for i in range(3):
        for j in range(3):
          if li_card[i][j] == m:
              li_card[i][j] = 0
 
for i in range(3):
    if li_card[i][0] == li_card[i][1] == li_card[i][2]:
        ans = True
        break
    elif li_card[0][i] == li_card[1][i] == li_card[2][i]:
        ans = True
        break
 
if not ans:
  if li_card[0][0] == li_card[1][1] == li_card[2][2]:
      ans = True
  elif li_card[0][2] == li_card[1][1] == li_card[2][0]:
      ans = True
 
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
a = [list(map(int,input().split()))for i in range(3)]
raw = []
for i in range(3):
    raw.append([a[i][0],a[i][1],a[i][2]])
    raw.append([a[0][i],a[1][i],a[2][i]])
raw.append([a[0][0],a[1][1],a[2][2]])
raw.append([a[0][2],a[1][1],a[2][0]])
cnt = [0]*8
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        if b in raw[j]:cnt[j]+=1
cnt.sort()
if cnt[-1] == 3:print("Yes")
else:print("No")

Solution (Python):
bingo = []
for _ in range(3):
    x,y,z = map(int,input().split())
    bingo.append((x,y,z))
n=int(input())
appear=[[False]*3 for i in range(3)]
b=[]
for _ in range(n):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        for k in range(len(b)):
            if bingo[i][j] == b[k]:
                appear[i][j] = True
ans = "No"
for i in range(3):
    if appear[i][0] and appear[i][1] and appear[i][2]:
        ans = "Yes"
for i in range(3):
    if appear[0][i] and appear[1][i] and appear[2][i]:
        ans = "Yes"
isdia = True
for i in range(3):
    if not appear[i][i]:
        isdia = False
if isdia:
    ans = "Yes"
isdia = True
j = 2
for i in range(3):
    if not appear[i][j-i]:
        isdia = False
if isdia:
    ans = "Yes"
print(ans)

Solution (Python):
li_a = list(map(int,input().split()))
li_b = list(map(int,input().split()))
li_c = list(map(int,input().split()))
n = int(input())
li_num=[int(input()) for i in range(n)]
 
li_card = [li_a, li_b, li_c]
 
ans = False
 





 
for m in li_num:
    for i in range(3):
        for j in range(3):
          if li_card[i][j] == m:
              li_card[i][j] = 0
 
for i in range(3):
    if li_card[i][0] == li_card[i][1] == li_card[i][2] == 0:
        ans = True
        break
    elif li_card[0][i] == li_card[1][i] == li_card[2][i] == 0:
        ans = True
        break
 
if not ans:
  if li_card[0][0] == li_card[1][1] == li_card[2][2] == 0:
      ans = True
  elif li_card[0][2] == li_card[1][1] == li_card[2][0] == 0:
      ans = True
 
if ans:
  print("Yes")
else:
  print("No")

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

def my_index(L, x):
    return L.index(x) if x in L else -1

for k in b:
    for i in range(3):
        if my_index(A[i], k) != -1:
            bingo[i][my_index(A[i], k)] = 1
            
ans = 0
for i in range(3):
    if bingo[i] == [1,1,1]:
        ans = 1
    if bingo[0][i] * bingo[1][i] * bingo[2][i]:
        ans = 1
    if bingo[0][0] * bingo[1][1] * bingo[2][2]:
        ans = 1
    if bingo[0][2] * bingo[1][1] * bingo[2][0]:
        ans = 1
        
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):



def main():
    bingo = []
    bingo.append(list(map(int, input().split())))
    bingo.append(list(map(int, input().split())))
    bingo.append(list(map(int, input().split())))
    
    list1 = [bingo[0][0], bingo[1][0], bingo[2][0]]
    list2 = [bingo[0][1], bingo[1][1], bingo[2][1]]
    list3 = [bingo[0][2], bingo[1][2], bingo[2][2]]
    list4 = [bingo[0][0], bingo[1][1], bingo[2][2]]
    list5 = [bingo[0][2], bingo[1][1], bingo[2][0]]
    
    bingo += list1, list2, list3, list4, list5
    
    n = int(input())
    num = list()
    for _ in range(n):
        num.append(int(input()))
        
    counter = 0   
    for i in range(8):
        for j in range(3):
            if bingo[i][j] in num:
                counter += 1
        if counter == 3:
            print('Yes')
            break
        else:
            counter = 0
            
    if counter != 3:
        print('No')
    
    
    return 0


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    called = [0] * (100 + 1)  

    a = []
    for _ in range(3):
        *row, = map(int, input().split())
        a.append(row)

    n = int(input())
    for _ in range(n):
        b = int(input())
        called[b] = 1

    for r in range(3):
        for c in range(3):
            number = a[r][c]
            if not called[number]:
                break
        else:
            print('Yes')
            return

    for c in range(3):
        for r in range(3):
            number = a[r][c]
            if not called[number]:
                break
        else:
            print('Yes')
            return

    for i in range(3):
        number = a[i][i]
        if not called[number]:
            break
    else:
        print('Yes')
        return

    for i in range(3):
        number = a[i][2 - i]
        if not called[number]:
            break
    else:
        print('Yes')
        return

    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
A = []
out = []
for x in range(3):
    A.append(list(map(int, input().split())))
    out.append([0, 0, 0])
N = int(input())
b = []
for B in range(N):
    b.append(int(input()))
for pick in b:
    for y in range(3):
        for x in range(3):
            if pick == A[y][x]:
                out[y][x] = 1

bingo = False
for x in range(3):
    if out[x][0] == 1 and out[x][1] == 1 and out[x][2] == 1:
        bingo = True

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

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

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

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

Solution (Python):

l_A =  [[0 for i in range(3)] for j in range(3)]
l_A[0] = list(map(int, input().split()))
l_A[1] = list(map(int, input().split()))
l_A[2] = list(map(int, input().split()))

def detect_BINGO(l_Atf):
    
    
    for i in range(3):
        f_detect = True
        for j in range(3):
            
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            
            return True
    
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[j][i]
        if(f_detect):
            
            return True
    
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][3-1-i]
    if(f_detect):
        
        return True
    
    
    return False


l_Atf = [[False for i in range(3)] for j in range(3)]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if(l_A[j][k] == b):
                l_Atf[j][k] = True
    

f_bingo = detect_BINGO(l_Atf)


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

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]

N = int(input())


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


ans = "No"
a = max(sum(A[0]), sum(A[1]), sum(A[2]), (A[0][0] + A[1][0] + A[2][0]), (A[0][1] + A[1][1] + A[2][1]), (A[0][2] + A[1][2] + A[2][2]), (A[0][0] + A[1][1] + A[2][2]), (A[0][2] + A[1][1] + A[2][0]))
if a == 3:
    ans = "Yes"

print(ans)

Solution (Python):
bingo = []
for i in range(3):
    a, b, c = map(int, input().split())
    bingo += [a, b, c]

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

for i in range(len(bingo)):
    if bingo[i] in b_list:
        bingo[i] = 'X'

pattern_list =[[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
flag = 0
for i in range(len(pattern_list)):
    if bingo[pattern_list[i][0]] == 'X' and bingo[pattern_list[i][1]] == 'X' and bingo[pattern_list[i][2]] == 'X':
        flag = 1
        break

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

Solution (Python):
X = [[0 for i in range(3)] for j in range(3)]
for x in range(3):
    Y = list(map(int,input().split()))

    
    for y in range(3):
        X[x][y] = Y[y]




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


for x in B:
    for y in range(3):
        for z in range(3):
            if(X[y][z] == x):
                X[y][z] = True
ans = "No"
for x in range(3):
    if(X[x][0] == True and X[x][1] == True and X[x][2] == True):
        ans = "Yes"
    if(X[0][x] == True and X[1][x] == True and X[2][x] == True):
        ans = "Yes"
if(X[0][0] == True and X[1][1] == True and X[2][2] == True):
    ans = "Yes"
if(X[0][2] == True and X[1][1] == True and X[2][0] == True):
    ans = "Yes"
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))

n = int(input())
for i in range(n):
    b = int(input())

    if b in a1:
        a1[a1.index(b)] = 0
    if b in a2:
        a2[a2.index(b)] = 0
    if b in a3:
        a3[a3.index(b)] = 0


if (a1[0] == a1[1] == a1[2] == 0) or (a2[0] == a2[1] == a2[2] == 0) or (a3[0] == a3[1] == a3[2] == 0) \
    or (a1[0] == a2[0] == a3[0] == 0) or (a1[1] == a2[1] == a3[1] == 0) or (a1[2] == a2[2] == a3[2] == 0) \
    or (a1[0] == a2[1] == a3[2] == 0) or (a1[2] == a2[1] == a3[0] == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
A_list_yoko1 = list(map(int, input().split()))
A_list_yoko2 = list(map(int, input().split()))
A_list_yoko3 = list(map(int, input().split()))
N = int(input())
B_list = []
for i in range(N):
    B_list.append(int(input()))

A_list_tate1 = []
A_list_tate2 = []
A_list_tate3 = []
A_list_naname1 = []
A_list_naname2 = []

A_list_tate1.append(A_list_yoko1[0])
A_list_tate1.append(A_list_yoko2[0])
A_list_tate1.append(A_list_yoko3[0])
A_list_tate2.append(A_list_yoko1[1])
A_list_tate2.append(A_list_yoko2[1])
A_list_tate2.append(A_list_yoko3[1])
A_list_tate3.append(A_list_yoko1[2])
A_list_tate3.append(A_list_yoko2[2])
A_list_tate3.append(A_list_yoko3[2])
A_list_naname1.append(A_list_yoko1[0])
A_list_naname1.append(A_list_yoko2[1])
A_list_naname1.append(A_list_yoko3[2])
A_list_naname2.append(A_list_yoko1[2])
A_list_naname2.append(A_list_yoko2[1])
A_list_naname2.append(A_list_yoko3[0])

A_list_yoko1_c = []
A_list_yoko2_c = []
A_list_yoko3_c = []
A_list_tate1_c = []
A_list_tate2_c = []
A_list_tate3_c = []
A_list_naname1_c = []
A_list_naname2_c = []
for i in B_list:
    if i in A_list_yoko1:
        A_list_yoko1_c.append(A_list_yoko1.index(i))
    if i in A_list_yoko2:
        A_list_yoko2_c.append(A_list_yoko2.index(i))
    if i in A_list_yoko3:
        A_list_yoko3_c.append(A_list_yoko3.index(i))
    if i in A_list_tate1:
        A_list_tate1_c.append(A_list_tate1.index(i))
    if i in A_list_tate2:
        A_list_tate2_c.append(A_list_tate2.index(i))
    if i in A_list_tate3:
        A_list_tate3_c.append(A_list_tate3.index(i))
    if i in A_list_naname1:
        A_list_naname1_c.append(A_list_naname1.index(i))
    if i in A_list_naname2:
        A_list_naname2_c.append(A_list_naname2.index(i))

if len(A_list_naname1_c) == 3 or len(A_list_naname2_c) == 3 or len(A_list_tate1_c) == 3 or len(A_list_tate2_c) == 3 or len(A_list_tate3_c) == 3 or len(A_list_yoko1_c) == 3 or len(A_list_yoko2_c) == 3 or len(A_list_yoko3_c) == 3:
    print("Yes")
else:
    print("No")

Solution (Python):
a=[input().split() for i in range(3)]
n=int(input())
b=[input() for i in range(n)]
flg=0
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j]=0
for n in range(3):
  if a[0][n]==a[1][n]==a[2][n]:
    flg=1
  elif a[n][0]==a[n][1]==a[n][2]:
    flg=1
  elif a[0][0]==a[1][1]==a[2][2]:
    flg=1
  elif a[0][2]==a[1][1]==a[2][0]:
    flg=1
print(['No','Yes'][flg])

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

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B[i] == A[j][k]:
                A[j][k] = 0             
if( ((A[0][0]==0) and (A[1][1]==0) and (A[2][2]==0)) or
   ((A[2][0]==0) and (A[1][1]==0) and (A[0][2]==0)) ):
    print('Yes');exit(0)


for j in range(len(A[0])): 
    if( ((A[j][0]==0) and (A[j][1]==0) and (A[j][2]==0)) or
       ((A[0][j]==0) and (A[1][j]==0) and (A[2][j]==0))    ):    
        print('Yes');
        exit(0)

print('No')

Solution (Python):
import itertools
A = list(itertools.chain.from_iterable([input().split() for _ in range(3)]))
N = int(input())
B = [input() for _ in range(N)]

for i in range(9):
    if A[i] in B:
        A[i] = "Bingo"

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