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):
xs = []                                                                                                                                                                                                                                                                                    
for i in range(3):                                                                                                                                                                                                                                                                         
    x = list(map(int,input().split()))                                                                                                                                                                                                                                                     
    xs.append(x)                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                           
n = int(input())                                                                                                                                                                                                                                                                           
bs = {int(input()) for i in range(n)}                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                           
for i in range(3):                                                                                                                                                                                                                                                                         
    xs[i] = [x in bs for x in xs[i] ]                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                           
flags = []                                                                                                                                                                                                                                                                                 
for i in range(3):                                                                                                                                                                                                                                                                         
    flags.append(all(xs[i]))                                                                                                                                                                                                                                                               
for i in range(3):                                                                                                                                                                                                                                                                         
    flags.append(all([xs[0][i], xs[1][i], xs[2][i]]))                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                           
flags.append(all([xs[0][0], xs[1][1], xs[2][2]]))                                                                                                                                                                                                                                          
flags.append(all([xs[0][2], xs[1][1], xs[2][0]]))                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                           
if any(flags):                                                                                                                                                                                                                                                                             
    print("Yes")                                                                                                                                                                                                                                                                           
else:                                                                                                                                                                                                                                                                                      
    print("No")

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

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

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

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

bingo = tate or yoko or naname

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

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

for i in range(N):
    bingo = input()
    bingo_list.append(bingo)



def bingo_row(p,q):
    row_total= 0
    
    for i in range(3):
        if p[i] in q:
            row_total +=1
        else:
            return False
    if row_total == 3:
        return True

def bingo_column(p,q,r,s):
    batu = 0
    
    for i in range(3):
        
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
                break
            else:
                batu +=1 
        else:
            batu +=1
    if batu == 3:
        return False

def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2] in s:
            return True
        elif p[2] in s and r[0] in s:
            return True
        else:
            return False
    else:
        return False

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

Solution (Python):
m=[0,0,0,0,0,0,0,0,0]
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]:
      m[j]=1
      break

ans=0
for i in range(3):
  if m[i]==1 and m[i+3]==1 and m[i+6]==1:
    ans=1
    break
  if m[i*3]==1 and m[i*3+1]==1 and m[i*3+2]==1:
    ans=1
    break
    
if m[0]==1 and m[4]==1 and m[8]==1:
  ans=1
if m[2]==1 and m[4]==1 and m[6]==1:
  ans=1
  
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np

def is_bingo(bingo):
  tate0 = bingo[0,0]+bingo[1,0]+bingo[2,0]==0
  tate1 = bingo[0,1]+bingo[1,1]+bingo[2,1]==0
  tate2 = bingo[0,2]+bingo[1,2]+bingo[2,2]==0
  yoko0 = bingo[0,0]+bingo[0,1]+bingo[0,2]==0
  yoko1 = bingo[1,0]+bingo[1,1]+bingo[1,2]==0
  yoko2 = bingo[2,0]+bingo[2,1]+bingo[2,2]==0
  naname0 = bingo[0,0]+bingo[1,1]+bingo[2,2]==0
  naname1 = bingo[2,0]+bingo[1,1]+bingo[0,2]==0
  tate = tate0 or tate1 or tate2
  yoko = yoko0 or yoko1 or yoko2
  naname = naname0 or naname1
  bingo = tate or yoko or naname
  return "Yes" if bingo else "No"

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

N = int(input())

for _ in range(N):
  b = int(input())
  i, j = np.where(bingo==b)
  bingo[i, j] = 0

print(is_bingo(bingo))

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


for i in range(N):
    for j in range(len(C)):
        if b[i] == C[j]:
            C[j] = 0


flag = False


if C[0] == C[1]==C[2]:
    flag = True
if C[3] == C[4]==C[5]:
    flag = True
if C[6] == C[7]==C[8]:
    flag = True

if C[0] == C[3]==C[6]:
    flag = True
if C[1] == C[4]==C[7]:
    flag = True
if C[2] == C[5]==C[8]:
    flag = True

