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 _ in range(3)]
n = int(input())
num = set([])
for _ in range(n):
  num.add(int(input()))
  
def func(a,b,c):
  if a in num and b in num and c in num:
    return 1
  else:
    return 0
  
r =func(*A[0]) or func(*A[1]) or func(*A[2])
c = func(A[0][0],A[1][0],A[2][0]) or func(A[0][1],A[1][1],A[2][1]) or func(A[0][2],A[1][2],A[2][2])
naname = func(A[0][0],A[1][1],A[2][2]) or func(A[2][0],A[1][1], A[0][2])

print('Yes' if r or c or naname else 'No')

Solution (Python):

import sys


YES = "Yes"  
NO = "No"  


def solve(A: "List[int]", N: int, b: "List[int]"):
    for i in range(N):
        for j in range(9):
            if A[j]==b[i]:
                A[j]=0
    ans=NO
    
    for i in range(3):
        if A[i]==A[i+3]==A[i+6]==0: ans=YES
    
    for i in range(3):
        if A[i*3]==A[i*3+1]==A[i*3+2]==0: ans=YES
    
    if A[0]==A[4]==A[8]==0: ans=YES
    if A[2]==A[4]==A[6]==0: ans=YES

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3*3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):
x=3
a=[]
for _ in range(x):
    a.append(list(map(int, input().split())))
n=int(input())
for _ in range(n):
    b=int(input())
    for ix in range(x):
        for iy in range(x):
            if a[ix][iy] == b:
                a[ix][iy]=-1


for i in range(x):
    if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
        print('Yes')
        exit()
    if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
        print('Yes')
        exit()

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    print('Yes')
    exit()
if a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    print('Yes')
    exit()

print('No')

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

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

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

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

n = int(input())
for _ in range(n):
    m = int(input())
    if m in c:
        c[c.index(m)]=0

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[5]==c[8]==c[2]==0 or c[0]==c[4]==c[8]==0 or c[2]==c[4]==c[6]==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)]
c = [[0, 0, 0] for _ in range(3)]
for k in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[k]:
                c[i][j] = 1

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

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

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

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

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

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

for i,j,k in [[(0,0),(1,1),(2,2)],[(0,2),(1,1),(2,0)]]:
    if A[i[0]][i[1]]+A[j[0]][j[1]]+A[k[0]][k[1]]==0:
        print("Yes")
        exit()

print("No")

Solution (Python):
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    As = [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 As[j][k] == b:
                    As[j][k] = -1

    for i in range(3):
        if As[i] == [-1, -1, -1]:
            print('Yes')
            return
        ri = [_[i] for _ in As]

        if ri == [-1,-1,-1]:
            print('Yes')
            return

    if As[0][0] == As[1][1] == As[2][2] == -1 or As[2][0] == As[1][1] == As[0][2] == -1:
        print('Yes')
        return
    
    print('No')


    return

if __name__ == '__main__':
    main()

Solution (Python):
bingo=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
D=[[0]*3 for _ in range(3)]

for _ in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if b==bingo[i][j]:
                D[i][j]=1
ans=set()
for d in D:
    ans.add(sum(d))
for d in zip(*D):
    ans.add(sum(d))
ans.add(D[0][0]+D[1][1]+D[2][2])
ans.add(D[0][2]+D[1][1]+D[2][0])
print('Yes' if 3 in ans else 'No')

Solution (Python):
a=[]
dp=[[0]*3 for i in range(3)]
for i in range(3):
    a1,a2,a3=map(int,input().split())
    a.append((a1,a2,a3))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for h in range(3):
            if a[j][h]==b:
                dp[j][h]=1
flag=0
for i in range(3):
    count=0
    for j in range(3):
        if dp[i][j]==1:
            count+=1
    if count==3:
        flag=1
for i in range(3):
    count=0
    for j in range(3):
        if dp[j][i]==1:
            count+=1
    if count==3:
        flag=1
count=0
for i in range(3):
    if dp[i][i]==1:
        count+=1
if count==3:
    flag=1
count=0
for i in range(3):
    if dp[2-i][i]==1:
        count+=1
if count==3:
    flag=1

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

Solution (Python):
def resolve():
    a = list(map(int, input().split()))
    a += list(map(int, input().split()))
    a += list(map(int, input().split()))
    n = int(input())
    b = [0]*n
    for i in range(n):
        b[i] = int(input())
    c = [False] * 9
    ans = False
    for i in range(9):
        c[i] = a[i] in b
    if c[0] and c[1] and c[2]:
        ans = True
    if c[3] and c[4] and c[5]:
        ans = True
    if c[6] and c[7] and c[8]:
        ans = True
    if c[0] and c[3] and c[6]:
        ans = True
    if c[1] and c[4] and c[7]:
        ans = True
    if c[2] and c[5] and c[8]:
        ans = True
    if c[0] and c[4] and c[8]:
        ans = True
    if c[2] and c[4] and c[6]:
        ans = True
    print("Yes" if ans else "No")


if __name__ == '__main__':
    resolve()

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


success = False
for i in range(3):
    if all([a == -1 for a in A[i]]):
        print("Yes")
        success = True
    elif all([a == -1 for a in [line[i] for line in A]]):
        print("Yes")
        success = True
    if success:
        break

if not(success) and A[0][0] == -1 and A[1][1] == -1 and A[2][2] == -1:
    print("Yes")
elif not(success) and A[2][0] == -1 and A[1][1] == -1 and A[0][2] == -1:
    print("Yes")
elif not(success):
    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())
