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):
from collections import defaultdict
def a():
    A = []
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[int(input())] = 1

    B = list(map(lambda x:d[x],A))

    if B[4]:
        if B[0] * B[8] + B[2] * B[6]:
            return 1
    
    for i in range(3):
        if sum(B[i*3:i*3+3]) == 3:
            return 1
        if sum(B[i::3]) == 3:
            return 1
    
    return 0

print(["No","Yes"][a()])

Solution (Python):
data_list = [ list(map(int,input().split(" "))) for i in range(3)]
n = int(input())
b_list = []
for _ in range(n):
    b_list.append(int(input()))



for k in range(n):
    for i in range(3):
        for j in range(3):
            if data_list[i][j] == b_list[k]:
                data_list[i][j] = -1

ans = []

for i in range(3):
    s = data_list[i]
    ans.append(sum(s))

for i in range(3):
    s = data_list[0][i] + data_list[1][i] + data_list[2][i]
    ans.append(s)

ans.append(data_list[0][0] + data_list[1][1] + data_list[2][2])
ans.append(data_list[0][2] + data_list[1][1] + data_list[2][0])

if ans.count(-3) != 0:
    print("Yes")
else:
    print("No")

Solution (Python):

L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))
L3 = list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]

Flag = False

LL = L1 + L2 + L3



for i in B:
    if i in LL:
        LL[LL.index(i)] = 0


for i in range(3):
    t = LL[3*i] + LL[3*i+1] + LL[3*i+2]
    if t == 0:
        Flag = True


for i in range(3):
    t = t = LL[i] + LL[i+3] + LL[i+6]
    if t == 0:
        Flag = True


t = LL[0] + LL[4] + LL[8]
if t == 0:
    Flag = True
t = LL[2] + LL[4] + LL[6]
if t == 0:
    Flag = True

if Flag == True:
    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)]
atari=[]

for i in range(3):
    atari.append([a[i][0],a[i][1],a[i][2]])
for i in range(3):
    atari.append([a[0][i],a[1][i],a[2][i]])
    
atari.append([a[0][0],a[1][1],a[2][2]])
atari.append([a[0][2],a[1][1],a[2][0]])

for k in range(len(atari)):
    if len(list(set(atari[k]) & set(b)))==3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
import numpy as np
Flg = "No"
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())

for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

if(A[0][2] == A[1][1] == A[2][0] == "*"):
    Flg = "Yes"

print(Flg)

Solution (Python):
a = list(map(int,input().split()))
a = a + list(map(int,input().split()))
a = a + list(map(int,input().split()))

n = int(input())
call = [int(input()) for i in range(n)]

for i in call:
	if i in a:
		a[a.index(i)] = 0

ans = 'No'

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

Solution (Python):
[A11,A12,A13] = list(map(int,input().split()))
[A21,A22,A23] = list(map(int,input().split()))
[A31,A32,A33] = list(map(int,input().split()))
N = int(input())

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

A=[A11,A12,A13,A21,A22,A23,A31,A32,A33]


sheet=[0]*9

for i in range(N):
    for j in range(9):
        if b[i]==A[j]:
            sheet[j]=1

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

Solution (Python):
bingo_dict = dict()
i=1
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1
i=2
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1
i=3
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1

N = int(input())

s = set()
for b in [int(input()) for n in range(N)]:
    if b in bingo_dict:
        s.add(bingo_dict[b])

patterns = [
    [11,12,13],
    [21,22,23],
    [31,32,33],
    [11,21,31],
    [12,22,32],
    [13,23,33],
    [11,22,33],
    [13,22,31]
]

for p in patterns:
    b = True
    for v in p:
        if v not in s:
            b = False
            break
    if b:
        print('Yes')
        exit()

print('No')

Solution (Python):
A = [[False, False, False], [False, False, False], [False, False, False]]

def checker():
    for i in range(3):
        if A[i][0] & A[i][1] & A[i][2]:
            return True
        elif A[0][i] & A[1][i] & A[2][i]:
            return True
    if A[0][0] & A[1][1] & A[2][2]:
        return True
    elif A[0][2] & A[1][1] & A[2][0]:
        return True
    return False

a0 = list(map(int, input().split()))
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(3):
        if b == a0[j]:
            A[0][j] = True
            break
        elif b == a1[j]:
            A[1][j] = True
            break
        elif b == a2[j]:
            A[2][j] = True
            break

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