if C[0] == C[4]==C[8]:
    flag = True
if C[2] == C[4]==C[6]:
    flag = True

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

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  A = [list(map(int,input().split())) for _ in range(3)]
  n = int(input())
  
  for _ in range(n):
    b = int(input())
    for i in range(3):
      for j in range(3):
        if A[i][j] == b:
          A[i][j] = 0
  
  
  if A[0][0] == A[0][1] == A[0][2] == 0:
    print('Yes')
    exit()
  if A[0][0] == A[1][0] == A[2][0] == 0:
    print('Yes')
    exit()
  if A[0][0] == A[1][1] == A[2][2] == 0:
    print('Yes')
    exit()
  if A[1][0] == A[1][1] == A[1][2] == 0:
    print('Yes')
    exit()
  if A[2][0] == A[2][1] == A[2][2] == 0:
    print('Yes')
    exit()
  if A[2][0] == A[1][1] == A[0][2] == 0:
    print('Yes')
    exit()
  if A[0][1] == A[1][1] == A[2][1] == 0:
    print('Yes')
    exit()
  if A[0][2] == A[1][2] == A[2][2] == 0:
    print('Yes')
    exit()
  print('No')
if __name__ == '__main__':
  main()

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

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

flag = 0

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

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

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

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

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

Solution (Python):

As = [list(map(int, input().split())) for i in range(3)]
N = int(input())
x = []
bingo = [[False]*3 for i in range(3)]
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if As[i][j] == b:
                bingo[i][j] = True

ans = True
for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2] : 
        print("Yes")
        exit()
for j in range(3):
    if bingo[0][j] and bingo[1][j] and bingo[2][j]:
        print("Yes")
        exit()
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    print("Yes" )
    exit()
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
    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()))
N = int(input())
b = [0] * N 
for i in range(N):
    b[i] = int(input())
A = [A1,A2,A3]
B = [[0]*3,[0]*3,[0]*3]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                B[i][j] = 1
if B[0] == [1,1,1]:
    print("Yes")
elif B[1] == [1,1,1]:
    print("Yes")
elif B[2] == [1,1,1]:
    print("Yes")
elif B[0][0] == 1 and B[1][0] == 1 and B[2][0] == 1:
    print("Yes")
elif B[0][1] == 1 and B[1][1] == 1 and B[2][1] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][2] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
    print("Yes")
else:
    print("No")

Solution (Python):

n1 = list(map(int,input().split()))
n2 = list(map(int,input().split()))
n3 = list(map(int,input().split()))

nall  = n1 + n2 + n3



N = int(input())


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




out = []
for i in range(len(nall)):
  if nall[i] in num:
    out.append(i)




out_set = set(out)


bingo1 = [0,1,2]
bingo2 = [3,4,5]
bingo3 = [6,7,8]
bingo4 = [0,3,6]
bingo5 = [1,4,7]
bingo6 = [2,5,8]
bingo7 = [0,4,8]
bingo8 = [6,4,2]

if (set(bingo1) <= set(out_set)) or (set(bingo2) <= set(out_set)) or (set(bingo3) <= set(out_set)) or (set(bingo4) <= set(out_set)) or (set(bingo5) <= set(out_set)) or (set(bingo6) <= set(out_set)) or (set(bingo7) <= set(out_set)) or (set(bingo8) <= set(out_set)):
  print("Yes")
else:
  print("No")

Solution (Python):
Bingo = [[0,0,0],[0,0,0],[0,0,0]]
Bingo[0][0],Bingo[0][1],Bingo[0][2]= map(int, input().split())  
Bingo[1][0],Bingo[1][1],Bingo[1][2]= map(int, input().split()) 
Bingo[2][0],Bingo[2][1],Bingo[2][2]= map(int, input().split()) 
N = int(input())
Numbers = [int(input() )for _ in range(N)]


maru =[[0,0,0],[0,0,0],[0,0,0]]
Flag =0


for Number in Numbers:
  for i in range(3):
    for j in range(3):
      if Bingo[i][j] == Number:
        maru[i][j]=1

