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 numpy as np 
A=[]
A.extend(list(map(int,input().split())))
A.extend(list(map(int,input().split())))
A.extend(list(map(int,input().split())))
N = int(input())
check = [False]*9
for i in range(N):
    b=int(input())
    if(b in A):
        check[A.index(b)]=True
posi_list=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
np_check=np.array(check)
for i in range(len(posi_list)):
    if (False not in np_check[posi_list[i]]):
        print('Yes')
        exit()
print('No')

Solution (Python):
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))

n = int(input())
nums = []
ans = "No"


for i in range(0, n):
  nums.append(int(input()))

for i in range(0,3):
  if row1[i] in nums: row1[i] = "O"
  if row2[i] in nums: row2[i] = "O"
  if row3[i] in nums: row3[i] = "O"


for i in range(0,3):
  if row1[i] == row2[i] == row3[i]: ans = "Yes"
    

if row1 == ["O","O","O"] or row2 == ["O","O","O"] or row3 == ["O","O","O"]: ans = "Yes"
  

if row1[0] == row2[1] == row3[2] or row1[2] == row2[1] == row3[0]: ans = "Yes"
  
print(ans)

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

a = np.array([iarr() for i in range(3)])
n = iinput()
for i in range(n):
    b = iinput()
    for i in range(3):
        for j in range(3):
            if a[i][j] == b: a[i][j] = 0

vertical = np.all(a == 0, axis=0)
horizontal = np.all(a == 0, axis=1)
diagonal = a[0][0]==a[1][1]==a[2][2]==0 or a[0][2]==a[1][1]==a[2][0]
flag = np.any(vertical==1) or np.any(horizontal==1) or diagonal
ans = "Yes" if flag else "No"
print(ans)

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 = []
for l in sys.stdin:
    b.append(int(l))

def bingo():
  if len(set(a1) &  set(b)) == 3 or len(set(a2) &  set(b)) == 3 or len(set(a3) &  set(b)) == 3:
    print('Yes')
    return
  
  if a1[0] in b and a2[1] in b and a3[2] in b: 
    print('Yes')
    return
  
  if a1[2] in b and a2[1] in b and a3[0] in b: 
    print('Yes')
    return
  
  for i in range(3):
    if a1[i] in b and a2[i] in b and a3[i] in b:
      print('Yes')
      return
  print('No')
  return

bingo()

Solution (Python):

a_list = list(list(map(int, input().split())) for _ in range(3))

li = []
n = int(input())
nums = list(int(input()) for _ in range(n))

for i in range(0,3):
    dum = []
    for j in range(0,3):
        if a_list[i][j] in nums:
            dum.append(1)
        else:
            dum.append(0)
    li.append(dum)
ans = 'No'
for i in range(0,3):
    if li[i][0] and li[i][1] and li[i][2]:
        ans = 'Yes'

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

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


    

print(ans)

Solution (Python):
import sys
import numpy as np
bingo = []
for _ in range(3):
    bingo.append(list(map(int,input().split())))

cl = np.array([[0,0,0],[0,0,0],[0,0,0]])

n = int(input())
st = set()
for _ in range(n):
    st.add(int(input()))

for _ in range(len(st)):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] in st:
                cl[i,j] = 1

if sum(cl[0]) == 3 or sum(cl[1]) == 3 or sum(cl[2]) == 3:
    print('Yes')
elif sum(cl[:,0]) == 3 or sum(cl[:,1]) == 3 or sum(cl[:,2]) == 3:
    print('Yes')
elif cl[0,0]+cl[1,1]+cl[2,2] == 3 or cl[0,2]+cl[1,1]+cl[2,0] == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import numpy as np

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

nums = np.array(read().split(), np.int64)

A = nums[:9]

for x in nums[10:]:
    A[A == x] = 0

def check(A):
    for i, j, k 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)):
        if A[i] == A[j] == A[k] == 0:
            return True
    return False