z = set()
for _ in range(N):
    z.add(int(input()))

A = (a in z) and (b in z) and (c in z)
B = (d in z) and (e in z) and (f in z)
C = (g in z) and (h in z) and (i in z)

D = (a in z) and (d in z) and (g in z)
E = (b in z) and (e in z) and (h in z)
F = (c in z) and (f in z) and (i in z)

G = (a in z) and (e in z) and (i in z)
H = (c in z) and (e in z) and (g in z)

r = A or B or C or D or E or F or G or H

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

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

mark = [[False] * 3 for _ in range(3)]

n = int(input())

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

    for i in range(3):
        for j in range(3):
            if a[i][j] == x:
                mark[i][j] = True

a = mark

for i in range(3):
    if all(a[i][j] == True for j in range(3)) or all(a[j][i] == True for j in range(3)):
        print('Yes')
        break
else:
    if all(a[i][i] == True for i in range(3)) or all(a[i][3-i-1] == True for i in range(3)):
        print('Yes')
    else:
        print('No')

Solution (Python):
A_array = [list(map(int,input().split())) for _ in range(3)]
hit_array = [[0] * 3 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 b == A_array[j][k]:
                hit_array[j][k] = 1
for i in range(3):
    if hit_array[i][0] and hit_array[i][1] and hit_array[i][2]:
        print("Yes")
        exit()
    if hit_array[0][i] and hit_array[1][i] and hit_array[2][i]:
        print("Yes")
        exit()

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

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

print("No")

Solution (Python):
import sys

A = []

for i in range(3):

    x,y,z = map(int,input().split())
    A += [x,y,z]

N = int(input())

for i in range(N):

    b = int(input())

    for j in range(9):

        if A[j] == b:
            A[j] = 0



for i in range(3):

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

for i in range(3):

    if A[i] == A[i+3] == A[i+6] == 0:
        print ("Yes")
        sys.exit()

if (A[2] == A[4] == A[6] == 0)or(A[0] == A[4] == A[8] == 0):
    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()))
A = [A1, A2, A3]
N = int(input())
l = [[-1] * 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:
                l[i][j] = 0
    if sum(l[0]) == 0 or sum(l[1]) == 0 or sum(l[2]) == 0:
        print('Yes')
        break
    if l[0][0] + l[1][0] + l[2][0] == 0 or l[0][1] + l[1][1] + l[2][1] == 0:
        print('Yes')
        break
    if l[0][2] + l[1][2] + l[2][2] == 0 or l[0][0] + l[1][1] + l[2][2] == 0:
        print('Yes')
        break
    if l[0][2] + l[1][1] + l[2][0] == 0:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
bingo = [[0] * 3 for _ in range(3)]

n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == num:
                bingo[i][j] = 1

is_bingo = 0
for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2]:
        is_bingo = 1
    elif bingo[0][i] and bingo[1][i] and bingo[2][i]:
        is_bingo = 1
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    is_bingo = 1
if bingo[2][0] and bingo[1][1] and bingo[0][2]:
    is_bingo = 1

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

Solution (Python):
nums = [list(map(int, input().split())) for _ in range(3)]
bingo = [[0, 0, 0] for _ in range(3)]
n = int(input())
bs = [int(input()) for _ in range(n)]
for b in bs:
	for i in range(3):
		for j in range(3):
			if nums[i][j] == b:
				bingo[i][j] = 1