for i in range(3):
  if maru[0][i] ==1 and maru[1][i]== 1 and maru[2][i] ==1:
    Flag = 1
    break
    
  if maru[i][0] ==1 and maru[i][1]== 1 and maru[i][2] ==1:
    Flag = 1
    break

  if maru[0][0] ==1 and maru[1][1]== 1 and maru[2][2]==1:
    Flag = 1
    break

  if maru[0][2] ==1 and maru[1][1]== 1 and maru[2][0]==1:
    Flag = 1
    break

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

Solution (Python):
import sys
list1=[]
list3=["Bingo","Bingo","Bingo"]
A1,A2,A3=map(str,input().split())
A4,A5,A6=map(str,input().split())
A7,A8,A9=map(str,input().split())
n=int(input())
list1=[input() for i in range(1,n+1)]
list2=[[A1,A2,A3],
    [A4,A5,A6],
    [A7,A8,A9]]
for y in range(3):
    for x in range(n):
            if (list1[x] in list2[y])==True:
                s=list2[y].index(list1[x])
                list2[y][s]="Bingo"

for i in range(3):
    if list2[i]==list3:
        print("Yes")
        sys.exit()

if list2[0][0]==list2[1][1] and list2[1][1]==list2[2][2]:
    print("Yes")
elif list2[0][2]==list2[1][1] and list2[1][1]==list2[2][0]:
    print("Yes")

elif list2[0][0]==list2[1][0] and list2[1][0]==list2[2][0]:
    print("Yes")
elif list2[0][1]==list2[1][1] and list2[1][1]==list2[2][1]:
    print("Yes")
elif list2[0][2]==list2[1][2] and list2[1][2]==list2[2][2]:
    print("Yes")
elif n<=2:
    print("No")
else:
    print("No")

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

initial_board = [A,B,C,D,E,F,G,H,I]
called = [0]*9

for i in range(9):
  if initial_board[i] in s:
    called[i] = 1

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

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

for _ in range(n):
    b = int(input())
    for rows in range(3):
        for columns in range(3):
            if m[rows][columns] == b:
                m[rows][columns] = 0

for i in range(3):
    if sum(m[i]) == 0:
        print('Yes')
        exit()
for i in range(3):
    if m[0][i] + m[1][i] + m[2][i] == 0:
        print('Yes')
        exit()
if m[0][0] + m[1][1] + m[2][2] == 0: print('Yes'); exit()
if m[0][2] + m[1][1] + m[2][0] == 0: 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 = [[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] = True
if (bingo[0][0] and bingo[1][0] and bingo[2][0]) or (bingo[0][1] and bingo[1][1] and bingo[2][1]) or (bingo[0][2] and bingo[1][2] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[0][1] and bingo[0][2]) or (bingo[1][0] and bingo[1][1] and bingo[1][2]) or (bingo[2][0] and bingo[2][1] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())

    for _ in range(N):
        b = int(input())
        for a_i in range(3):
            for a_j in range(3):
                if A[a_i][a_j] == b:
                    A[a_i][a_j] = "empty"

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

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

    if A[0][0] == "empty" and A[1][1] == "empty" and A[2][2] == "empty":
        ans = "Yes"

    if A[2][0] == "empty" and A[1][1] == "empty" and A[0][2] == "empty":
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

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

for i in N_number:
    for j in Bingo_number:
        for k in range(len(Bingo_number)):
            if i[0] == j[k]:
                j[k] = "+"


ans = 0
count2 = 0
count3 = 0

for i in range(3):
    count = 0
    count1 = 0
    for j in range(3):
        if Bingo_number[i][j] == "+":
            count += 1
        if Bingo_number[j][i] == "+":
            count1 += 1
        if i == j:
            if Bingo_number[i][j] == "+":
                count2 += 1
        if i + j == 2:
            if Bingo_number[i][j] == "+":
                count3 += 1
        
    if count == 3 or count1 == 3 or count2 == 3 or count3 == 3:
        ans += 1

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

Solution (Python):
l = [list(map(int, input().split())) for i in range(3)]
ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N = int(input())

for i in range(N):
    search = int(input())
    f = 0
    for j in range(3):
        for k in range(3):
            if l[j][k] == search:
                f = 1
                ans[j][k] = 1
                break
        if f == 1:
            break

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

Solution (Python):
A = [input().split() for l in range(3)]
N=int(input())
b = [input() for l in range(N)]

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

if (A[0][0]==A[0][1]==A[0][2]) or (A[1][0]==A[1][1]==A[1][2]) or (A[2][0]==A[2][1]==A[2][2]) or (A[0][0]==A[1][0]==A[2][0]) or (A[0][1]==A[1][1]==A[2][1]) or (A[0][2]==A[1][2]==A[2][2]) or (A[1][1]==A[2][2]==A[0][0]) or (A[0][2]==A[1][1]==A[2][0]):
    print('Yes')
else:
    print('No')

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

for i in range(n):
    x = int(input())
    for h in range(3):
        for w in range(3):

            if m[h][w] == x: m[h][w] = 0


for i in range(3):
    if sum(m[i]) == 0 :print('Yes'); exit()

for i in range(3):
    if m[0][i] + m[1][i] + m[2][i] == 0: print('Yes'); exit()

if m[0][0] + m[1][1] + m[2][2] == 0: print('Yes'); exit()
if m[0][2] + m[1][1] + m[2][0] == 0: 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 _ in range(N)]