Solution (Python):
Card = [[],[],[]]
for k in range(3):
    Card[k] = list(map(int,input().split()))
N = int(input())
Call = [int(input()) for k in range(N)]
Bin = [[0,0,0],[0,0,0],[0,0,0]]
for k in range(N):
    for l in range(3):
        for m in range(3):
            if Card[l][m] == Call[k]:
                Bin[l][m] =1
ans = 0
for k in range(3):
    if Bin[k][0] == Bin[k][1] and Bin[k][1] == Bin[k][2] and Bin[k][0] ==1:
        ans = 1
    if Bin[0][k] == Bin[1][k] and Bin[1][k] == Bin[2][k] and Bin[2][k] ==1:
        ans = 1
if Bin[0][0] == Bin[1][1] and Bin[1][1] == Bin[2][2] and Bin[2][2] ==1:
    ans = 1 
if Bin[0][2] == Bin[1][1] and Bin[1][1] == Bin[2][0] and Bin[2][0] == 1:
    ans = 1

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

Solution (Python):
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())

z1=[]
z2=[]
z3=[]
z4=[]
z5=[]
z6=[]
z7=[]
z8=[]
z1.append(a)
z1.append(b)
z1.append(c)

z2.append(d)
z2.append(e)
z2.append(f)

z3.append(g)
z3.append(h)
z3.append(i)

z4.append(a)
z4.append(d)
z4.append(g)

z5.append(b)
z5.append(e)
z5.append(h)

z6.append(c)
z6.append(f)
z6.append(i)

z7.append(a)
z7.append(e)
z7.append(i)

z8.append(c)
z8.append(e)
z8.append(g)

n=int(input())
for i in range(n):
    x=int(input())
    if x in z1:z1.remove(x)
    if x in z2:z2.remove(x)
    if x in z3:z3.remove(x)
    if x in z4:z4.remove(x)
    if x in z5:z5.remove(x)
    if x in z6:z6.remove(x)
    if x in z7:z7.remove(x)
    if x in z8:z8.remove(x)

if len(z1)==0 or len(z2)==0 or len(z3)==0 or len(z4)==0 or len(z5)==0 or len(z6)==0 or len(z7)==0 or len(z8)==0:
    print("Yes")
else:
    print("No")

Solution (Python):
A=[]
for i in range(3):
    a=list(map(int,input().split()))
    A.append(a)
V=[[0]*3 for i in range(3)]
n=int(input())
for i in range(n):
    t=int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]==t:
                V[j][k]=1
if V[0][0]==V[1][0]==V[2][0]==1:
    print('Yes')
    exit()
elif V[0][1]==V[1][1]==V[2][1]==1:
    print('Yes')
    exit()
elif V[0][2]==V[1][2]==V[2][2]==1:
    print('Yes')
    exit()
elif V[0][0]==V[0][1]==V[0][2]==1:
    print('Yes')
    exit()
elif V[1][0]==V[1][1]==V[1][2]==1:
    print('Yes')
    exit()
elif V[2][0]==V[2][1]==V[2][2]==1:
    print('Yes')
    exit()
elif V[0][0]==V[1][1]==V[2][2]==1:
    print('Yes')
    exit()
elif V[0][2]==V[1][1]==V[2][0]==1:
    print('Yes')
    exit()
else:
    print('No')

Solution (Python):
li1 = list(map(int,input().split()))
li2 = list(map(int,input().split()))
li3 = list(map(int,input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
A = li1+li2+li3

hit = []
for i in b:
    if i in A:
        hit.append(A.index(i)+1)

if (1 in hit and 2 in hit and 3 in hit)\
or (4 in hit and 5 in hit and 6 in hit)\
or (7 in hit and 8 in hit and 9 in hit)\
or (1 in hit and 4 in hit and 7 in hit)\
or (2 in hit and 5 in hit and 8 in hit)\
or (3 in hit and 6 in hit and 9 in hit)\
or (1 in hit and 5 in hit and 9 in hit)\
or (3 in hit and 5 in hit and 7 in hit):
    print("Yes")
else:
    print("No")

Solution (Python):
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))



N=int(input())
mylist=[]
flaglist=[0,0,0,0,0,0,0,0] 
for i in range(N):
    mylist.append(int(input()))
    
    