ans = 0
ans += bingo[0][0] * bingo[1][0] * bingo[2][0]
ans += bingo[0][1] * bingo[1][1] * bingo[2][1]
ans += bingo[0][2] * bingo[1][2] * bingo[2][2]
ans += bingo[0][0] * bingo[0][1] * bingo[0][2]
ans += bingo[1][0] * bingo[1][1] * bingo[1][2]
ans += bingo[2][0] * bingo[2][1] * bingo[2][2]
ans += bingo[0][0] * bingo[1][1] * bingo[2][2]
ans += bingo[2][0] * bingo[1][1] * bingo[0][2]

if ans >= 1:
	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())
    for j in range(3):
        if A1[j] == b:
            A1[j] = 0
        if A2[j] == b:
            A2[j] = 0
        if A3[j] == b:
            A3[j] = 0

f = 0

if A1[0] == 0 and A1[1] == 0 and A1[2] == 0:
    f = 1
if A2[0] == 0 and A2[1] == 0 and A2[2] == 0:
    f = 1
if A3[0] == 0 and A3[1] == 0 and A3[2] == 0:
    f = 1
if A1[0] == 0 and A2[0] == 0 and A3[0] == 0:
    f = 1
if A1[1] == 0 and A2[1] == 0 and A3[1] == 0:
    f = 1
if A1[2] == 0 and A2[2] == 0 and A3[2] == 0:
    f = 1
if A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
    f = 1
if A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
    f = 1
if f == 1:
    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 i in range(N):
    B.append(int(input()))
flag=0

if A1 in B and A2 in B and A3 in B:
    flag=1
if A4 in B and A5 in B and A6 in B:
    flag=1
if A7 in B and A8 in B and A9 in B:
    flag=1

if A1 in B and A4 in B and A7 in B:
    flag=1
if A2 in B and A5 in B and A8 in B:
    flag=1
if A3 in B and A6 in B and A9 in B:
    flag=1

if A1 in B and A5 in B and A9 in B:
    flag=1
if A3 in B and A5 in B and A7 in B:
    flag=1

print('Yes' if flag==1 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())
c = [int(input()) for _ in range(N)]
b=[[0,0,0],[0,0,0],[0,0,0]]
for val in c:
    for i in range(3):
        for j in range(3):
            if val == a[i][j]:
                b[i][j]=1
if sum(b[1])==3 or sum(b[0])==3 or sum(b[2])==3 or b[0][0]+b[1][0]+b[2][0]==3 or b[0][1]+b[1][1]+b[2][1]==3 or b[0][2]+b[1][2]+b[2][2]==3 or b[0][2]+b[1][1]+b[2][0]==3 or b[0][0]+b[1][1]+b[2][2]==3:
    print('Yes')