bingo1 = [0, 0, 0]
bingo2 = [0, 0, 0]
bingo3 = [0, 0, 0]


for i in range(3):
  for j in range(N):
    if A[i][0] == b[j]:
      bingo1[i] = 1
    if A[i][1] == b[j]:
      bingo2[i] = 1
    if A[i][2] == b[j]:
      bingo3[i] = 1
      


if bingo1[0] == bingo1[1] == bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == bingo2[1] == bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == bingo3[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[0] == bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == bingo2[1] == bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == bingo2[2] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[2] == bingo2[1] == bingo3[0] == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
A = [0]*9
A[0], A[1], A[2] = map(int, input().split())
A[3], A[4], A[5] = map(int, input().split())
A[6], A[7], A[8] = map(int, input().split())
N = int(input())
B = [0]*N
for i in range(N):
    B[i] = int(input())
if A[4] in B:
    if A[0] in B and A[8] in B:
        print("Yes")
        exit()
    if A[2] in B and A[6] in B:
        print("Yes")
        exit()
    if A[1] in B and A[7] in B:
        print("Yes")
        exit()
    if A[3] in B and A[5] in B:
        print("Yes")
        exit()
if A[0] in B and A[1] in B and A[2] in B:
    print("Yes")
    exit()
if A[6] in B and A[7] in B and A[8] in B:
    print("Yes")
    exit()
if A[0] in B and A[3] in B and A[6] in B:
    print("Yes")
    exit()
if A[2] in B and A[5] in B and A[8] in B:
    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)]
 
