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):
import sys

input = sys.stdin.readline

a = [list(map(int, input().split())) for _ in range(3)]
marked = [[False, False, False] for _ in range(3)]

Q = int(input())
for i in range(Q):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                marked[j][k] = True
                
for i in range(3):
    if marked[i][0] == marked[i][1] == marked[i][2] == True:
        print("Yes")
        exit()
    if marked[0][i] == marked[1][i] == marked[2][i] == True:
        print("Yes")
        exit()
if marked[0][0] == marked[1][1] == marked[2][2] == True:
    print("Yes")
    exit()
if marked[0][2] == marked[1][1] == marked[2][0] == True:
    print("Yes")
    exit()
print("No")

Solution (Python):
import sys
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[list(map(int,input().split())) for i in range(N)]
flat=[j for i in A for j in i]
for i,value in enumerate(flat):
    if [value] in b:
         flat[i]=-1
for i in range(3):
    if flat[i*3]==flat[i*3+1]==flat[i*3+2]==-1:
        print('Yes')
        sys.exit()
    if flat[i]==flat[i+3]==flat[i+6]==-1:
        print('Yes')
        sys.exit()
if flat[0]==flat[4]==flat[8]==-1 or flat[2]==flat[4]==flat[6]==-1:
    print('Yes')
    sys.exit()
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())
for i in range(n):
    p=int(input())
    for q in range(3):
        if a[q]==p:
            a[q]=0
        if b[q]==p:
            b[q]=0
        if c[q]==p:
            c[q]=0
f=0
if a[0]==a[1]==a[2] or b[0]==b[1]==b[2] or c[0]==c[1]==c[2]:
    f=1
if a[0]==b[0]==c[0] or a[1]==b[1]==c[1] or a[2]==b[2]==c[2]:
    f=1
if a[0]==b[1]==c[2] or a[2]==b[1]==c[0]:
    f=1
print("Yes" if f==1 else "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())
l=list()
for i in range(N):
  b=int(input())
  l.append(b)

if A in l and B in l and C in l:
  print('Yes')
  exit()

if A in l and D in l and G in l:
  print('Yes')
  exit()
  
if A in l and E in l and I in l:
  print('Yes')
  exit()

if D in l and E in l and F in l:
  print('Yes')
  exit()
  
if G in l and H in l and I in l:
  print('Yes')
  exit()

if B in l and E in l and H in l:
  print('Yes')
  exit()
  
if C in l and F in l and I in l:
  print('Yes')
  exit()
  
if C in l and E in l and G in l:
  print('Yes')
  exit()
  
else:
  print('No')

Solution (Python):
f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[2] == 'X':
    ans += 1
elif f[2] == 'X' and s[1] == 'X' and t[0] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
elif ans == 0:
    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 = []
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0

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

print("No")
exit()

Solution (Python):
A = list()
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(len(A)):
    if A[j] == b:
      A[j] = 0

for i in range(3):
  if A[3*i:3*i+3] == [0, 0, 0]:
    print('Yes')
    exit()
  elif [A[i], A[i+3], A[i+6]] == [0, 0, 0]:
    print('Yes')
    exit()
  elif [A[0], A[4], A[8]] == [0, 0, 0] or [A[2], A[4], A[6]] == [0, 0, 0]:
    print('Yes')
    exit()
print('No')

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

Solution (Python):
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
        
bingo = False
for row in A:
  if sum(row) == 0:
    bingo = True
for col in zip(*A):
  if sum(col) == 0:
    bingo = True
if sum(A[i][i] for i in range(3)) == 0:
  bingo =True
if sum(A[i][3 - i - 1] for i in range(3)) == 0:
  bingo = True
  
print("Yes" if bingo == True else "No")

Solution (Python):
import numpy as np
a = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)] 

a = np.array(a,  dtype=np.int64).reshape(9)
b = np.array(b, dtype=np.int64)

for i in range(N):
    for j in range(len(a)):
        if b[i] == a[j]:
            a[j] = -1

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

Solution (Python):
import itertools

