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=[0,0,0]
S=[0,0,0]
for i in range(3):
    A[i]=[int(x) for x in input().split()]
    S[i]=[0,0,0]
N=int(input())

for i in range(N):
    b=int(input())
    
    for x in range(3):
        for y in range(3):
            if A[x][y]==b:
                S[x][y]=1

flag=False
for i in range(3):
    if S[i]==[1,1,1]:
        flag=True

for i in range(3):
    s=[]
    for k in range(3):
        s.append(S[k][i])
    if s==[1,1,1]:
        flag=True

s=[]
for i in range(3):
    s.append(S[i][i])

if s==[1,1,1]:
    flag=True
        
s=[]
for i in range(3):
    s.append(S[i][2-i])

if s==[1,1,1]:
    flag=True

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

Solution (Python):
a_list = [input().split(" "),input().split(" "),input().split(" ")]
N = int(input())
for i in range(N):
    b = input()
    for j in range(3):
        for k in range(3):
            if a_list[j][k] == b:
                a_list[j][k] = ""
bingo = False
if a_list[0][0] =="" and  a_list[1][1] =="" and  a_list[2][2] == "":
    bingo = True
if a_list[0][2] =="" and  a_list[1][1] =="" and  a_list[2][0] == "":
    bingo = True
for i in range(3):
    if a_list[i][0] == "" and a_list[i][1] == "" and a_list[i][2] == "":
        bingo = True
    elif a_list[0][i] == "" and a_list[1][i] == "" and a_list[2][i] == "":
        bingo = True
if bingo:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
a_list=[]
for i in range(3):
  tmp=list(map(int,input().split()))
  a_list.append(tmp)
a_list=np.array(a_list)
num=int(input())
for i in range(num):
  tmp=int(input())
  a_list[a_list==tmp]=-1
  
yes_no=False
for i in range(3):
  if sum(a_list[i])==-3:
    yes_no=True
    break
  tmp=0
  for j in range(3):
    tmp+=a_list[j][i]
  if tmp==-3:
    yes_no=True
    break
else:
  yes_no=False
tmp=0
tmp2=0
for i in range(3):
  tmp+=a_list[i][i]
  tmp2+=a_list[i][2-i]
if tmp==-3 or tmp2==-3:
  yes_no=True

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

Solution (Python):

import sys


a = [['' for _ in range(3)] for _ in range(3)]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
a[2] = list(map(int, input().split()))
n = int(input())
b = []
for _ in range(n):
    tmp = int(input())
    b.append(tmp)


f = [['' for _ in range(3)] for _ in range(3)]
for i in range(3):
    for j in range(3): f[i][j] = 0

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

for i in range(3):
    s = 0
    for j in range(3):
        s += f[i][j]
    if s == 3:
        print('Yes')
        sys.exit()

for i in range(3):
    s = 0
    for j in range(3):
        s += f[j][i]
    if s == 3:
        print('Yes')
        sys.exit()

if f[0][0] + f[1][1] + f[2][2] == 3:
    print('Yes')
    sys.exit()
if f[0][2] + f[1][1] + f[2][0] == 3:
    print('Yes')
    sys.exit()

print('No')

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

for _ in range(n):
    x = int(input())
    for i in range(3):
        for j in range(3):
            if al[i][j]==x:
                al[i][j] = -1

for i in range(3):
    if -3==sum(al[i]):
        print("Yes")
        exit()

    if -3==sum([al[j][i] for j in range(3)]):
        print("Yes")
        exit()

if al[0][0]+al[1][1]+al[2][2]==-3:
    print("Yes")
    exit()
if al[0][2]+al[1][1]+al[2][0]==-3:
    print("Yes")
    exit()

print("No")

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
flag = False
for i in range(3):
    if all(a[i][j] in b for j in range(3)): 
        flag = True
    if all(a[j][i] in b for j in range(3)):
        flag = True
if all(a[i][i] in b for i in range(3)) or all(a[i][2-i] in b for i in range(3)):
    flag = True
 
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
A = np.array([list(map(int,list(input().split()))) for i in range(3)])
N = int(input())
b = [int(input()) for i in range(N)]

hit = np.zeros_like(A)

for n in b:
	hit[A == n] = 1
if np.sum(np.sum(hit, 0) == 3):
	print('Yes')
elif np.sum(np.sum(hit, 1) == 3):
	print('Yes')
elif hit[0, 0] + hit[1, 1] + hit[2, 2] == 3:
	print('Yes')
elif hit[2, 0] + hit[1, 1] + hit[0, 2] == 3:
	print('Yes')
else:
	print('No')

Solution (Python):
def myAnswer(A: list, B: list, N: int) -> str:
    clomn = [0, 0, 0]
    bingoCard = [[0, 0, 0] for i in range(3)]
    row = [0, 0, 0]
    
    for b in B:
        for i, a in enumerate(A):
            if(b in a):
                bingoCard[i][a.index(b)] = 1
                clomn[i] += 1
                row[a.index(b)] += 1
                break
   
   
   

    
    if(3 in row or 3 in clomn):
        return "Yes"

    
    if(bingoCard[1][1]):
        if((bingoCard[0][0] and bingoCard[2][2]) or (bingoCard[0][2] and bingoCard[2][0])):
            return "Yes"

    
    return "No"