print('Yes' if check(A) else 'No')

Solution (Python):
from itertools import combinations
A1,A2,A3=(map(int,input().split()))
A4,A5,A6=(map(int,input().split()))
A7,A8,A9=(map(int,input().split()))
x=[A1,A2,A3,A4,A5,A6,A7,A8,A9]
N=int(input())
num=[]
win=[]
for i in range(0,N):
    num.append(int(input()))
for i in num:
    if i in x:
        y=x.index(i)+1
        win.append(y)
        win.sort()
win1=[(1,2,3),(4,5,6),(7,8,9),(1,4,7),(2,5,8),(3,6,9),(1,5,9),(3,5,7)]
a=list(combinations(win,3))
for i in a:
    if i in win1:
        print('Yes')
        break
else:
    print('No')

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

if (a[0][0] in c and a[0][1] in c and a[0][2] in c) or (a[1][0] in c and a[1][1] in c and a[1][2] in c) or (a[2][0] in c and a[2][1] in c and a[2][2] in c) or (a[0][0] in c and a[1][0] in c and a[2][0] in c) or (a[0][1] in c and a[1][1] in c and a[2][1] in c) or (a[0][2] in c and a[1][2] in c and a[2][2] in c) or (a[0][0] in c and a[1][1] in c and a[2][2] in c) or (a[0][2] in c and a[1][1] in c and a[2][0] in c):
    print('Yes')
else:
    print('No')

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
a_hash = [[False, False, False] for _ in range(3)]
 
for i in b:
    for ind, j in enumerate(a):
        if i in j:
            a_hash[ind][j.index(i)] = True
 
for i in a_hash:
    if all(i):
        print("Yes")
        exit()
 
if a_hash[0][0] and a_hash[1][1] and a_hash[2][2]:
    print("Yes")
    exit()
elif a_hash[0][2] and a_hash[1][1] and a_hash[2][0]:
    print("Yes")
    exit()
 
for num in range(3):
    if a_hash[0][num] and a_hash[1][num] and a_hash[2][num]:
        print("Yes")
        exit()
print("No")

Solution (Python):
A=[[],[],[]]
b=[]
A[0]=[int(x) for x in input().split()]
A[1]=[int(x) for x in input().split()]
A[2]=[int(x) for x in input().split()]
N =int(input().split()[0])
for i in range(N):
  b.append(int(input()))

for i in range(N):
  for j in range(3):
    for k in range(3):
      if A[j][k]==b[i]:
        A[j][k]=0
num=(A[0][0]+A[0][1]+A[0][2])*(A[1][0]+A[1][1]+A[1][2])*(A[2][0]+A[2][1]+A[2][2])*(A[0][0]+A[1][0]+A[2][0])*(A[0][1]+A[1][1]+A[2][1])*(A[0][2]+A[1][2]+A[2][2])*(A[0][0]+A[1][1]+A[2][2])*(A[0][2]+A[1][1]+A[2][0])

if num==0:
  print('Yes')
else:
  print('No')

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

for i in b:
    for ind, j in enumerate(a):
        if i in j:
            a_hash[ind][j.index(i)] = True

for i in a_hash:
    if all(i):
        print("Yes")
        exit()

if a_hash[0][0] and a_hash[1][1] and a_hash[2][2]:
    print("Yes")
    exit()
elif a_hash[0][2] and a_hash[1][1] and a_hash[2][0]:
    print("Yes")
    exit()

for num in range(3):
    if a_hash[0][num] and a_hash[1][num] and a_hash[2][num]:
        print("Yes")
        exit()
print("No")

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

for _ in range(n):
  b = int(input())
  for y in range(3):
    for x in range(3):
      if a[y][x] == b:
        a[y][x] = -1

for y in range(3):
  f = True
  for x in range(3):
    if a[y][x] != -1:
      f = False
  if f:
    print('Yes')
    exit()
    