for i in range(3):
    for j in range(N):
        if Alist[i]==mylist[j]:
            flaglist[0]+=1
            
for i in range(3):
    for j in range(N):
        if Blist[i]==mylist[j]:
            flaglist[1]+=1
            
            
for i in range(3):
    for j in range(N):
        if Clist[i]==mylist[j]:
            flaglist[2]+=1


for i in range(N):
    if Alist[0]==mylist[i]:
        flaglist[3]+=1
    elif Blist[0]==mylist[i]:
        flaglist[3]+=1
    elif Clist[0]==mylist[i]:
        flaglist[3]+=1
        
for i in range(N):
    if Alist[1]==mylist[i]:
        flaglist[4]+=1
    elif Blist[1]==mylist[i]:
        flaglist[4]+=1
    elif Clist[1]==mylist[i]:
        flaglist[4]+=1

for i in range(N):
    if Alist[2]==mylist[i]:
        flaglist[5]+=1
    elif Blist[2]==mylist[i]:
        flaglist[5]+=1
    elif Clist[2]==mylist[i]:
        flaglist[5]+=1
        
for i in range(N):
    if Alist[2]==mylist[i]:
        flaglist[6]+=1
    elif Blist[1]==mylist[i]:
        flaglist[6]+=1
    elif Clist[0]==mylist[i]:
        flaglist[6]+=1
        
for i in range(N):
    if Alist[0]==mylist[i]:
        flaglist[7]+=1
    elif Blist[1]==mylist[i]:
        flaglist[7]+=1
    elif Clist[2]==mylist[i]:
        flaglist[7]+=1
        
if max(flaglist)>=3:
    print("Yes")
else:
    print("No")

Solution (Python):
num1 =input().rstrip().split()
num2 =input().rstrip().split()
num3 =input().rstrip().split()
numbers=[int(num1[0]),int(num1[1]),int(num1[2]),int(num2[0]),int(num2[1]),int(num2[2]),int(num3[0]),int(num3[1]),int(num3[2])]

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

for i in range(9):
    for call in calls:
        if call == numbers[i]:
            numbers[i]=0

a=numbers[0]+numbers[1]+numbers[2]
b=numbers[3]+numbers[4]+numbers[5]
c=numbers[6]+numbers[7]+numbers[8]
d=numbers[0]+numbers[3]+numbers[6]
e=numbers[1]+numbers[4]+numbers[7]
f=numbers[2]+numbers[5]+numbers[8]
g=numbers[0]+numbers[4]+numbers[8]
h=numbers[2]+numbers[4]+numbers[6]

if a*b*c*d*e*f*g*h==0:
    print("Yes")
else:
    print("No")

Solution (Python):

X = dict()
cc = 0
for _ in range(3):
    a, b, c = map(int, input().split())
    X[a] = cc
    cc += 1 
    X[b] = cc
    cc += 1 
    X[c] = cc
    cc += 1 

Q = int(input())
ss = set()
for _ in range(Q):
    c = int(input())
    if c in X:
        ss.add(X[c])
if 0 in ss and 1 in ss and 2 in ss:
    print("Yes")
elif 3 in ss and 4 in ss and 5 in ss:
    print("Yes")
elif 6 in ss and 7 in ss and 8 in ss:
    print("Yes")
elif 0 in ss and 3 in ss and 6 in ss:
    print("Yes")
elif 1 in ss and 4 in ss and 7 in ss:
    print("Yes")
elif 2 in ss and 5 in ss and 8 in ss:
    print("Yes")
elif 0 in ss and 4 in ss and 8 in ss:
    print("Yes")
elif 2 in ss and 4 in ss and 6 in ss:
    print("Yes")
else:
    print("No")

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

for x in b:
  for i in range(3):
    for j in range(3):
      c[j][i] = c[j][i] or (a[j][i] == x)

bingo = 0
for j in range(3):
  bingo = bingo or all(c[j])
for i in range(3):
  bingo = bingo or all([c[j][i] for j in range(3)])

bingo = bingo or all([c[i][i] for i in range(3)]) or all([c[i][2-i] for i in range(3)])

if bingo:
  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 = [int(input()) for _ in range(N)]
A = [
    A1,
    A2,
    A3,
    [A1[0],A2[0],A3[0]],
    [A1[1],A2[1],A3[1]],
    [A1[2],A2[2],A3[2]],
    [A1[0],A2[1],A3[2]],
    [A1[2],A2[1],A3[0]],
]