def judge():
  for i in range(3):
    if A[i*3 + 0] + A[i*3 + 1] + A[i*3 + 2]  == 0 or A[0*3 + i] + A[1*3 + i] + A[2*3 + i]  == 0:
      return True
  if A[0*3 + 0] + A[1*3 + 1] + A[2*3 + 2]  == 0 or A[2*3 + 0] + A[1*3 + 1] + A[0*3 + 2]  == 0:
    return True
  return False

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

N = int(input())

for _ in range(N):
  b = int(input())
  A = [0 if i == b else i for i in A]
  
if judge():
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

a = []

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

n = int(input())
for j in range(n):
    tmp = int(input())
    for x in range(3):
        for y in range(3):
            if(a[x][y] == tmp):
                a[x][y] = 0


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

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

R1 = [False] * 3
R2 = [False] * 3
R3 = [False] * 3

for b in B:
    if b in A1:
        R1[A1.index(b)] = True
    if b in A2:
        R2[A2.index(b)] = True
    if b in A3:
        R3[A3.index(b)] = True

if R1[0] and R1[1] and R1[2]:
    print("Yes")
    sys.exit(0)

if R2[0] and R2[1] and R2[2]:
    print("Yes")
    sys.exit(0)

if R3[0] and R3[1] and R3[2]:
    print("Yes")
    sys.exit(0)

if R1[0] and R2[0] and R3[0]:
    print("Yes")
    sys.exit(0)

if R1[1] and R2[1] and R3[1]:
    print("Yes")
    sys.exit(0)

if R1[2] and R2[2] and R3[2]:
    print("Yes")
    sys.exit(0)

if R1[0] and R2[1] and R3[2]:
    print("Yes")
    sys.exit(0)

if R1[2] and R2[1] and R3[0]:
    print("Yes")
    sys.exit(0)
    
print("No")

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

Solution (Python):


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

N = int(input())
B = [[False] * 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:
                B[i][j] = True

ans = 'No'
for i in range(3):
    if B[i][0] == B[i][1] == B[i][2] == True:
        ans = 'Yes'
    if B[0][i] == B[1][i] == B[2][i] == True:
        ans = 'Yes'
if B[0][0] == B[1][1] == B[2][2] == True:
    ans = 'Yes'
if B[0][2] == B[1][1] == B[2][0] == True:
    ans = 'Yes'

print(ans)

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):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
flag=False
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0:
        flag=True
for i in range(3):
    if a[0][i]==a[1][i]==a[2][i]==0:
        flag=True
if a[0][0]==a[1][1]==a[2][2]==0:
    flag=True
if a[0][2]==a[1][1]==a[2][0]==0:
    flag=True
print('Yes' if flag else 'No')

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

Solution (Python):
def resolve():
  A = [[int(item) for item in input().split()] for i in range(3)]
  N = int(input())
  B = [int(input()) for i in range(N)]
  
  table = [[a in B for a in row] for row in A]
  
  for i in range(3):
    if table[i][0] == table[i][1] == table[i][2] == True:
      print("Yes")
      return
    if table[0][i] == table[1][i] == table[2][i] == True:
      print("Yes")
      return
    
  if table[0][0] == table[1][1] == table[2][2] == True or table[0][2] == table[1][1] == table[2][0] == True:
    print("Yes")
    return 
  
  print("No")
  
resolve()

Solution (Python):
a=[[],[],[]]

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

n = int(input())

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

y0 = (a[0][0] == a[0][1] == a[0][2])
y1 = (a[1][0] == a[1][1] == a[1][2])
y2 = (a[2][0] == a[2][1] == a[2][2])

t0 = (a[0][0] == a[1][0] == a[2][0])
t1 = (a[0][1] == a[1][1] == a[2][1])
t2 = (a[0][2] == a[1][2] == a[2][2])

n1 = (a[0][0] == a[1][1] == a[2][2])
n2 = (a[0][2] == a[1][1] == a[2][0])

if y0 or y1 or y2 or t0 or t1 or t2 or n1 or n2:
    print('Yes')
else :
    print('No')

Solution (Python):

import collections
import itertools as it
import math
import numpy as np
 


yoko = [list(map(int, input().split())) for _ in range(3)]
is_flag = [False] * 9





yoko = list(np.array(yoko).flatten())

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

    if b in yoko:
        is_flag[yoko.index(b)] = True

is_flag = list(np.array(is_flag).reshape(3, 3))