for x in range(3):
  f = True
  for y in range(3):
    if a[y][x] != -1:
      f = False
  if f:
    print('Yes')
    exit()
    
f = True
for x in range(3):
  if a[x][x] != -1:
    f = False
if f:
  print('Yes')
  exit()
  
f = True
for x in range(3):
  if a[x][2-x] != -1:
    f = False
if f:
  print('Yes')
  exit()
  
print('No')

Solution (Python):
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int 
float 


for name in fruits: 
    print(name)


list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

exit(0) 

cumsum(リスト) 
cumsum_number(N,K,x) 
"""
number=[]
number1=[]
for _ in range(3):
    number += map(int,input().split())
N=int(input())
for _ in range(N):
    number1 += map(int,input().split())
for i in number1:
    if i in number:
        s=number.index(i)
        number[s]=0
if number[0]==0 and number[1]==0 and number[2]==0:
    print("Yes")
elif number[3]==0 and number[4]==0 and number[5]==0:
    print("Yes")
elif number[6]==0 and number[7]==0 and number[8]==0:
    print("Yes")
elif number[0]==0 and number[3]==0 and number[6]==0:
    print("Yes")
elif number[1]==0 and number[4]==0 and number[7]==0:
    print("Yes")
elif number[2]==0 and number[5]==0 and number[8]==0:
    print("Yes")
elif number[0]==0 and number[4]==0 and number[8]==0:
    print("Yes")
elif number[2]==0 and number[4]==0 and number[6]==0:
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
a.append(input().split())
a.append(input().split())
a.append(input().split())
n = int(input())

for i in range(n):
  b = input()
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = "0"
        break
    else:
      continue
    break

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

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

print("No")

Solution (Python):
def readinput():
    a=[]
    for i in range(3):
        l=list(map(int,input().split()))
        a.append(l)
    n=int(input())
    b=[]
    for _ in range(n):
        b.append(int(input()))
    return n,a,b

def main(n,a,b):
    sheet=[]
    for i in range(3):
        sheet.append([0,0,0])
    
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if a[j][k]==b[i]:
                    sheet[j][k]=1
    
    bingo=False
    for i in range(3):
        if sheet[i][0]==1 and sheet[i][1]==1 and sheet[i][2]==1:
            bingo=True
        elif sheet[0][i]==1 and sheet[1][i]==1 and sheet[2][i]==1:
            bingo=True
    if sheet[0][0]==1 and sheet[1][1]==1 and sheet[2][2]==1:
        bingo=True
    if sheet[0][2]==1 and sheet[1][1]==1 and sheet[2][0]==1:
        bingo=True
    return bingo

if __name__=='__main__':
    n,a,b=readinput()
    ans=main(n,a,b)
    if ans == True:
        print('Yes')
    else:
        print('No')

Solution (Python):
A1,A2,A3 = map(int, input().split())
A4,A5,A6 = map(int, input().split())
A7,A8,A9 = map(int, input().split())
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))
if A1 in B and A2 in B and A3 in B:
  print('Yes')
elif A4 in B and A5 in B and A6 in B:
  print('Yes')
elif A7 in B and A8 in B and A9 in B:
  print('Yes')
elif A1 in B and A4 in B and A7 in B:
  print('Yes')
elif A2 in B and A5 in B and A8 in B:
  print('Yes')
elif A3 in B and A6 in B and A9 in B:
  print('Yes')
elif A1 in B and A5 in B and A9 in B:
  print('Yes')
elif A3 in B and A5 in B and A7 in B:
  print('Yes')
else:
  print('No')

Solution (Python):
A = [[i for i in map(int, input().split())] for _ in range(3)]
N = int(input())
b = set(int(input()) for _ in range(N))
ans = False

ans = False
for row in A:
    if all(x in b for x in row):
        ans = True
for j in range(3):
    if all(A[i][j] in b for i in range(3)):
        ans = True
if all(A[i][i] in b for i in range(3)):
    ans = True
if all(A[i][2 - i] in b for i in range(3)):
    ans = True
print("Yes" if ans else "No")

Solution (Python):
A = []
for _ in range(3):
  A += list(map(int, input().split()))
N = int(input())
res = "No"

for _ in range(N):
  b = int(input())
  if b in A:
    ind = A.index(b)
    A[ind] = -1
if any(all(a==-1 for a in A[3*i:3*i+3])for i in range(3)): res = "Yes"
if any(all(a==-1 for a in A[i::3])for i in range(3)): res = "Yes"
if any(all(A[i]==-1 for i in a)for a in [[0,4,8],[2,4,6]]): res = "Yes"
print(res)

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


A = [[0 for _ in range(3)] for _ in range(3)]

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

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] = - 1

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

if A[0][2] == A[1][1] == A[2][0] == -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)]

c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for b in B:
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                c[i][j] += 1

cnt = 0
for i in range(3):
    if c[i][i] == 1:
       cnt += 1 
if cnt == 3:
    print('Yes')
    exit()

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

for i in range(3):
    cnt = 0
    for j in range(3):
        if c[j][i] == 1:
            cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

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

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

card = [A, B, C, D, E, F, G, H, I]
count = []

for i in range(N):
    num = int(input())
    if num in card:
        count.append(num)

if A in count and B in count and C in count:
    print("Yes")
elif D in count and E in count and F in count:
    print("Yes")
elif G in count and H in count and I in count:
    print("Yes")
elif A in count and D in count and G in count:
    print("Yes")
elif B in count and E in count and H in count:
    print("Yes")
elif C in count and F in count and I in count:
    print("Yes")
elif A in count and E in count and I in count:
    print("Yes")
elif C in count and E in count and G in count:
    print("Yes")
else:
    print("No")

Solution (Python):
A = [tuple(map(int, input().split())) for _ in range(3)]
C = [[False]*3 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:
                C[i][j] = True

ans = 'No'
for i in range(3):
    if all(C[i]):
        ans = 'Yes'
        break
for j in range(3):
    if C[0][j] + C[1][j] + C[2][j] == 3:
        ans = 'Yes'
        break

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

print(ans)

Solution (Python):
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
X = A + B + C
N = int(input())
L = []
for i in range (N):
  K = int(input())
  L.append(K)
ck = 'No'
if A[0] in L and A[1]in L and A[2] in L:
  ck = 'Yes'
elif B[0] in L and B[1]in L and B[2] in L:
  ck = 'Yes'
elif C[0] in L and C[1]in L and C[2] in L:
  ck = 'Yes'
elif A[0] in L and B[0]in L and C[0] in L:
  ck = 'Yes'
elif A[1] in L and B[1]in L and C[1] in L:
  ck = 'Yes'
elif A[2] in L and B[2]in L and C[2] in L:
  ck = 'Yes'
elif A[0] in L and B[1] in L and C[2] in L:
  ck = 'Yes'
elif A[2] in L and B[1] in L and C[0] in L:
  ck = 'Yes'
print(ck)

Solution (Python):
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
X=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    X=['X' if j==y else j for j in X]
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    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()))
x=a+b+c
n=int(input())
ans='No'
for _ in range(n):
  s=int(input())
  x=['x' if i==s else i for i in x]
if x[0]==x[3]==x[6]=='x':ans='Yes'
elif x[1]==x[4]==x[7]=='x':ans='Yes'
elif x[2]==x[5]==x[8]=='x':ans='Yes'
elif x[0]==x[1]==x[2]=='x':ans='Yes'
elif x[3]==x[4]==x[5]=='x':ans='Yes'
elif x[6]==x[7]==x[8]=='x':ans='Yes'
elif x[0]==x[4]==x[8]=='x':ans='Yes'
elif x[2]==x[4]==x[6]=='x':ans='Yes'
print(ans)

Solution (Python):
c1,c2,c3 = map(int, input().split())
c4,c5,c6 = map(int, input().split())
c7,c8,c9 = map(int, input().split())
card = [c1,c2,c3,c4,c5,c6,c7,c8,c9]
N = int(input())

b = []
for _ in range(N):
  b.append(int(input()))

for _ in b:
  for j in range(9):
    if card[j] == _:
      card[j] = "o"  
  
bingo = [
  [card[0],card[1],card[2]],
  [card[3],card[4],card[5]],
  [card[6],card[7],card[8]],
  [card[0],card[3],card[6]],
  [card[1],card[4],card[7]],
  [card[2],card[5],card[8]],
  [card[0],card[4],card[8]],
  [card[2],card[4],card[6]]
]

for i in bingo:
  if i == ["o","o","o"]:
    print("Yes")
    break
else:
  print("No")

Solution (Python):
card=[[0]*3 for i in range(3)]
for i in range(3):
  A=list(map(int,input().split()))
  card[i][0]=A[0]
  card[i][1]=A[1]
  card[i][2]=A[2]
N=int(input())
b=list()
for i in range(N):
  b.append(int(input()))
Kekka=[[False]*3 for i in range(3)]
for i in range(N):
  for j in range(3):
    for k in range(3):
      if card[j][k]==b[i]:
        Kekka[j][k]=True
flag=False
for i in range(3):
  if Kekka[i][0]==True and Kekka[i][1]==True and Kekka[i][2]==True:
    flag=True
for i in range(3):
  if Kekka[0][i]==True and Kekka[1][i]==True and Kekka[2][i]==True:
    flag=True
if Kekka[0][0]==True and Kekka[1][1]==True and Kekka[2][2]==True:
    flag=True
if Kekka[0][2]==True and Kekka[1][1]==True and Kekka[2][0]==True:
    flag=True
print("Yes" if flag==True else "No")

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

cont_lin = [0,0,0]
cont_col = [0,0,0]
contdp = contds = 0
for a in range(n):
  b= int(input())
  for i in range(3):
    for j in range(3):
      if M[i][j]==b:
          cont_lin[i]+=1
          cont_col[j]+=1
          if i==j:
              contdp+=1
          if i==2-j:
              contds+=1
achou = False
if (contdp == 3) or (contds==3):
    achou=True
elif (cont_lin[0]==3) or (cont_lin[1]==3) or (cont_lin[2]==3) :
    achou=True  
elif (cont_col[0]==3) or (cont_col[1]==3) or (cont_col[2]==3) :
    achou=True

print('Yes' if achou else 'No')

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

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

for p in val:
    for i in range(3):
        for j in range(3):
            if p == num[i][j]: num[i][j]=-1

ans='No'

for j in range(3): 
    if(num[0][j] == -1 and num[1][j] == -1 and num[2][j] ==-1): ans='Yes'
    if(num[j][0] == -1 and num[j][1] == -1 and num[j][2] ==-1): ans='Yes'

if(num[0][0] == -1 and num[1][1] == -1 and num[2][2] ==-1): ans='Yes'
if(num[0][2] == -1 and num[1][1] == -1 and num[2][0] ==-1): ans='Yes'


print(ans)

Solution (Python):
a = [list(map(int,input().split())) for i 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

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[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0:
    print('Yes')
    exit()
print('No')

Solution (Python):
from sys import stdin
import itertools
import numpy as np


A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = list(itertools.chain.from_iterable([A1,A2,A3]))

N = int(stdin.readline().rstrip())
b = [int(stdin.readline().rstrip()) for _ in range(N)]


for i in range(len(A)):
  if A[i] in b:
    A[i] = 0


A = np.reshape(A, (3,3))


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

for col in range(3):
  if A[0][col] == 0 and A[1][col] == 0 and A[2][col] == 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")

Solution (Python):
bing = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
bn = [int(input()) for _ in range(n)]
for n in bn:
  for i in range(3):
    for j in range(3):
      if bing[i][j]==n:
        bing[i][j]=0
        continue

for i in range(3):
  if bing[i][0]==bing[i][1]==bing[i][2]:
    print('Yes')
    quit()
  if bing[0][i]==bing[1][i]==bing[2][i]:
    print('Yes')
    quit()

if bing[0][0]==bing[1][1]==bing[2][2]:
  print('Yes')
  quit()
if bing[2][0]==bing[1][1]==bing[0][2]:
  print('Yes')
  quit()

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 i in range(n)]

for i in range(n):
    if b[i] in a1:
        a1[a1.index(b[i])] = 500
    elif b[i] in a2:
        a2[a2.index(b[i])] = 500
    elif b[i] in a3:
        a3[a3.index(b[i])] = 500
    else:
        pass


ver = [a1[i]+a2[i]+a3[i] for i in range(3)]
hor = [sum(a1),sum(a2),sum(a3)]
dia = [a1[0]+a2[1]+a3[2],a3[0]+a2[1]+a1[2]]

if max(max(ver),max(hor),max(dia)) == 1500:
    print('Yes')
else:
    print('No')

Solution (Python):






a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for k in range(n)]
ans = "No"

for i in range(3):
    for j in range(3):
        if b.count(a[i][j]) != 0:
            a[i][j] = 0

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

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

if a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0:
    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)]
mark = [[False, False, False] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True

ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break      
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[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)]
a=[[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j]==b:
                a[i][j]=True
bingo=False
for i in range(3):
    if a[i][0] and a[i][1] and a[i][2]:
        bingo=True
for j in range(3):
    if a[0][j] and a[1][j] and a[2][j]:
        bingo=True
if a[0][0] and a[1][1] and a[2][2]:
    bingo=True
if a[2][0] and a[1][1] and a[2][0]:
    bingo=True
print("Yes" if bingo else "No")

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

for i in range(n):
    b = int(input())
    for j in range(9):
        if a[j] == b:
            a[j] = 0
        
if a[0] == 0 and a[1] == 0 and a[2] == 0:
    print('Yes')
elif a[3] == 0 and a[4] == 0 and a[5] == 0:
    print('Yes')
elif a[6] == 0 and a[7] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[3] == 0 and a[6] == 0:
    print('Yes')
elif a[1] == 0 and a[4] == 0 and a[7] == 0:
    print('Yes')
elif a[2] == 0 and a[5] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[4] == 0 and a[8] == 0:
    print('Yes')
elif a[2] == 0 and a[4] == 0 and a[6] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
a1_1,a1_2,a1_3 = map(int,input().split())
a2_1,a2_2,a2_3 = map(int,input().split())
a3_1,a3_2,a3_3 = map(int,input().split())
n = int(input())
k = list(int(input()) for i in range(n)) 

if a1_1 in k and a1_2 in k and a1_3 in k :
  print("Yes")

elif a2_1 in k and a2_2 in k and a2_3 in k :
  print("Yes")

elif a3_1 in k and a3_2 in k and a3_3 in k :
  print("Yes")

elif a1_1 in k and a2_1 in k and a3_1 in k :
  print("Yes")

elif a1_2 in k and a2_2 in k and a3_2 in k :
  print("Yes")

elif a1_3 in k and a2_3 in k and a3_3 in k :
  print("Yes")

elif a1_1 in k and a2_2 in k and a3_3 in k :
  print("Yes")

elif a1_3 in k and a2_2 in k and a3_1 in k :
  print("Yes")

else : 
  print("No")

Solution (Python):
A = [[]]*3
for T in range(0,3):
    A[T] = [int(x) for x in input().split()]
A   = sum(A,[])
ATF = [False]*9
 
N = int(input())
for TT in range(0,N):
    B = int(input())
    if B in A:
        ATF[A.index(B)] = True

Flag = False
if   (all(ATF[:3])) or (all(ATF[3:6])) or (all(ATF[6:])):
    Flag = True
elif (all(ATF[::3])) or (all(ATF[1::3])) or (all(ATF[2::3])):
    Flag = True
elif (all(ATF[::4])) or (all(ATF[2:7:2])):
    Flag = True
    
if Flag:
    print('Yes')
else:
    print('No')

Solution (Python):
l = []
for i in range(3):
  n1, n2, n3 = map(str, input().split())
  l.append(int(n1))
  l.append(int(n2))
  l.append(int(n3))

n = int(input())
for i in range(n):
  num = int(input())
  if num in l:
    l[l.index(num)] = 0
    
if l[0]==0 and l[1]==0 and l[2]==0:
  print('Yes')
elif l[3]==0 and l[4]==0 and l[5]==0:
  print('Yes')
elif l[6]==0 and l[7]==0 and l[8]==0:
  print('Yes')
elif l[0]==0 and l[3]==0 and l[6]==0:
  print('Yes')
elif l[1]==0 and l[4]==0 and l[7]==0:
  print('Yes')
elif l[2]==0 and l[5]==0 and l[8]==0:
  print('Yes')
elif l[0]==0 and l[4]==0 and l[8]==0:
  print('Yes')
elif l[2]==0 and l[4]==0 and l[6]==0:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
M = [int(input()) for i in range(N)]
for m in range(len(M)):
	if M[m] in A:
		A[A.index(M[m])] = 0
	elif M[m] in B:
		B[B.index(M[m])] = 0
	elif M[m] in C:
		C[C.index(M[m])] = 0
for t in range(3):
	if A[t] + B[t] + C[t] == 0:
		print('Yes')
		sys.exit()
if sum(A) == 0 or sum(B) == 0 or sum(C) ==0:
	print('Yes')
	sys.exit()
elif A[0] + B[1] + C[2] == 0:
	print('Yes')
	sys.exit()
elif A[2] + B[1] +C[0] == 0:
	print('Yes')
else:
	print('No')

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 = [int(input()) for i in range(N)]
a1 = [0,0,0]
a2 = [0,0,0]
a3 = [0,0,0]
for b in B:
    if b in A1:
        a1[A1.index(b)] = 1
    elif b in A2:
        a2[A2.index(b)] = 1
    elif b in A3:
        a3[A3.index(b)] = 1

for i in range(3):
    if a1[i] == 1 and a2[i] == 1 and a3[i] == 1:
        print("Yes")
        sys.exit()
if a1[0] == 1 and a1[1] == 1 and a1[2] == 1:
    print("Yes")
    sys.exit()
elif a2[0] == 1 and a2[1] == 1 and a2[2] == 1:
    print("Yes")
    sys.exit()
elif a3[0] == 1 and a3[1] == 1 and a3[2] == 1:
    print("Yes")
    sys.exit()
elif a1[0] == 1 and a2[1] == 1 and a3[2] == 1:
    print("Yes")
    sys.exit()
elif a1[2] == 1 and a2[1] == 1 and a3[0] == 1:
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
def makelist(n, m):
    return [[False for _ in range(m)] for _ in range(n)]

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

N = int(input())
bingo = makelist(3, 3)
for _ in range(N):
    b = int(input())
    for y in range(3):
        for x in range(3):
            if A[y][x] == b:
                bingo[y][x] = True

ans = "No"
yes = "Yes"
for y in range(3):
    if all(bingo[y]):
        ans = yes

for x in range(3):
    res = True
    for y in range(3):
        res = res and bingo[y][x]
    if res:
        ans = yes

if bingo[1][1]:
    if (bingo[0][0] and bingo[2][2]) or (bingo[0][2] and bingo[2][0]):
        ans = yes

print(ans)