for al in A:
    res = True
    for a in al:
        if not a in B:
            res = False
    if res:
        print('Yes')
        exit()

print('No')

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

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

is_open = []
for b in B:
    for j in range(3):
        for i in range(3):
            if card[j][i] == b:
                is_open.append((i, j))

is_open_list = [True if (i, j) in is_open else False for i in range(3) for j in range(3)]

for i in range(3):
    if is_open_list[i] and is_open_list[i + 3] and is_open_list[i + 6]:
        print('Yes')
        exit()
    elif is_open_list[3 * i] and is_open_list[3 * i + 1] and is_open_list[3 * i + 2]:
        print('Yes')
        exit()

if is_open_list[0] and is_open_list[4] and is_open_list[8]:
    print('Yes')
    exit()
elif is_open_list[2] and is_open_list[4] and is_open_list[6]:
    print('Yes')
    exit()

print('No')

Solution (Python):
import sys
a = [[0] * 3 for i in range(3)]
ans = [[0] * 3 for i in range(3)]
for i in range(3):
    a[i][0],a[i][1],a[i][2] = map(int, input().split())
N = int(input())
b = [input() for i in range(N)]
for i in range(3):
    for j in range(3):
        if ans[i][j] == 1:
            break
        for k in range(N):
            if a[i][j] == int(b[k]):
                ans[i][j] = 1
                break
for i in range(3):
    if ans[i][0] == 1 and ans[i][1] == 1 and ans[i][2] == 1:
        print('Yes')
        sys.exit()
for j in range(3):
    if ans[0][j] == 1 and ans[1][j] == 1 and ans[2][j] == 1:
        print('Yes')
        sys.exit()
if ans[0][0] == 1 and ans[1][1] == 1 and ans[2][2] == 1:
    print('Yes')
    sys.exit()
if ans[0][2] == 1 and ans[1][1] == 1 and ans[2][0] == 1:
    print('Yes')        
    sys.exit()
print('No')

Solution (Python):
bingo = []
for i in range(3):
    bingo.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 bingo[i][j] == b:
                bingo[i][j] = "o"

for i in range(3):
    flag = 0
    for j in range(3):
        if bingo[i][j] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()
    flag = 0
    for j in range(3):
        if bingo[j][i] == "o":
            flag += 1
    if flag == 3:
        print("Yes")
        exit()

if (
    bingo[0][0] == bingo[1][1] == bingo[2][2] == "o"
    or bingo[0][2] == bingo[1][1] == bingo[2][0] == "o"
):
    print("Yes")
    exit()
print("No")

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

if a[0][0] in b and a[0][1] in b and a[0][2] in b:
    print('Yes')
    exit()
if a[1][0] in b and a[1][1] in b and a[1][2] in b:
    print('Yes')
    exit()
if a[2][0] in b and a[2][1] in b and a[2][2] in b:
    print('Yes')
    exit()
if a[0][0] in b and a[1][0] in b and a[2][0] in b:
    print('Yes')
    exit()
if a[0][1] in b and a[1][1] in b and a[2][1] in b:
    print('Yes')
    exit()
if a[0][2] in b and a[1][2] in b and a[2][2] in b:
    print('Yes')
    exit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
    exit()
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
    print('Yes')
    exit()
print('No')

Solution (Python):
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60


a = [[int(j) for j in input().split()] for i in range(3)]


n = int(input())
ans = [[0 for j in range(3)] for i in range(3)]
b = [int(input()) for i in range(n)]


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


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

elif ans[0][0] == ans[1][0] == ans[2][0] == 1:
    print("Yes")
elif ans[0][1] == ans[1][1] == ans[2][1] == 1:
    print("Yes")
elif ans[0][2] == ans[1][2] == ans[2][2] == 1:
    print("Yes")

elif ans[0][0] == ans[1][1] == ans[2][2] == 1:
    print("Yes")
elif ans[0][2] == ans[1][1] == ans[2][0] == 1:
    print("Yes")

else:
    print("No")

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

d = a

for k1, i in enumerate(a):
    for k2, j in enumerate(a[k1]):
        if a[k1][k2] in b:
            d[k1][k2]=0
