Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

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

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

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

Solution (Python):
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
for b in B:
    for i in range(3):
        if b in A[i]:
            A[i][A[i].index(b)]=0
            
a=[]
            
def tate(X,i,c):
    cnt=0
    for j in range(3):
        if X[j][i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)
        
def yoko(X,i,c):
    cnt=0
    for j in range(3):
        if X[i][j]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)
        
def naname(X,c):
    cnt=0
    for i in range(3):
        if X[i][i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)

def naname2(X,c):
    cnt=0
    for i in range(3):
        if X[i][2-i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)

            
for i in range(3):
    tate(A,i,a)
    yoko(A,i,a)
naname(A,a)
naname2(A,a)
    
if len(a)==0:
    print("No")
else:
    print("Yes")

Solution (Python):
line_a = list(map(int, input().split()))
line_b = list(map(int, input().split()))
line_c = list(map(int, input().split()))

bingo = line_a + line_b + line_c


N = int(input())
Bn = []
for i in range(N):
  n = int(input())
  Bn.append(n)

for i in Bn:
  if i in bingo:
    n = bingo.index(i)
    bingo[n] = -1

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

Solution (Python):
a1 = input()
a2 = input()
a3 = input()
a1_list = a1.split(' ')
a2_list = a2.split(' ')
a3_list = a3.split(' ')

num = input()
num = int(num)
bingo = []

for i in range(num):
    y = input()
    bingo.append(y)

for i in bingo:
    i = str(i)
    for y in range(3):
        if a1_list[y] == i:
            a1_list[y] = 'OK'
        elif a2_list[y] == i:
            a2_list[y] = 'OK'
        elif a3_list[y] == i:
            a3_list[y] = 'OK'

bingo1 = (a1_list[0] == a1_list[1] and a1_list[1] == a1_list[2] and a1_list[2] == a1_list[0])
bingo2 = (a2_list[0] == a2_list[1] and a2_list[1] == a2_list[2] and a2_list[2] == a2_list[0])
bingo3 = (a3_list[0] == a3_list[1] and a3_list[1] == a3_list[2] and a3_list[2] == a3_list[0])
bingo4 = (a1_list[0] == a2_list[0] and a2_list[0] == a3_list[0] and a1_list[0] == a3_list[0])
bingo5 = (a1_list[1] == a2_list[1] and a2_list[1] == a3_list[1] and a1_list[1] == a3_list[1])
bingo6 = (a1_list[2] == a2_list[2] and a2_list[2] == a3_list[2] and a1_list[2] == a3_list[2])
bingo7 = (a1_list[0] == a2_list[1] and a2_list[1] == a3_list[2] and a1_list[0] == a3_list[2])
bingo8 = (a1_list[2] == a2_list[1] and a2_list[1] == a3_list[0] and a3_list[0] == a1_list[2])

if bingo1 or bingo2 or bingo3:
    print('Yes')
elif bingo4 or bingo5 or bingo6:
    print('Yes')
elif bingo7 or bingo8:
    print('Yes')
else:
    print('No')

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

Bingo=[Bingocard[0][0],Bingocard[0][1],Bingocard[0][2],Bingocard[1][0],Bingocard[1][1],Bingocard[1][2],Bingocard[2][0],Bingocard[2][1],Bingocard[2][2]]


Num = len(Draws)





for i in range (0, Num):
	if Bingo.count(Draws[i])>0:
		Bingo[Bingo.index(Draws[i])]= 0
	else:
		continue

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

Solution (Python):
a=[list(map(int,input().split())) for j in range(3)]
for i in range(int(input())):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
              a[j][k]=0
ans="No"

for i in range(3):
    if a[0][i]==a[1][i]==a[2][i]==0:
      ans="Yes"
    if a[i][0]==a[i][1]==a[i][2]==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):
import numpy as np

a = np.array([list(map(int, input().split())) for i in range(3)])
n = int(input())
b = [int(input()) for i in range(n)]

mask = np.zeros((3, 3))
for bi in b:
  mask += (a == bi)

flag = False
if mask[0, :].sum() >= 3 or mask[1, :].sum() >= 3 or mask[2, :].sum() >= 3:
    flag = True

if mask[:, 0].sum() >= 3 or mask[:, 1].sum() >= 3 or mask[:, 2].sum() >= 3:
    flag = True

if mask[0, 0] + mask[1, 1] + mask[2, 2] >= 3 or mask[2, 0] + mask[1, 1] + mask[0, 2] >= 3:
    flag = True

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