line = is_flag 
line += list(np.array(is_flag).T) 
line += [[line[0][0], line[1][1], line[2][2]], [line[0][2], line[1][1], line[2][0]]]

for l in line:
    if sum(l) == 3:
        print('Yes')
        break
else:
    print('No')

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

for a in A:
    for i, x in enumerate(a):
        if x in b:
            a[i] = "o"


for a in A:
    if len(set(a)) == 1:
        print("Yes")
        exit()


T = []
for i in range(3):
    temp = []
    for j in range(3):
        temp.append(A[j][i])
    T.append(temp)

for t in T:
    if len(set(t)) == 1:
        print("Yes")
        exit()


if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    print("Yes")
    exit()

print("No")

Solution (Python):
def resolve():
    a = [[int(i) for i in input().split()] for _ in range(3)]
    ans = 'No'
    n = int(input())
    for _ in range(n):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if b == a[i][j]:
                    a[i][j] = 0

    for i in range(3):
        if sum(a[i]) == 0 or sum([a[0][i], a[1][i], a[2][i]]) == 0:
            ans = 'Yes'
        elif sum([a[0][0], a[1][1], a[2][2]]) == 0 or sum([a[0][2], a[1][1], a[2][0]]) == 0:
            ans = 'Yes'
    print(ans)

resolve()

Solution (Python):
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
ans = False     
for row in A:
    if sum(row) == 0:
        ans = True
for col in zip(*A):
    if sum(col) == 0:
        ans = True

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A = [list(map(int,rl().split())) for _ in range(3)]
    N = int(rl())
    b = [int(rl()) for _ in range(N)]
    
    bingo = [[False] * 3 for _ in range(3)]
    for bi in b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == bi:
                    bingo[i][j] = True
    
    for i in range(3):
        cnt = 0
        for j in range(3):
            cnt += bingo[i][j]
        if cnt == 3:
            print("Yes")
            exit()
    for i in range(3):
        cnt = 0
        for j in range(3):
            cnt += bingo[j][i]
        if cnt == 3:
            print("Yes")
            exit()
    cnt = 0
    for i in range(3):
        cnt += bingo[i][i]
    if cnt == 3:
        print("Yes")
        exit()
    cnt = 0
    for i, j in[[0, 2],[1,1],[2,0]]:
        cnt += bingo[i][j]
    if cnt == 3:
        print("Yes")
        exit()
    print("No")
    

if __name__ == '__main__':
    solve()

Solution (Python):
import numpy as np

A = np.zeros([3, 3], dtype=int)
M = np.zeros([3, 3], dtype=int)

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

for b in B:
    M[A == b] = 1

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  
def Is(): return map(int, input().split())  
def LI(): return list(map(int, input().split()))  
def TI(): return tuple(map(int, input().split()))  
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  
def LS(): return list(input())  
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

A = LIR(3)
n = I()
B = IR(n)

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

for i in range(3):
    if A[0][i] == A[1][i] == A[2][i] == 0:
        print("Yes")
        exit()

for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        print("Yes")
        exit()

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

if A[2][0] == A[1][1] == A[0][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()))
bingo_num = []
judge = False
N = int(input())
for i in range(N):
  bingo_num.append(int(input()))
for i in bingo_num:
  for a in range(len(A1)):
    if A1[a] == i:
      A1[a] = -1
  for b in range(len(A2)):
    if A2[b] == i:
      A2[b] = -1
  for c in range(len(A3)):
    if A3[c] == i:
      A3[c] = -1
if sum(A1) == -3 or sum(A2) == -3 or sum(A3) == -3:
  judge = True
for i in range(len(A1)):
  if A1[i] + A2[i] + A3[i] == -3:
    judge = True
if A1[0] + A2[1] + A3[2] == -3 or A1[2] + A2[1] + A3[0] == -3:
  judge = True
if judge:
  print('Yes')
else:
  print('No')

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


for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == a[j][k]:
                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):
import sys
table = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
    cmd = int(input())
    for i in range(3):
        for j in range(3):
            if table[i][j] == cmd:
                table[i][j] = -1
                break