l = 0
for i in range(3):
    if d[i][0] == 0 and d[i][1] == 0 and d[i][2] == 0:
        l += 1
    if d[0][i] == 0 and d[1][i]==0 and d[2][i]==0:
        l += 1
    if d[0][0] == 0 and d[1][1] == 0 and d[2][2] == 0:
        l += 1
    if d[0][2] == 0 and d[1][1] == 0 and d[2][0] == 0:
        l += 1
if l != 0:
    print("Yes")
else:
    print("No")

Solution (Python):
A=[]
B=[]
for i in range(3):
    a1,a2,a3=input().split()
    A.append([int(a1),int(a2),int(a3)])

N=int(input())
for i in range(N):
    B.append(int(input()))

    
ans="No"

for i in range(3):
	if B.count(A[0][0])* B.count(A[0][1])* B.count(A[0][2])!=0\
or  B.count(A[1][0])* B.count(A[1][1])* B.count(A[1][2])!=0\
or  B.count(A[2][0])* B.count(A[2][1])* B.count(A[2][2])!=0\
or  B.count(A[0][0])* B.count(A[1][0])* B.count(A[2][0])!=0\
or  B.count(A[0][2])* B.count(A[1][2])* B.count(A[2][2])!=0\
or  B.count(A[0][1])* B.count(A[1][1])* B.count(A[2][1])!=0\
or  B.count(A[0][0])* B.count(A[1][1])* B.count(A[2][2])!=0\
or  B.count(A[0][2])* B.count(A[1][1])* B.count(A[2][0])!=0:
		ans="Yes"
    
print(ans)

Solution (Python):
A= list(map(int, input().split()))
B= list(map(int, input().split()))
C= list(map(int, input().split()))
N = int(input())
D = [int(input()) for j in range(N)]
a = D.count(A[0])
b = D.count(A[1])
c = D.count(A[2])
d = D.count(B[0])
e = D.count(B[1])
f = D.count(B[2])
g = D.count(C[0])
h = D.count(C[1])
i = D.count(C[2])
Sum1 = (a + b + c +1) % 4
Sum2 = (d + e + f + 1) % 4
Sum3 = (g + h + i +1) % 4
Sum4 = (a + e + i +1) % 4
Sum5 = (c + e + g +1) % 4
Sum6 = (a + d + g +1) % 4
Sum7 = (b + e + h +1) % 4
Sum8 = (c + f + i +1) % 4
list = [Sum1,Sum2,Sum3,Sum4,Sum5,Sum6,Sum7,Sum8]
s = list.count(0)
if s >= 1:
    print("Yes")
else:
    print("No")

Solution (Python):
whith1 = list(map(int,input().split()))
whith2 = list(map(int,input().split()))
whith3 = list(map(int,input().split()))
b = whith1 + whith2 + whith3
n = int(input())
num = []
for i in range(n):
    x = int(input())
    if x in b :
        b = [0 if i == x else i for i in b]
if b[0] == b[1] == b[2] or b[3] == b[4] == b[5] == 0 or b[6] == b[7] == b[8] == 0:
    print('Yes')
elif b[0] == b[3] == b[6] or b[1] == b[4] == b[7] == 0 or b[2] == b[5] == b[8] == 0:
    print('Yes')
elif b[0] == b[4] == b[8] or b[2] == b[4] == b[6] == 0 or b[6] == b[7] == b[8] == 0:
    print('Yes')
else :
    print('No')

Solution (Python):
A = []
for i in range(0, 3):
  a = input().split(' ')
  for j in a:
    A.append(int(j))


N = int(input())

for i in range(0, N):
  data = int(input())
  if data in A:
    A[A.index(data)] = 0

if sum(A[0:3]) == 0 \
or sum(A[3:6]) == 0 \
or sum(A[6:9]) == 0 \
or A[0] + A[4] + A[8] == 0 \
or A[2] + A[4] + A[6] == 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: 
  print("Yes")
else:
  print("No")

Solution (Python):

a = []
for i in range(3):
    a.append([int(i) for i in input().split()])
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

"""
c = [a[0][0], a[0][1], a[0][2]]
d = [a[1][0], a[1][1], a[1][2]]
e = [a[2][0], a[2][1], a[2][2]]
f = [a[0][0], a[1][0], a[2][0]]
g = [a[0][1], a[1][1], a[2][1]]
h = [a[0][2], a[1][2], a[2][2]]
i = [a[0][0], a[1][1], a[2][2]]
j = [a[2][0], a[1][1], a[0][2]]
"""