if (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[1][0] in b) and (A[1][1] in b) and (A[1][2] in b) or \
    (A[2][0] in b) and (A[2][1] in b) and (A[2][2] in b) or \
    (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[0][0] in b) and (A[1][0] in b) and (A[2][0] in b) or \
    (A[0][1] in b) and (A[1][1] in b) and (A[2][1] in b) or \
    (A[0][2] in b) and (A[1][2] in b) and (A[2][2] in b) or \
    (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')
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 = []
for i in range(N):
    b.append(int(input()))

A4 = []
A5 = []
A6 = []
A7 = []
A8 = []

A4.append(A1[0])
A4.append(A2[0])
A4.append(A3[0])

A5.append(A1[1])
A5.append(A2[1])
A5.append(A3[1])

A6.append(A1[2])
A6.append(A2[2])
A6.append(A3[2])

A7.append(A1[0])
A7.append(A2[1])
A7.append(A3[2])

A8.append(A1[2])
A8.append(A2[1])
A8.append(A3[0])

if b.count(A1[0]) + b.count(A1[1]) + b.count(A1[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A2[0]) + b.count(A2[1]) + b.count(A2[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A3[0]) + b.count(A3[1]) + b.count(A3[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A4[0]) + b.count(A4[1]) + b.count(A4[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A5[0]) + b.count(A5[1]) + b.count(A5[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A6[0]) + b.count(A6[1]) + b.count(A6[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A7[0]) + b.count(A7[1]) + b.count(A7[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A8[0]) + b.count(A8[1]) + b.count(A8[2]) == 3:
    print ("Yes")
    exit (0)

print ("No")

Solution (Python):
import numpy as np



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

N = int(input())

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

for bi in b:
    A = np.where(A==bi,0,A)

counter = 0

for i in range(3):
    if sum(A[i,:]) == 0:
        counter = 1

for i in range(3):
    if sum(A[:,i]) == 0:
        counter = 1

if np.trace(A) == 0 or np.trace(A[::-1]) == 0:
    counter = 1

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

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

    m = [[0,0,0],[0,0,0],[0,0,0]]

    N = int(input())
    for i in range(N):
        b = int(input())
        for row, a in enumerate(A):
            if b in a:
                found = a.index(b)
                m[row][found] = 1
                break

    if ((m[0][0] == 1 and m[0][1] == 1 and m[0][2] == 1) or
        (m[1][0] == 1 and m[1][1] == 1 and m[1][2] == 1) or
        (m[2][0] == 1 and m[2][1] == 1 and m[2][2] == 1) or
        (m[0][0] == 1 and m[1][0] == 1 and m[2][0] == 1) or
        (m[0][1] == 1 and m[1][1] == 1 and m[2][1] == 1) or
        (m[0][2] == 1 and m[1][2] == 1 and m[2][2] == 1) or
        (m[0][0] == 1 and m[1][1] == 1 and m[2][2] == 1) or
        (m[0][2] == 1 and m[1][1] == 1 and m[2][0] == 1)):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    q2()

Solution (Python):
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=list(int(input()) for i in range(N))
x=[]
for i in range(3):
  for j in range(3):
    if A[i][j] in B:
      x.append(A[i][j])
if A[0][0] in x and A[1][0] in x and A[2][0] in x:
  print("Yes")
elif A[0][1] in x and A[1][1] in x and A[2][1] in x:
  print("Yes")
elif A[0][2] in x and A[1][2] in x and A[2][2] in x:
  print("Yes")
elif A[0][0] in x and A[0][1] in x and A[0][2] in x:
  print("Yes")
elif A[1][0] in x and A[1][1] in x and A[1][2] in x:
  print("Yes")
elif A[2][0] in x and A[2][1] in x and A[2][2] in x:
  print("Yes")
elif A[0][0] in x and A[1][1] in x and A[2][2] in x:
  print("Yes")
elif A[0][2] in x and A[1][1] in x and A[2][0] in x:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np
A = np.array([input().split() for _ in range(3)],np.int64).reshape(3,3)
N = int(input())
for i in range(N):
    b = int(input())
    A[A==b] = 0
    
if np.any(np.all(A==0,axis=0)) or np.any(np.all(A==0,axis=1)) or A[0][0] == A[1][1] == A[2][2] == 0 or A[2][0] == A[1][1] == A[0][2] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
card  = []
balls = []

for _ in range(3):
  card.extend(input().split())

n = int(input())

for _ in range(n):
  balls.append(input())

for i in range(9):
  if card[i] in balls:
    card[i] = "open"

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

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    x = int(input())
    for j in range(3):
        if x in a[j]:
            a[j][a[j].index(x)]=0
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0 or a[0][i]==a[1][i]==a[2][i]==0 or a[0][0]==a[1][1]==a[2][2]==0 or a[0][2]==a[1][1]==a[2][0]==0:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input()))
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")

Solution (Python):
A=open(0).read().split()
print('YNeos'[all(t-set(map(A.index,A[10:])) for t in({0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}))::2])