for i in range(3):
    if (table[i][0]==-1 and table[i][1]==-1 and table[i][2]==-1) or \
        (table[0][i]==-1 and table[1][i]==-1 and table[2][i]==-1):
        print("Yes")
        sys.exit()
if (table[0][0]==-1 and table[1][1]==-1 and table[2][2]==-1) or \
    (table[0][2]==-1 and table[1][1]==-1 and table[2][0]==-1):
    print("Yes")
    sys.exit()
print("No")

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





for i in range(3):
    for j in range(3):
        if A[i][j] in T:
            A[i][j] = 999



for i in range(3):
    if A[i][0] + A[i][1] + A[i][2] == 999 * 3:
        print("Yes")
        exit()
    if A[0][i] + A[1][i] + A[2][i] == 999 * 3:
        print("Yes")
        exit()

if A[0][0] + A[1][1] + A[2][2] == 999 * 3:
    print("Yes")
    exit()
if A[2][0] + A[1][1] + A[0][2] == 999 * 3:
    print("Yes")
    exit()

print("No")

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush



def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

def main():
    mod = 10**9+7
    

    
    
    
    
    A = tuple(tuple(map(int, input().split())) for i in range(3)) 
    N = int(input())
    B = tuple(int(input()) for i in range(N))
    tset=set()
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j]==b:
                    tset.add(i*4+j)
    flag=False
    for i in range(3):
        if i*4 in tset and i*4+1 in tset and i*4+2 in tset:
            flag=True
        elif i in tset and 4+i in tset and 8+i in tset:
            flag=True
    if 0 in tset and 5 in tset and 10 in tset:
        flag=True
    elif 2 in tset and 5 in tset and 8 in tset:
        flag=True

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





if __name__ == "__main__":
    main()

Solution (Python):
card=[]
for i in range(3):
  card.append(list(map(int,input().split())))
n = int(input())
for i in range(n):
  k = int(input())
  for i in range(3):
    for j in range(3):
      if k == card[i][j]:
        card[i][j] = -1

bingo=False
for i in range(3):
  if card[0][i] == -1 and card[1][i] == -1 and card[2][i] == -1:
    bingo=True
  if card[i][0] == -1 and card[i][1] == -1 and card[i][2] == -1:
    bingo=True
if card[0][0] == -1 and card[1][1] == -1 and card[2][2] == -1:
  bingo=True
if card[2][0] == -1 and card[1][1] == -1 and card[0][2] == -1:
  bingo=True
if bingo:
  print("Yes")
else:
  print("No")

Solution (Python):
card = [0]*3
for i in range(3):
    a = input().split()
    card[i] = [int(s) for s in a]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == card[j][k]:
                card[j][k] = 0