tmp = []
tmp2 = 0
tmp3 = 0
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                tmp.append([j,k])
                tmp2 += j
                tmp3 += k

count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
count6 = 0
flag = "No"
for i in range(len(tmp)):
    if tmp[i][0] == 0:
        count1 += 1
    if tmp[i][0] == 1:
        count2 += 1
    if tmp[i][0] == 2:
        count3 += 1
    if tmp[i][1] == 0:
        count4 += 1
    if tmp[i][1] == 1:
        count5 += 1
    if tmp[i][1] == 2:
        count6 += 1
if count1 >= 3 or count2 >= 3 or count3 >= 3 or count4 >= 3 or count5 >= 3 or count6 >= 3:
    flag = "Yes"
else:
    tmp4 = 0
    tmp5 = 0
    for i in range(len(tmp)):
        if (tmp[i][0] == 0 and tmp[i][1] == 0) or (tmp[i][0] == 1 and tmp[i][1] == 1) or (tmp[i][0] == 2 and tmp[i][1] == 2):
            tmp4 += 1
        if (tmp[i][0] == 0 and tmp[i][1] == 2) or (tmp[i][0] == 1 and tmp[i][1] == 1) or (tmp[i][0] == 2 and tmp[i][1] == 0):
            tmp5 += 1
    if tmp4 >= 3 or tmp5 >= 3:
        flag = "Yes"
print(flag)

Solution (Python):
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy










sc=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
data=[[0 for i in range(3)] for x in range(3)]

for b in B:
    for i in range(3):
        for x in range(3):
            if sc[i][x]==b:
                data[i][x]=1

for nlst in ([[[i,x] for i in range(3)] for x in range(3)],\
[[[x,i] for i in range(3)] for x in range(3)],\
[[[i,i] for i in range(3)]],\
[[[i,2-i] for i in range(2,-1,-1)]]):

    for lst in nlst:
        count=0
        for i,x in lst:
            count+=data[i][x]

        if count==3:
            print("Yes")
            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())))
n=int(input())
L=[]
for i in range(n):
    L.append(int(input()))
M=[[0,0,0],[0,0,0],[0,0,0]]
for i in L:
    for j in range(3):
        for k in range(3):
            if i==A[j][k]:
                M[j][k]=1

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

if M[0][0]+M[1][0]+M[2][0]==3 or M[0][1]+M[1][1]+M[2][1]==3 or M[0][2]+M[1][2]+M[2][2]==3:
        print("Yes")
        exit()

if M[0][0]+M[1][1]+M[2][2]==3 or M[0][2]+M[1][1]+M[2][0]==3:
    print("Yes")
    exit()
    
print("No")

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

b=set(b)
ch=[]
for i in range(3):
    ch.append([0,0,0])

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

for i in range(3):
    s=0
    for j in range(3):
        s+=ch[i][j]
    if s==3:
        print("Yes")
        exit()

for i in range(3):
    s = 0
    for j in range(3):
        s += ch[j][i]
    if s == 3:
        print("Yes")
        exit()

s=0
for i in range(3):
   s+=ch[i][i]
if s==3:
    print("Yes")
    exit()

s=0
for i in range(3):
   s+=ch[i][2-i]
if s==3:
    print("Yes")
    exit()

print("No")

Solution (Python):
from bisect import bisect_right, bisect_left
from collections import Counter, deque
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import groupby, permutations, combinations, product
from sys import stdin, stderr





def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)