def modelAnswer():
    tmp = 1


def main():
    A = []
    B = []
    for _ in range(3):
        A.append(list(map(int, input().split())))
    N = int(input())
    for _ in range(N):
        B.append(int(input()))
    print(myAnswer(A[:], B[:], N))


if __name__ == '__main__':
    main()

Solution (Python):
def myAnswer(A: list, B: list, N: int) -> str:
    bingoCard = [[0, 0, 0] for i in range(3)]
    row = [0, 0, 0]
    
    for b in B:
        for i, a in enumerate(A):
            if(b in a):
                bingoCard[i][a.index(b)] = 1
                row[a.index(b)] += 1
                break
    for n, b in enumerate(bingoCard):
        if(sum(b) == 3):
            return "Yes"  

    
    if(3 in row):
        return "Yes"

    
    if(bingoCard[1][1]):
        if((bingoCard[0][0] and bingoCard[2][2]) or (bingoCard[0][2] and bingoCard[2][0])):
            return "Yes"

    
    return "No"


def modelAnswer():
    tmp = 1


def main():
    A = []
    B = []
    for _ in range(3):
        A.append(list(map(int, input().split())))
    N = int(input())
    for _ in range(N):
        B.append(int(input()))
    print(myAnswer(A[:], B[:], N))


if __name__ == '__main__':
    main()

Solution (Python):
A=[[int(_) for _ in input().split()] for i in range(3)]
flag=[[0]*3 for i in range(3)]
n=int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                flag[i][j]=1
import numpy as np
if (3 in np.sum(flag,axis=0)) or (3 in np.sum(flag,axis=1)) or (((flag[0][0]==flag[1][1] and flag[1][1]==flag[2][2]) or (flag[0][2]==flag[1][1] and flag[1][1]==flag[2][0])) and flag[1][1]==1):
    print("Yes")
else:
    print("No")

Solution (Python):

def myAnswer(A:list,B:list,N:int) -> str:
   bingo=[[0,0,0] for i in range(3)]
   for b in B:
      for i,a in enumerate(A):
         if(b in a):
            bingo[i][a.index(b)] = 1
            break
   tate=[0,0,0]
   for n,b in enumerate(bingo):
      if(sum(b) == 3):
         return "Yes"
      for i in range(3):
         tate[i] += b[i]
   if(3 in tate): return "Yes"
   if(bingo[1][1] == 1):
      if((bingo[0][0] == 1 and bingo[2][2] == 1) or (bingo[0][2]==1 and bingo[2][0]==1)):
         return "Yes"
   return "No"

def modelAnswer():
   tmp=1
def main():
   A=[]
   B=[]
   for _ in range(3):
      A.append(list(map(int,input().split())))
   N = int(input())
   for _ in range(N):
      B.append(int(input()))
   print(myAnswer(A[:],B[:],N))

if __name__ == '__main__':
   main()

Solution (Python):
A = []*3

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

for i in range(N):
    aaa = int(input())
    for m in range(3):
        for n in range(3):
            if A[m][n] == aaa:
                A[m][n] = 0

    for k in range(3):
        if A[0][k] == A[1][k] and A[0][k] == A[2][k]:
            flag = 1
            break
        if A[k][0] == A[k][1] and A[k][0] == A[k][2]:
            flag = 1
            break
    if A[0][0] == A[1][1] and A[0][0] == A[2][2]:
        flag = 1
        break
    if A[0][2] == A[1][1] and A[0][2] == A[2][0]:
        flag = 1
        break


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

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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)

Solution (Python):
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')

Solution (Python):
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()

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):


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

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


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


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

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

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

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

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

Solution (Python):
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

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):













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

Solution (Python):
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")

Solution (Python):

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

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):

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


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

Solution (Python):

import math
ls=[]
for i in range(3):
    ls.append(list(map(int,input().split())))
ans=[[0,0,0],[0,0,0],[0,0,0]]
n=int(input())
for i in range(n):
    a=int(input())
    for j in range(3):
        for k in range(3):
            if a==ls[j][k]:
                ans[j][k]=1
res=[]
for i in range(3):
    total=0
    for j in range(3):
        total+=ans[i][j]
    res.append(total)
var=0
while var<3:
    total=0
    for i in range(3):
        total+=ans[i][var]
    var+=1
    res.append(total)
res.append(ans[0][0]+ans[1][1]+ans[2][2])
res.append(ans[0][2]+ans[1][1]+ans[2][0])
res.sort()


if res[len(res)-1]==3:
    print("Yes")
else:
    print("No")

Solution (Python):
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")

Solution (Python):

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

Solution (Python):
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')

Solution (Python):
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")