else:
    print('No')

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
o = [[0] * 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 b == a[i][j]:
                o[i][j] = 1

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

Solution (Python):


from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    a = []
    for i in range(3):
        atmp = li()
        a.append(atmp)
    n = ii()
    b = []
    for i in range(n):
        tmp = ii()
        b.append(tmp)
    
    for i in b:
        for itr in range(3):
            for itritr in range(3):
                if a[itr][itritr] == i:
                    a[itr][itritr] = 0

    for i in range(3):
        if sum(a[i]) == 0:
            print(yes)
            exit()
    for i in range(3):
        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 or a[0][2]+a[1][1]+a[2][0] == 0:
        print(yes)
        exit()
    print(no)



main()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    A=[[0]*3 for _ in range(3)]
    l=[]
    for i in range(3):
        A[i]=list(map(int,input().split()))
    for i in range(3):
        l.append(A[i])
        l.append([A[0][i],A[1][i],A[2][i]])
    l.append([A[0][0],A[1][1],A[2][2]])
    l.append([A[2][0],A[1][1],A[0][2]])
    N=int(input())
    b=[int(input()) for i in range(N)]
    for x in l:
        for y in x:
            if not y in b:
                break
        else:
            print('Yes')
            exit()
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
A = []
for i in range(3):
    A.append(list(map(int,input().split())))
N = int(input())
B = []
for i in range(N):
    B.append(int(input()))
L = [[False,False,False] for i in range(3)]
for e in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == e:
                L[i][j] = True


for i in range(3):
    if L[i][0] and L[i][1] and L[i][2]:
        print('Yes')
        exit()

for i in range(3):
    if L[0][i] and L[1][i] and L[2][i]:
        print('Yes')
        exit()

if L[0][0] and L[1][1] and L[2][2]:
    print('Yes')
    exit()
if L[2][0] and L[1][1] and L[0][2]:
    print('Yes')
    exit()
print('No')

Solution (Python):
l = [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 l[j][k] == b:
                l[j][k] = -1

r = False
for i in l:
    if sum(i) == -3:
        r = True
for i in range(3):
    if l[0][i] == l[1][i] == l[2][i] == -1:
        r = True
if l[0][0] == l[1][1] == l[2][2] == -1:
    r = True
if l[2][0] == l[1][1] == l[0][2] == -1:
    r = True
    
if r == True:
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
for _ in range(3):
    at = [int(num) for num in input().split()]
    a.append(at)
b = [[0,0,0] for _ in range(3)]
n = int(input())
for t in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if num == a[i][j]:
                b[i][j] = 1
                
ans = "No"
for i in range(3):
    if b[i][0] == 1 and b[i][1] == 1 and b[i][2] == 1:
        ans = "Yes"
for j in range(3):
    if b[0][j] == 1 and b[1][j] == 1 and b[2][j] == 1:
        ans = "Yes"
if b[0][0] * b[1][1] * b[2][2] == 1:
    ans = "Yes"
if b[0][2] * b[1][1] * b[2][0] == 1:
    ans = "Yes"
    
print(ans)

Solution (Python):
a1,a2,a3 = map(int,input().split())
b1,b2,b3 = map(int,input().split())
c1,c2,c3 = map(int,input().split())

N = int(input())
holl = []
for i in range(N):
    holl_t = int(input())
    holl.append(holl_t)


check_list = [[a1,a2,a3],[b1,b2,b3],[c1,c2,c3],[a1,b1,c1],[a2,b2,c2],[a3,b3,c3],[a1,b2,c3],[a3,b2,c1]]
ans = 0

for check in check_list:
    count = 0
    for i in check:
        if i in holl:
            count += 1
    
    if count == 3:
        ans = 1
        break

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

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

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


if (a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0) or \
        (a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0) or \
        (a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0) or \
        (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 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):
a = []
for i in range(3):
    a.append(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] = 0
if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
    print('Yes')
elif a[0][0]+a[1][0]+a[2][0] == 0:
    print('Yes')
elif a[0][1]+a[1][1]+a[2][1] == 0:
    print('Yes')
elif a[0][2]+a[1][2]+a[2][2] == 0:
    print('Yes')
elif a[0][0]+a[1][1]+a[2][2] == 0:
    print('Yes')
elif a[0][2]+a[1][1]+a[2][0] == 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)]
for i in range(3):
    for j in range(3):
        if a[i][j] not in b:
            break
    else:
        print('Yes')
        exit()
for i in range(3):
    for j in range(3):
        if a[j][i] not in b:
            break
    else:
        print('Yes')
        exit()
for i in range(3):
    if a[i][i] not in b:
        break
else:
    print('Yes')
    exit()
for i in range(3):
    if a[2-i][i] not in b:
        break
else:
    print('Yes')
    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())
l = []
for i in range(n):
  li = int(input())
  l.append(li)
for x in [a,b,c,[a[0],b[0],c[0]],[a[1],b[1],c[1]],[a[2],b[2],c[2]],[a[0],b[1],c[2]],[a[2],b[1],c[0]]]:
  flag = True
  for xi in x:
    if xi not in l:
      flag = False
      break
  if flag:
    print("Yes")
    exit()
print("No")

Solution (Python):
import itertools
A = [[int(_) for _ in input().split()] for _ in range(3)]
N = int(input())
B = set([int(input()) for _ in range(N)])
C = [[False] * 3 for _ in range(3)]
for i, j in itertools.product(range(3), range(3)):
    if A[i][j] in B:
        C[i][j] = True
f = False
for i in range(3):
    if all(C[i][j] for j in range(3)):
        f = True
for j in range(3):
    if all(C[i][j] for i in range(3)):
        f = True
if all([C[0][0], C[1][1], C[2][2]]):
    f = True
if all([C[0][2], C[1][1], C[2][0]]):
    f = True
print('Yes' if f else 'No')

Solution (Python):
A = [[] for i in range(8)]
A[0] = list(map(int,input().split()))
A[1] = list(map(int,input().split()))
A[2] = list(map(int,input().split()))
A[3] = [A[0][0],A[1][0],A[2][0]]
A[4] = [A[0][1],A[1][1],A[2][1]]
A[5] = [A[0][2],A[1][2],A[2][2]]
A[6] = [A[0][0],A[1][1],A[2][2]]
A[7] = [A[0][2],A[1][1],A[2][0]]

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

for i in range(8):
    bingo = True
    for j in range(3):
        if not A[i][j] in b:
            bingo = False
    if bingo:
        print('Yes')
        exit()
print('No')

Solution (Python):