def exgcd(x, y):
    if y == 0:
        return 1, 0
    a, b = exgcd(y, x % y)
    return b, a - (x // y) * b



def lcm(x, y):
    m = gcd(x, y)
    return (x // m) * (y // m)


def main():
    a = []
    a.append([int(x) for x in input().split()])
    a.append([int(x) for x in input().split()])
    a.append([int(x) for x in 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
    tate = [0, 0, 0]
    yoko = [0, 0, 0]
    naname = [0, 0]
    for i in range(3):
        for j in range(3):
            tate[i] += a[i][j]
            yoko[j] += a[i][j]
        naname[0] += a[i][i]
        naname[1] += a[i][2 - i]
    
    
    
    if -3 in tate or -3 in yoko or -3 in naname:
        return "Yes"
    return "No"


if __name__ == "__main__":
    print(main())

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

for i in range(n):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:
        a[j][k]=-1

ans='No'
for i in a:
  if list(i)==[-1,-1,-1]:
    ans='Yes'
for i in zip(*a):
  if list(i)==[-1,-1,-1]:
    ans='Yes'
if a[0][0]+a[1][1]+a[2][2]==-3:
  ans='Yes'
if a[0][2]+a[1][1]+a[2][0]==-3:
  ans='Yes'


print(ans)

Solution (Python):
b1 = [int(x) for x in input().split()]
b2 = [int(x) for x in input().split()]
b3 = [int(x) for x in input().split()]
n = int(input())
li = list()
for i in range(n):
    li.append(int(input()))

b1_0 = False
b1_1 = False
b1_2 = False
b2_0 = False
b2_1 = False
b2_2 = False
b3_0 = False
b3_1 = False
b3_2 = False

for name in li:
    for j ,name2 in enumerate(b1):
        if(name2 == name):
            if(j == 0):
                b1_0 = True
            elif(j == 1):
                b1_1 = True
            else:
                b1_2 = True
    for k,name3 in enumerate(b2):
        if(name == name3):
            if(k == 0):
                b2_0 = True
            elif(k == 1):
                b2_1 = True
            else:
                b2_2 = True
    for l,name4 in enumerate(b3):
        if(name == name4):
            if(l == 0):
                b3_0 = True
            elif(l == 1):
                b3_1 = True
            else:
                b3_2 = True
            
if (b1_0 and b1_1 and b1_2):
    print("Yes")
elif (b2_0 and b2_1 and b2_2):
    print("Yes")
elif (b3_0 and b3_1 and b3_2):
    print("Yes")
elif (b1_0 and b2_0 and b3_0):
    print("Yes")
elif (b1_1 and b2_1 and b3_1):
    print("Yes")
elif(b1_2 and b2_2 and b3_2):
    print("Yes")
elif (b1_0 and b2_1 and b3_2):
    print("Yes")
elif (b1_2 and b2_1 and b3_0):
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
def resolve_b():
    card = [list(map(int, input().split())) for i in range(3)]
    l = [[0,0,0],[0,0,0],[0,0,0]]
    n = int(input())

    for i in range(n):
        num = int(input())
        for j in range(3):
            for k in range(3):
                if card[j][k] == num:
                    l[j][k] = 1
    nl = np.array(l)

    if sum(l[0]) == 3 or sum(l[1]) == 3 or sum(l[2]) == 3 or sum(l[:][0]) == 3 or sum(nl[:,0]) ==3 or sum(nl[:,1]) ==3 or sum(nl[:,2])==3:
        print("Yes")
    elif (l[0][0] + l[1][1] + l[2][2]) == 3 or (l[0][2] + l[1][1] + l[2][0])==3:
        print("Yes")
    else:
        print("No")
        
resolve_b()

Solution (Python):

import numpy as np
A = np.zeros((3,3))
A[0,0],A[0, 1], A[0,2]  = map(int, input().split())
A[1,0],A[1, 1], A[1,2]  = map(int, input().split())
A[2,0],A[2, 1], A[2,2]  = map(int, input().split())

N = int(input())
b = np.ndarray(N)
for i in range(N):
  b[i] = int(input())

B = np.zeros((3,3))

for i in range(N):
  B[A==b[i]] = 1

B1 = np.sum(B, axis=0)
B2 = np.sum(B, axis=1)
B3 = B[0,0] + B[1,1] + B[2,2]
B4 = B[2,0] + B[1,1] + B[0,2]

if(sum(B1 == 3) + sum(B2 == 3) >=1):
  print('Yes')
elif(B3 == 3 or B4 == 3):
  print('Yes')
else:
  print('No')

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

Solution (Python):
B1 = list(map(int, input().split()))
B2 = list(map(int, input().split()))
B3 = list(map(int, input().split()))
B= B1+B2+B3
N = int(input())
for n in range(N):
  num = int(input())
  B = [0 if i == num else i for i in B]
  if (B[0]+B[1]+B[2])*(B[3]+B[4]+B[5])*(B[6]+B[7]+B[8])*(B[0]+B[3]+B[6])*(B[1]+B[4]+B[7])*(B[2]+B[5]+B[8])*(B[0]+B[4]+B[8])*(B[2]+B[4]+B[6]) == 0:
    print('Yes')
    exit()
print('No')