if (card[0][0] == 0 and card[1][0] == 0 and card[2][0] == 0) or (card[0][1] == 0 and card[1][1] == 0 and card[2][1] == 0) or (card[0][2] == 0 and card[1][2] == 0 and card[2][2] == 0) or(card[0][0] == 0 and card[0][1] == 0 and card[0][2] == 0) or (card[1][0] == 0 and card[1][1] == 0 and card[1][2] == 0) or (card[2][0] == 0 and card[2][1] == 0 and card[2][2] == 0) or (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or (card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')
import numpy as np

def solve():
    A = LLI(3)
    
    n = II()
    C = np.array([[0, 0, 0] for _ in range(3)])
    
    for i in range(n):
        b = II()
        for j in range(3):
            for k in range(3):
                if A[j][k] == b:
                    C[j][k] = 1

    
    
    for i in range(3):
        
        
        if sum(C[:, i]) == 3 or sum(C[i, :]) == 3:
            print('Yes')
            return

    
    if C[0][0] + C[1][1] + C[2][2] == 3 or C[0][2] + C[1][1] + C[2][0] == 3:
        print('Yes')
        return

    print('No')



if __name__ == '__main__':
    solve()

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 i in range(n):
    b = int(input())
    a = [0 if b == a[i] else a[i] for i in range(9)]

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

Solution (Python):
dic = {}
for i in range(3):
  arr = input().split()
  for j in range(3):
    dic[arr[j]] = (i,j)
    
n = int(input())
appear=[[False for _ in range(3)] for __ in range(3)]

for _ in range(n):
  b = input()
  if b in dic:
    i, j = dic[b]
    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'
    break
  if appear[0][i] and appear[1][i] and appear[2][i]:
    ans = 'Yes'
    break
if appear[0][0] and appear[1][1] and appear[2][2]:
  ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
  ans = 'Yes'
print(ans)

Solution (Python):
import numpy as np

A = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
for i in range(n):
  b = int(input())
  A = np.where(A == b, -1, A)

if -3 in np.sum(A, axis=0) or -3 in np.sum(A, axis=1) or A[0,0] + A[1,1] + A[2,2] == -3 or A[0,2] + A[1,1] + A[2,0] ==-3:
  print("Yes")
else:
  print("No")

Solution (Python):

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

B = [input() for _ in range(N)]

result = False

for x in range(len(B)):
    for y in range(3):
        for z in range(3):
            
            
            if A[y][z] == B[x]:
                A[y][z] = 0

for i in range(3):
        if A[i][0] == A[i][1] == A[i][2]:
            result = True
            break

for i in range(3):
        if A[0][i] == A[1][i] == A[2][i]:
            result = True
            break

if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    result = True
    


if result == False:
    print("No")
else:
    print("Yes")

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())
dic = {0:False,1:False,2:False,3:False,4:False,5:False,6:False,7:False,8:False}
for i in range(N):
    called = int(input())
    for j in range(9):
        if called == A[j//3][j%3]:
            dic[j] = True
            continue
if dic[0] == dic[1] == dic[2] == True or dic[3] == dic[4] == dic[5] == True or dic[6] == dic[7] == dic[8] == True or dic[0] == dic[3] == dic[6] == True or dic[1] == dic[4] == dic[7] == True or dic[2] == dic[5] == dic[8] == True or dic[0] == dic[4] == dic[8] == True or dic[2] == dic[4] == dic[6] == True:
    print("Yes")
else:
    print("No")

Solution (Python):
A1 = [int(_) for _ in input().split()]
A2 = [int(_) for _ in input().split()]
A3 = [int(_) for _ in input().split()]
P = [A1, A2, A3]
for i in range(3):
    P.append([A1[i], A2[i], A3[i]])
P.append([A1[0], A2[1], A3[2]])
P.append([A1[2], A2[1], A3[0]])


N = int(input())
B = []
for i in range(N):
    b = int(input())
    B.append(b)
for p in P:
    if len(set(p) & set(B)) == 3:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
A = [[int(i) for i in readline().split()] for _ in range(3)]
n = int(readline())
b = [int(readline()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 0
        
if A[0][0]+A[1][1]+A[2][2] == 0 \
or A[0][2]+A[1][1]+A[2][0] == 0 \
or A[0][0]+A[0][1]+A[0][2] == 0 \
or A[1][0]+A[1][1]+A[1][2] == 0 \
or A[2][0]+A[2][1]+A[2][2] == 0 \
or A[0][0]+A[1][0]+A[2][0] == 0 \
or A[0][1]+A[1][1]+A[2][1] == 0 \
or A[0][2]+A[1][2]+A[2][2] == 0 :
    print('Yes')
else:
    print('No')

Solution (Python):
seat=[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 seat[j]:
            seat[j][seat[j].index(x)]=0


f = False
for i in range(3):
    if seat[i][0]==0 and seat[i][1]==0 and seat[i][2]==0:
        f = True
    if seat[0][i] == 0 and seat[1][i] == 0 and seat[2][i] == 0:
        f = True
if seat[0][0]==0 and seat[1][1]==0 and seat[2][2]==0:
    f = True
if seat[0][2]==0 and seat[1][1]==0 and seat[0][2]==0:
    f = True

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

Solution (Python):
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

a = readInts()+readInts()+readInts()

n = readInt()
b = []
for i in range(n):
	b = readInt()
	if b in a:
		c = a.index(b)
		a[c] = 0

for i in [0,3,6]:
	if a[i]+a[i+1]+a[i+2]==0:
		print("Yes")
		exit()
for i in [0,1,2]:
	if a[i]+a[i+3]+a[i+6]==0:
		print("Yes")
		exit()
if a[0]+a[4]+a[8]==0 or a[2]+a[4]+a[6]==0:
	print("Yes")
	exit()

print("No")