def main():
    A = []
    for i in range(3):
        ary = [int(v) for v in input().split()]
        A.append(ary)
    N = int(input())

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

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

    for i in range(3):
        cnt1 = 0
        cnt2 = 0
        for j in range(3):
            if A[i][j] == 0:
                cnt1 += 1
            if A[j][i] == 0:
                cnt2 += 1
        if cnt1 == 3 or cnt2 == 3:
            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")


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    b = [list(map(int, input().split())) for _ in [0]*3]
    n = int(input())
    x = [int(input()) for _ in [0]*n]
    memo = [[False]*3 for _ in [0]*3]

    for i in x:
        for j in range(3):
            for k in range(3):
                if b[j][k] == i:
                    memo[j][k] = True
    for i in range(3):
        if memo[i][0] == memo[i][1] == memo[i][2] == True:
            print("Yes")
            return
        if memo[0][i] == memo[1][i] == memo[2][i] == True:
            print("Yes")
            return
    if memo[0][0] == memo[1][1] == memo[2][2] == True:
        print("Yes")
        return
    if memo[0][2] == memo[1][1] == memo[2][0] == True:
        print("Yes")
        return
    print("No")


main()

Solution (Python):
def main():
    A = [list(map(int,input().split())) for _ in range(3)]
    N = int(input())
    b = [int(input()) for _ in range(N)]
    bng = [[False]*3 for _ in range(3)]
    ans = "No"
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i] == A[j][k]:
                    bng[j][k] = True
    if (bng[0] == [True]*3 or
        bng[1] == [True]*3 or
        bng[2] == [True]*3 or
        bng[0][0] == bng[1][0] == bng[2][0] == True or
        bng[0][1] == bng[1][1] == bng[2][1] == True or
        bng[0][2] == bng[1][2] == bng[2][2] == True or
        bng[0][0] == bng[1][1] == bng[2][2] == True or
        bng[0][2] == bng[1][1] == bng[2][0] == True):
        ans = "Yes"
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def mark(b, check, la):
    for i in range(3):
        for j in range(3):
            if la[i][j] == b:
                check[i][j] = True

def ok(check):
    for i in range(3):
        if check[i][0] and check[i][1] and check[i][2]:
            return True
        if check[0][i] and check[1][i] and check[2][i]:
            return True
    if check[0][0] and check[1][1] and check[2][2]:
        return True
    if check[2][0] and check[1][1] and check[0][2]:
        return True
    return False


def main():
    check = [[False for _ in range(3)] for _ in range(3)]
    la = []
    for i in range(3):
        l = rli()
        la.append(l)
    n = ri()
    for i in range(n):
        b = ri()
        mark(b, check, la)
    if ok(check):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
input = stdin.readline

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

n = int(input())
for _ in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if board[i][j] == num:
                board[i][j] = True
                break


bingo_count = 0
for i in range(3):
    if board[i][0] == board[i][1] == board[i][2] == True:
        bingo_count += 1
    elif board[0][i] == board[1][i] == board[2][i] == True:
        bingo_count += 1

if board[0][0] == board[1][1] == board[2][2] == True:
    bingo_count += 1
if board[0][2] == board[1][1] == board[2][0] == True:
    bingo_count += 1

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

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

ok = [[False for i in range(3)] for j in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                ok[i][j] = True

    

bingo = False

if [True, True, True] in ok:
    bingo = True
if ok[0][0] == ok[1][1] == ok[2][2] == True:
    bingo = True
if ok[0][2] == ok[1][1] == ok[2][0] == True:
    bingo = True
for i in range(3):
    if ok[0][i] == ok[1][i] == ok[2][i] == True:
        bingo = True

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

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, N, B):
    C = [[False] * 3 for _ in range(3)]
    D = {}
    for i, r in enumerate(A):
        for j, c in enumerate(r):
            D[c] = (i, j)

    for b in B:
        if b in D:
            i, j = D[b]
            C[i][j] = True

    for i in range(3):
        t = True
        for j in range(3):
            t = t and C[i][j]
        if t:
            return 'Yes'

    for i in range(3):
        t = True
        for j in range(3):
            t = t and C[j][i]
        if t:
            return 'Yes'

    t = True
    for i in range(3):
        t = t and C[i][i]
    if t:
            return 'Yes'

    t = True
    for i in range(3):
        t = t and C[2-i][i]
    if t:
            return 'Yes'
    return 'No'


def main():
    A = [read_int_n() for _ in range(3)]
    N = read_int()
    B = [read_int() for _ in range(N)]

    print(slv(A, N, B))


if __name__ == '__main__':
    main()