Solution (Python):
a=[]
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
n=int(input())
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 = 0
for i in range(3):
    if sum(a[i]) == 0:
        ans+=1
    if sum([a[j][i] for j in range(3)]) == 0:
        ans+=1
if a[0][0]+a[1][1]+a[2][2]==0:
     ans +=1
if a[2][0]+a[1][1]+a[0][2]==0:
     ans +=1
print('Yes' if ans > 0 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[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
    if a[i][0]==a[i][1]==a[i][2]==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):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
judge = 0

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

l = [[(a_i in B) for a_i in a] for a in A]

x = [
    [(0, 0), (0, 1), (0, 2)],
    [(1, 0), (1, 1), (1, 2)],
    [(2, 0), (2, 1), (2, 2)],

    [(0, 0), (1, 0), (2, 0)],
    [(0, 1), (1, 1), (2, 1)],
    [(0, 2), (1, 2), (2, 2)],

    [(0, 0), (1, 1), (2, 2)],
    [(0, 2), (1, 1), (2, 0)],
]

flag = any(all(l[y][x] for x, y in pos_l) for pos_l in x)













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

Solution (Python):
A = [list(map(int, input().split())) for _ 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[2 - x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')

Solution (Python):
A = []
B = []
cnt = 0

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(3):
    for j in range(3):
        for k in B:
            if A[i][j] == k:
                A[i][j] = 0
import sys
for i in range(3):            
    if A[i][0]==0 and A[i][0]==A[i][1] and A[i][1]==A[i][2]:
        print('Yes')
        sys.exit()
    elif A[0][i]==0 and A[0][i]==A[1][i] and A[1][i]==A[2][i]:
        print('Yes')
        sys.exit()
    elif A[0][0]==0 and A[0][0]==A[1][1] and A[1][1]==A[2][2]:
        print('Yes')
        sys.exit()
    elif A[0][2]==0 and A[0][2]==A[1][1] and A[1][1]==A[2][0]:
        print('Yes')
        sys.exit()

print('No')

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

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

ans = 'No'

for i in range(3):
  if sum(b[i]) == 3:
    ans = 'Yes'
    break

for i in range(3):
  if sum([b[j][i] for j in range(3)]) == 3:
    ans = 'Yes'
    break

if sum([b[i][i] for i in range(3)]) == 3:
  ans = 'Yes'

if sum([b[i][2-i] for i in range(3)]) == 3:
  ans = 'Yes'
  
print(ans)

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

lines = stdin.readlines()

a1 = [int(x) for x in lines[0].rstrip().split()]
a2 = [int(x) for x in lines[1].rstrip().split()]
a3 = [int(x) for x in lines[2].rstrip().split()]

counter = 0
n = int(lines[3].rstrip())
for i in range(n):
    if a1[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a1[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a1[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a2[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a2[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a3[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a3[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[0] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[0] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[1] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[1] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[2] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[2] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[2] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[0] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

if counter > 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

A1 = LIST()
A2 = LIST()
A3 = LIST()
N = INT()
B = np.ones(N)
for i in range(N):
  B[i] = INT()
  
B = list(B)

def bingo_array(A, B):
  for i in range(3):
    for x in B:
      if A[i] == x:
        A[i] *= 0
       
bingo_array(A1, B)
bingo_array(A2, B)
bingo_array(A3, B)

if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
  print("Yes")
elif A1[0]+A2[0]+A3[0] == 0 or A1[1]+A2[1]+A3[1] == 0 or A1[2]+A2[2]+A3[2] == 0:
  print("Yes")
elif A1[0]+A2[1]+A3[2] == 0 or A1[2]+A2[1]+A3[0] == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
A = list(map(int,input().split()))
A += list(map(int,input().split()))
A += list(map(int,input().split()))
Z = [False]*9

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

for i in range(N):
  for j in range(9):
    if A[j] == B[i]:
      Z[j] = True
      
if (Z[0] and Z[1] and Z[2]) or (Z[3] and Z[4] and Z[5]) or (Z[6] and Z[7] and Z[8]) or (Z[0] and Z[3] and Z[6]) or (Z[1] and Z[4] and Z[7]) or (Z[2] and Z[5] and Z[8]) or (Z[0] and Z[4] and Z[8]) or (Z[2] and Z[4] and Z[6]):
  print("Yes")
else:
  print("No")

Solution (Python):
li=[]
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
n=int(input())
for num in range(n):
  j=int(input())
  li.append(j)
bingo=0
yoko1=(a in li) and (b in li) and (c in li)
yoko2=(d in li) and (e in li) and (f in li)
yoko3=(g in li) and (h in li) and (i in li)
yoko=yoko1 or yoko2 or yoko3
tate1=(a in li) and (d in li) and (g in li)
tate2=(b in li) and (e in li) and (h in li)
tate3=(c in li) and (f in li) and (i in li)
tate=tate1 or tate2 or tate3
nana1=(a in li) and (e in li) and (i in li)
nana2=(c in li) and (e in li) and (g in li)
nana=nana1 or nana2
if yoko or tate or nana:
    bingo=1
print("Yes" if bingo==1 else "No")

Solution (Python):
a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
a = [a_1, a_2, a_3]
n = int(input())
for i in range(n):
    number = int(input())
    for j in range(3):
        if a_1[j] == number:
            a_1[j] = 0
            break
        elif a_2[j] == number:
            a_2[j] = 0
            break
        elif a_3[j] == number:
            a_3[j] = 0
            break
if (a[0][0]+a[1][1]+a[2][2])*(a[0][2]+a[1][1]+a[2][0])*(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[0][1]+a[0][2])*(a[1][0]+a[1][1]+a[1][2])*(a[2][0]+a[2][1]+a[2][2]) == 0:
    print('Yes')
else:
    print('No')

Solution (Python):


A = []

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

import copy

B = copy.deepcopy(A)

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

B = [set(b) for b in B]

N = int(input())

bs = []

for _ in range(N):
  bs += [int(input())]

bs = set(bs)

flag = "No"

for b in B:
  if b.issubset(bs):
    flag = "Yes"

print(flag)

Solution (Python):
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for j in range(n)]
for j in range(n):
  for i in range(3):
    for k in range(3):
      if b[j] == a[i][k]:
        a[i][k]=0
x="yet"
sum=0
for i in range(3):
  sum+=a[i][i]
if sum==0:
  print("Yes")
  x="done"  

if x=="yet":
  sum=0
  for i in range(3):
    sum+=a[2-i][i]
  if sum==0:
    print("Yes")
    x="done"
    
if x=="yet":
  for i in range(3): 
    sum=0
    for k in range(3):  
      sum+=a[i][k]
    if sum==0:
      print("Yes")
      x="done"
      break

if x=="yet":
  for k in range(3): 
    sum=0
    for i in range(3):  
      sum+=a[i][k]
    if sum==0:
      print("Yes")
      x="done"
      break
if x=="yet":
      print("No")

Solution (Python):
def bingo(line):
    for num in line:
        if not num in b:
            return False
    return True

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

lines = []
lines.append([A[0][0], A[0][1], A[0][2]])
lines.append([A[1][0], A[1][1], A[1][2]])
lines.append([A[2][0], A[2][1], A[2][2]])

lines.append([A[0][0], A[1][0], A[2][0]])
lines.append([A[0][1], A[1][1], A[2][1]])
lines.append([A[0][2], A[1][2], A[2][2]])

lines.append([A[0][0], A[1][1], A[2][2]])
lines.append([A[0][2], A[1][1], A[2][0]])

for line in lines:
    for num in line:
        if bingo(line):
            print('Yes')
            exit(0)

print('No')
exit(0)

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

yoko = [[(i,j) for j in range(3)] for i in range(3)]
tate = [[(i,j) for i in range(3)] for j in range(3)]
naname = [[(i,i) for i in range(3)], [(i,2 - i) for i in range(3)]]

atari = set()
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            atari.add((i, j))

if len(atari) < 3:
    print('No')
else:        
    for i in yoko:
        if i[0] in atari and i[1] in atari and i[2] in atari:
            print('Yes')
            exit()

    for i in tate:
        if i[0] in atari and i[1] in atari and i[2] in atari:
            print('Yes')
            exit()

    for i in naname:
        if i[0] in atari and i[1] in atari and i[2] in atari:
            print('Yes')
            exit()
    
    print('No')

Solution (Python):
import sys
a1=[int(i) for i in input().split()]
a2=[int(i) for i in input().split()]
a3=[int(i) for i in input().split()]
for l in sys.stdin:
  if int(l) in a1:
    a1[a1.index(int(l))]=0
  elif int(l) in a2:
    a2[a2.index(int(l))]=0
  elif int(l) in a3:
    a3[a3.index(int(l))]=0
m=sum(a1)*sum(a2)*sum(a3)
for i in range(3):
  m*=a1[i]+a2[i]+a3[i]
  m*=a1[i]+a2[1]+a3[2-i]
print('Yes' if m==0 else 'No')

Solution (Python):
import sys
a = [list(map(int,input().split())) for _ in range(3)]
check = [[0]*3 for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                check[i][j] = 1

for j in range(3):
    ch = 0
    for i in range(3):
        if check[i][j] == 1:
            ch += 1
    else:
        if ch == 3:
            print('Yes')
            sys.exit()

for i in range(3):
    ch = 0
    for j in range(3):
        if check[i][j] == 1:
            ch += 1
    else:
        if ch == 3:
            print('Yes')
            sys.exit()

if check[0][0] + check[1][1] + check[2][2] == 3:
    print('Yes')
    sys.exit()
if check[0][2] + check[1][1] + check[2][0] == 3:
    print('Yes')
    sys.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())
for i in range(n):
    for j in range(3):
        if a1[j]==b[i]:
            a1[j]=-1
        if a2[j]==b[i]:
            a2[j]=-1
        if a3[j]==b[i]:
            a3[j]=-1
if sum(a1)==-3 \
    or sum(a2)==-3 \
    or sum(a3)==-3 \
    or (a1[0],a2[0],a3[0])==(-1,-1,-1) \
    or (a1[1],a2[1],a3[1])==(-1,-1,-1) \
    or (a1[2],a2[2],a3[2])==(-1,-1,-1) \
    or (a1[0], a2[1], a3[2]) == (-1, -1, -1) \
    or (a1[2], a2[1], a3[0]) == (-1, -1, -1) :
    print("Yes")

else:
    print("No")

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


while n > 0:
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                a[i][j] = "Yes"
    n -= 1
if a[0][0] == a[0][1] == a[0][2]:
    print("Yes")
elif a[1][0] == a[1][1] == a[1][2]:
    print("Yes")
elif a[2][0] == a[2][1] == a[2][2]:
    print("Yes")
elif a[0][0] == a[1][0] == a[2][0]:
    print("Yes")
elif a[0][1] == a[1][1] == a[2][1]:
    print("Yes")
elif a[0][2] == a[1][2] == a[2][2]:
    print("Yes")
elif a[0][0] == a[1][1] == a[2][2]:
    print("Yes")
elif a[0][2] == a[1][1] == a[2][0]:
    print("Yes")
else:
    print("No")

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


while n > 0:
    b = int(input())
    for i in range(3):
        if b == a[0][i]:
            a[0][i] = "Yes"
    for j in range(3):
        if b == a[1][j]:
            a[1][j] = "Yes"
    for k in range(3):
        if b == a[2][k]:
            a[2][k] = "Yes"
    n -= 1
if a[0][0] == a[0][1] == a[0][2]:
    print("Yes")
elif a[1][0] == a[1][1] == a[1][2]:
    print("Yes")
elif a[2][0] == a[2][1] == a[2][2]:
    print("Yes")
elif a[0][0] == a[1][0] == a[2][0]:
    print("Yes")
elif a[0][1] == a[1][1] == a[2][1]:
    print("Yes")
elif a[0][2] == a[1][2] == a[2][2]:
    print("Yes")
elif a[0][0] == a[1][1] == a[2][2]:
    print("Yes")
elif a[0][2] == a[1][1] == a[2][0]:
    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):
    x = int(input())
    b.append(x)


for i in b:
    if i in a1:
        a1[a1.index(i)] = 'X'
    if i in a2:
        a2[a2.index(i)] = 'X'
    if i in a3:
        a3[a3.index(i)] = 'X'

if len(set(a1)) == 1 and a1[0] == 'X' or len(set(a2)) == 1 and a2[0] == 'X' or len(set(a3)) == 1 and a3[0] == 'X':
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[0] == a3[0] or a1[1] == 'X' and a1[1] == a2[1] == a3[1] or a1[2] == 'X' and a1[2] == a2[2] == a3[2]:
    print('Yes')
elif a1[0] == 'X' and a1[0] == a2[1] == a3[2] or a1[2] == 'X' and a1[2] == a2[1] == a3[0]:
    print('Yes')
else:
    print('No')

Solution (Python):
A = list()
for _ in range(3):
  for i in map(int, input().split()):
    A.append(i)
N = int(input())
B = list()
for i in range(N):
  B.append(int(input()))
c = [0 for i in range(9)]
for i in range(N):
  for j in range(9):
    if B[i] == A[j]:
      c[j] += 1

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

Solution (Python):
P = [list(map(int,input().split())) for i in range(3)]
Q=[P[i][j] for i in range(3) for j in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
TF_list=[(Q[i] in B) for i in range(9)]
if TF_list[0]+TF_list[1]+TF_list[2] ==3 or \
TF_list[3]+TF_list[4]+TF_list[5] ==3 or \
TF_list[6]+TF_list[7]+TF_list[8] ==3 or \
TF_list[0]+TF_list[3]+TF_list[6] ==3 or \
TF_list[1]+TF_list[4]+TF_list[7] ==3 or \
TF_list[2]+TF_list[5]+TF_list[8] ==3 or \
TF_list[0]+TF_list[4]+TF_list[8] ==3 or \
TF_list[2]+TF_list[4]+TF_list[6] ==3:
  print ('Yes')
else:
  print('No')

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

  n = int(input())

  data_map = []
  for _ in range(3):
    data_map.append([0, 0, 0])

  for _ in range(n):
    x = int(input())
    if x == data[0][0]:
      data_map[0][0] = 1
    if x == data[0][1]:
      data_map[0][1] = 1
    if x == data[0][2]:
      data_map[0][2] = 1
    if x == data[1][0]:
      data_map[1][0] = 1
    if x == data[1][1]:
      data_map[1][1] = 1
    if x == data[1][2]:
      data_map[1][2] = 1
    if x == data[2][0]:
      data_map[2][0] = 1
    if x == data[2][1]:
      data_map[2][1] = 1
    if x == data[2][2]:
      data_map[2][2] = 1

  
  

  
  if sum(data_map[0]) == 3 or sum(data_map[1]) == 3 or sum(data_map[2]) == 3:
    print("Yes")
    return
  
  
  if data_map[0][0] + data_map[1][1] + data_map[2][2] == 3:
    print("Yes")
    return
  
  if data_map[0][2] + data_map[1][1] + data_map[2][0] == 3:
    print("Yes")
    return

  
  if data_map[0][0] + data_map[1][0] + data_map[2][0] == 3:
    print("Yes")
    return
  if data_map[0][1] + data_map[1][1] + data_map[2][1] == 3:
    print("Yes")
    return
  if data_map[0][2] + data_map[1][2] + data_map[2][2] == 3:
    print("Yes")
    return

  print("No")

if __name__ == "__main__":
  main()

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

for i in range(0,N):
    for j in range(9):
        if B[i] ==  A[j]:
            A[j] = 0

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

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

Solution (Python):

import sys 


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


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

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

if f[0][0] + f[1][1] + f[2][2] == 3 or f[0][2] + f[1][1] + f[2][0] == 3:
    print('Yes')
    sys.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)]
A = [[0 if j in b else j for j in A[i]] for i in range(3)]

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

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

if all([x == 0 for x in A1]):
    print('Yes')
    exit()
if all([y == 0 for y in A2]):
    print('Yes')
    exit()
if all([z == 0 for z in A3]):
    print('Yes')
    exit()

for t in range(3):
    if A1[t] == A2[t] == A3[t]:
        print('Yes')
        exit()

if A1[0] == A2[1] == A3[2]:
    print('Yes')
    exit()

if A1[2] == A2[1] == A3[0] == 0:
    print('Yes')
    exit()

print('No')

Solution (Python):
bingo = []
b = []

for i in range(3):
  tmp = list(map(int,input().split()))
  bingo.append(tmp)

n = int(input())

while True:
  try:
    b.append(int(input()))
  except EOFError:
    break

lis1 = [bingo[0][0],bingo[0][1],bingo[0][2]]
lis2 = [bingo[1][0],bingo[1][1],bingo[1][2]]
lis3 = [bingo[2][0],bingo[2][1],bingo[2][2]]

lis4 = [bingo[0][0],bingo[1][0],bingo[2][0]]
lis5 = [bingo[0][1],bingo[1][1],bingo[2][1]]
lis6 = [bingo[0][2],bingo[1][2],bingo[2][2]]

lis7 = [bingo[0][0],bingo[1][1],bingo[2][2]]
lis8 = [bingo[0][2],bingo[1][1],bingo[2][0]]

allList = [lis1,lis2,lis3,lis4,lis5,lis6,lis7,lis8]

for i in allList:
  cnt = 0
  for _ in range(3):
    if i[_] in b:
      cnt +=1
  if cnt ==3:
    print("Yes")
    exit()
print("No")

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

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

c=0
for i in range(3):
    if a[0][i]==a[1][i] and a[0][i]==a[2][i]:
        c += 1
if a[0]==[0,0,0] or a[1]==[0,0,0] or a[2]==[0,0,0]:
    print("Yes")
elif c!= 0:
    print("Yes")
elif (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) or (a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
    print("Yes")
else:
    print("No")