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 =[]
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
B = [0]*N
for i in range(N):
    B[i] = int(input())

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

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

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

print('No')

Solution (Python):
A = {}

for i in range(3):
    a1, a2, a3 = map(int, input().split())
    A[a1] = (i+1,1)
    A[a2] = (i+1,2)
    A[a3] = (i+1,3)

N = int(input())

Bingo = {}
for i in range(3):
    Bingo[(i+1,1)] = False
    Bingo[(i+1,2)] = False
    Bingo[(i+1,3)] = False

for i in range(N):
    B = int(input())
    if B in A:
        Bingo[A[B]] = True

ans = False

for i in range(1, 4):
    ans = ans or (Bingo[(i,1)] and Bingo[(i,2)] and Bingo[(i,3)])
    ans = ans or (Bingo[(1,i)] and Bingo[(2,i)] and Bingo[(3,i)])
ans = ans or (Bingo[(1,1)] and Bingo[(2,2)] and Bingo[(3,3)])
ans = ans or (Bingo[(1,3)] and Bingo[(2,2)] and Bingo[(3,1)])

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

Solution (Python):
A = []
index = {}
for i in range(3):
    lst = list(map(int,input().split()))
    for idx,l in enumerate(lst):
        index[l] = (i,idx)
    A.append(lst)
N = int(input())

for _ in range(N):
    s = int(input())
    if s in index:
        i,j = index[s]
        A[i][j] = 0

for i in range(3):
    if sum(A[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    su = 0
    for j in range(3):
        su+=A[j][i]
    if su == 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")

Solution (Python):

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

list = [[0] * 3 for i in range(3)]

N = int(input())

for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == S[j][k]:
                list[j][k] += 1



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

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


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


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

anc = 0
for row in a:
    cnt = 0
    for col in row:
        if col in b:
            cnt += 1
    if cnt == 3:
        anc += 1
        break
for i,row in enumerate(a):
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        anc += 1 
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        anc += 1
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
        anc += 1

if anc >= 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)]

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


for i in range(N):
    for x in range(3):
        for y in range(3):
            if A[x][y] == b[i]:
                card[x][y] = 1

ans = "No"

for i in range(3):
    if sum(card[i]) == 3:
        ans = "Yes"

if sum([card[i][i] for i in range(3)]) == 3:
    ans = "Yes"

if sum([card[i][2 - i] for i in range(3)]) == 3:
    ans = "Yes"

for i in range(3):
    if sum([card[j][i] for j in range(3)]) == 3:
        ans = "Yes"

print(ans)

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

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

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

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

if sum([A[i][j] for i, j in [[2, 0], [1, 1], [0, 2]]]) == 0:
    print('Yes')
    exit()

print('No')

Solution (Python):
A = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = list(map(int, input().split()))
N = int(input())
B = [0] * N
for i in range(N):
    B[i] = list(map(int, input().split()))

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

if (A[0][0] == A[0][1] and A[0][1] == A[0][2]) or (A[1][0] == A[1][1] and A[1][1] == A[1][2]) or (
        A[2][0] == A[2][1] and A[2][1] == A[2][2]) or (A[0][0] == A[1][0] and A[1][0] == A[2][0]) or (
        A[0][1] == A[1][1] and A[1][1] == A[2][1]) or (A[0][2] == A[1][2] and A[1][2] == A[2][2]) or (
        A[0][0] == A[1][1] and A[1][1] == A[2][2]) or (A[0][2] == A[1][1] and A[1][1] == A[2][0]):
    print("Yes")
else:
    print("No")

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

import numpy as np
A = np.array(A)

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

ans = [[False] * 3 for _ in range(3)]
ans = np.array(ans)

for b in B:
    temp = (A == b)

    ans = np.logical_or(ans, temp)


if ans[0, :].all() or ans[1, :].all() or ans[2, :].all():
    print("Yes")

elif ans[:, 0].all() or ans[:, 1].all() or ans[:, 2].all():
    print("Yes")

elif ans[0, 0] and ans[1, 1] and ans[2, 2]:
    print("Yes")
elif ans[0, 2] and ans[1, 1] and ans[2, 0]:
    print("Yes")
else:
    print("No")

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas


A1n = list(map(lambda n: [n, 0], mulinputs()))
A2n = list(map(lambda n: [n, 0], mulinputs()))
A3n = list(map(lambda n: [n, 0], mulinputs()))
N = intinput()

As = [A1n, A2n, A3n]



bs = []
for i in range(N):
    
    b = int(input())
    for row in As:
        for col in row:
            if b == col[0]:
                col[1] = 1

is_bingo = True
is_bingo &= (As[0][0][1] == 1)
is_bingo &= (As[1][1][1] == 1)
is_bingo &= (As[2][2][1] == 1)

if is_bingo:
    print('Yes')
    exit()

is_bingo = True
is_bingo &= (As[2][0][1] == 1)
is_bingo &= (As[1][1][1] == 1)
is_bingo &= (As[0][2][1] == 1)

if is_bingo:
    print('Yes')
    exit()

for row in As:
    if len(list(filter(lambda x: x[1]==1, row))) == 3:
        print('Yes')
        exit()

is_bingo = True
is_bingo &= (As[2][0][1] == 1)
is_bingo &= (As[1][0][1] == 1)
is_bingo &= (As[0][0][1] == 1)

if is_bingo:
    print('Yes')
    exit()

is_bingo = True
is_bingo &= (As[2][1][1] == 1)
is_bingo &= (As[1][1][1] == 1)
is_bingo &= (As[0][1][1] == 1)

if is_bingo:
    print('Yes')
    exit()

is_bingo = True
is_bingo &= (As[2][2][1] == 1)
is_bingo &= (As[1][2][1] == 1)
is_bingo &= (As[0][2][1] == 1)

if is_bingo:
    print('Yes')
    exit()

print('No')

Solution (Python):
A = [[int(s) for s in input().split()] for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

def in_B(n, B):
  if n in B:
    return True
  else:
    return False
    
is_B = [[in_B(A[i][j],B) for j in range(3)] for i in range(3)]

bingo_idx = [[(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)],
             [(2,0), (1,1), (0,2)]]

bingo = False
for a, b, c in bingo_idx:
  ai, aj = a
  bi, bj = b
  ci, cj = c
  if is_B[ai][aj] and is_B[bi][bj] and is_B[ci][cj]:
    bingo = True
    break

if bingo:
  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(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                a[j][k] = '

if a[0][0] == "
    print('Yes')
elif a[1][0] == "
    print('Yes')
elif a[2][0] == "
    print('Yes')
elif a[0][0] == "
    print('Yes')
elif a[0][1] == "
    print('Yes')
elif a[0][2] == "
    print('Yes')
elif a[0][0] == "
    print('Yes')
elif a[0][2] == "
    print('Yes')
else:
    print('No')

Solution (Python):



def solve(*args: str) -> str:
    A = []
    for i in range(3):
        A.extend(map(int, args[i].split()))

    n = int(args[3])
    B = map(int, args[4:])

    M = [False]*9
    for b in B:
        for j in range(9):
            M[j] |= A[j] == b

    bingo = False

    for y in range(3):
        bingo |= all(M[y*3:y*3+3])

    for x in range(3):
        bingo |= all([M[x], M[x+3], M[x+6]])

    bingo |= all([M[0], M[4], M[8]])
    bingo |= all([M[2], M[4], M[6]])

    return 'Yes' if bingo else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

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

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


flag = False
for row in range(3):
    for col in range(3):
        if bingo[row][col] is None:
            continue
        else:
            break
    else:
        flag = True

for row in range(3):
    for col in range(3):
        if bingo[col][row] is None:
            continue
        else:
            break
    else:
        flag = True

if bingo[0][0] is None and bingo[1][1] is None and bingo[2][2] is None:
    flag = True
if bingo[0][2] is None and bingo[1][1] is None and bingo[2][0] is None:
    flag = True

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

Solution (Python):
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
n = int(input())
B = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(n):
    N =  int(input())
    for num, j in enumerate([A1,A2,A3]):
        for num2, k in enumerate(j):
            if k == N:
                B[num][num2] = True
                
flag = False
for i in B:
    if i[0]==True and i[1]==True and i[2]==True:
        flag = True
        break
else:
    for i in range(3):
        if B[0][i]==True and B[1][i]==True and B[2][i]==True:
            flag = True
            break
    else:
        if (B[0][0]==True and B[1][1]==True and B[2][2]==True) or (B[0][2]==True and B[1][1]==True and B[2][0]==True):
            flag = True

if flag == True:
    print("Yes")
else:
    print("No")

Solution (Python):
bingo = False
A = []
for _ in range(3):
  a = list(map(int, input().split()))
  A.append(a)
  
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

if sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[2]) == 0 or sum([A[0][0], A[1][0], A[2][0]]) == 0 or sum([A[0][1], A[1][1], A[2][1]]) == 0 or sum([A[0][2], A[1][2], A[2][2]]) == 0 or sum([A[0][0], A[1][1], A[2][2]]) == 0 or sum([A[2][0], A[1][1], A[0][2]]) == 0:
  bingo = True

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

Solution (Python):
import itertools 

A = [list(map(int,input().split())) for i in range(3)]
AA = list(itertools.chain.from_iterable(A))
grid = []
N = int(input())
for i in range(N):
  b = int(input())
  if b in AA:
    grid.append(AA.index(b))
    


if (0 in grid and 4 in grid and 8 in grid) or (2 in grid and 4 in grid and 6 in grid):
  print("Yes")
elif(0 in grid and 1 in grid and 2 in grid) or (3 in grid and 4 in grid and 5 in grid) or (6 in grid and 7 in grid and 8 in grid):
  print("Yes")
elif(0 in grid and 3 in grid and 6 in grid) or (1 in grid and 4 in grid and 7 in grid) or (2 in grid and 5 in grid and 8 in grid):
  print("Yes")
else:
  print("No")

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

b = [[0, 0, 0],[0, 0, 0], [0, 0, 0]]
flag = 0

for _ in range(n):
    x = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == x:
                b[j][k] = 1
                
if b[0] == [1, 1, 1]:
    flag = 1
elif b[1] == [1, 1, 1]:
    flag = 1
elif b[2] == [1, 1, 1]:
    flag = 1
elif b[0][0] == 1 and b[1][0] == 1 and b[2][0] == 1:
    flag = 1
elif b[0][1] == 1 and b[1][1] == 1 and b[2][1] == 1:
    flag = 1
elif b[0][2] == 1 and b[1][2] == 1 and b[2][2] == 1:
    flag = 1
elif b[0][0] == 1 and b[1][1] == 1 and b[2][2] == 1:
    flag = 1
elif b[0][2] == 1 and b[1][1] == 1 and b[2][0] == 1:
    flag = 1
if flag:
    print("Yes")
else:
    print("No")

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



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


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

Solution (Python):
A = []
for i in range(3):
    for x in map(int, input().split()):
        A.append(x)
for _ in range(int(input())):
    x = int(input())
    if x in A:
        A[A.index(x)] = 'b'
cds = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6]
]
for cd in cds:
    if A[cd[0]] == 'b' and A[cd[1]] == 'b' and A[cd[2]] == 'b':
        print('Yes')
        exit()
print('No')

Solution (Python):
L=[]
tmp=0
for i in range (3):
	L.append(list(map(int,input().split())))
N=int(input())
X=[]
for i in range (N):
	X.append(int(input()))
for i in range(N):
	for j in range(3):
		for k in range(3):
			if L[j][k]==X[i]:
				L[j][k]=0
if L[0][0]==0:
	if L[0][1]==0 and L[0][2]==0:
		tmp+=1
	if L[1][0]==0 and L[2][0]==0:
		tmp+=1
	if L[1][1]==0 and L[2][2]==0:
		tmp+=1
if L[1][1]==0:
	if L[1][0]==0 and L[1][2]==0:
		tmp+=1
	if L[0][1]==0 and L[2][1]==0:
		tmp+=1
	if L[0][2]==0 and L[2][0]==0:
		tmp+=1
if L[2][2]==0:
	if L[0][2]==0 and L[1][2]==0:
		tmp+=1
	if L[2][0]==0 and L[2][1]==0:
		tmp+=1
if tmp!=0:
	print("Yes")
else:
	print("No")

Solution (Python):
A=[]
B=[[0,0,0],[0,0,0],[0,0,0]]
bseq=[]
for i in range(3):
    a,b,c=map(int,input().split())
    A.append([a,b,c])
n=int(input())
for i in range(n):
    bseq.append(int(input()))
    
for i in range(n):
    for j in range(3):
        for k in range(3):
            if A[j][k]==bseq[i]:
                B[j][k]=1
bingo=0
if B[0][0]==1 and B[0][1]==1 and B[0][2]==1:
    bingo+=1
if B[1][0]==1 and B[1][1]==1 and B[1][2]==1:
    bingo+=1
if B[2][0]==1 and B[2][1]==1 and B[2][2]==1:
    bingo+=1
if B[0][0]==1 and B[1][0]==1 and B[2][0]==1:
    bingo+=1
if B[0][1]==1 and B[1][1]==1 and B[2][1]==1:
    bingo+=1
if B[0][2]==1 and B[1][2]==1 and B[2][2]==1:
    bingo+=1
if B[0][0]==1 and B[1][1]==1 and B[2][2]==1:
    bingo+=1
if B[2][0]==1 and B[1][1]==1 and B[0][2]==1:
    bingo+=1
if bingo>=1:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []

A.append(input().split(' '))
A.append(input().split(' '))
A.append(input().split(' '))

N = int(input())

bingo = [['0']*3 for i in range(3)]

b = 0
for i in range(N):
    b = input()
    for j in range(3):
        for k in range(3):
            if(b == A[j][k]):
                bingo[j][k] = '1'


if(bingo[0][0] == '1' and bingo[0][1] == '1' and bingo[0][2] == '1'):
    print("Yes")
elif(bingo[1][0] == '1' and bingo[1][1] == '1' and bingo[1][2] == '1'):
    print("Yes")
elif(bingo[2][0] == '1' and bingo[2][1] == '1' and bingo[2][2] == '1'):
    print("Yes")
elif(bingo[0][0] == '1' and bingo[1][0] == '1' and bingo[2][0] == '1'):
    print("Yes")
elif(bingo[0][1] == '1' and bingo[1][1] == '1' and bingo[2][1] == '1'):
    print("Yes")
elif(bingo[0][2] == '1' and bingo[1][2] == '1' and bingo[2][2] == '1'):
    print("Yes")
elif(bingo[0][0] == '1' and bingo[1][1] == '1' and bingo[2][2] == '1'):
    print("Yes")
elif(bingo[2][0] == '1' and bingo[1][1] == '1' and bingo[0][2] == '1'):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

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

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

c = [0] * 9

for i in b:
    for index , j in enumerate(A):
        if i == j:
            c[index] = 1



if c[0] == 1 and c[1] == 1 and c[2] == 1:
    print("Yes")
    sys.exit()
elif c[3] == 1 and c[4] == 1 and c[5] == 1:
    print("Yes")
    sys.exit()
elif c[6] == 1 and c[7] == 1 and c[8] == 1:
    print("Yes")
    sys.exit()



if c[0] == 1 and c[3] == 1 and c[6] == 1:
    print("Yes")
    sys.exit()
elif c[1] == 1 and c[4] == 1 and c[7] == 1:
    print("Yes")
    sys.exit()
elif c[2] == 1 and c[5] == 1 and c[8] == 1:
    print("Yes")
    sys.exit()

if c[0] == 1 and c[4] == 1 and c[8] == 1:
    print("Yes")
    sys.exit()
elif c[2] == 1 and c[4] == 1 and c[6] == 1:
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
import numpy as np

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

a = np.array(a1+a2+a3)
a = a.reshape(3,3)

n = int(input())

for i in range(n):
  b = int(input())
  a = np.where(a==b, 0, a)

bng = 0
for i in range(3):
  r_sum = 0
  c_sum = 0
  for j in range(3):
    r_sum += a[i][j]
    c_sum += a[j][i]
  if r_sum==0 or c_sum==0:
    bng = 1

x_sum = 0
x_sum2 = 0
for i in range(3):
  x_sum += a[i][i]
  x_sum2 += a[2-i][i]
if x_sum==0 or x_sum2 ==0:
  bng = 1

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

Solution (Python):
tst = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
A = [list(map(int, input().split())) for j in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
for i in b:
    for j in range(3):
        for k in range(3):
            if A[j][k] == i:
                tst[j][k] = 1

if sum(tst[0]) == 3 or \
        sum(tst[1]) == 3 or \
        sum(tst[2]) == 3 or \
        tst[0][0] + tst[1][0] + tst[2][0] == 3 or \
        tst[0][1] + tst[1][1] + tst[2][1] == 3 or \
        tst[0][2] + tst[1][2] + tst[2][2] == 3 or \
        tst[0][0] + tst[1][1] + tst[2][2] == 3 or \
        tst[0][2] + tst[1][1] + tst[2][0] == 3:
    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())
for i in range(N):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            num = a[j].index(b)
            a[j][num] = 0
f = a
flag = False

for i in f:
    if i[0] == 0 and i[1]==0 and i[2]==0:
        flag = True

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

if f[0][0] == 0 and f[1][1]==0 and f[2][2]==0: 
    flag = True 
elif f[0][2] ==0 and f[1][1]==0 and f[2][0]==0:
    flag = True
print('Yes' if flag==True else 'No')

Solution (Python):

"""
Created on Sun Mar  1 13:17:41 2020

@author: naoki
"""

import sys








A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b_flat = [int(input()) for _ in range(N)]    
    
count3 = 0
count4 = 0
for j in range(3):
    count1 = 0
    count2 = 0
    for i in range(3):
        if A[j][i] in b_flat:
            count1 += 1
        if A[i][j] in b_flat:
            count2 += 1
    if count1 == 3 or count2 == 3:
        print("Yes")
        sys.exit()
    if A[j][j] in b_flat:
        count3 += 1
    if A[j][-(j+1)] in b_flat:
        count4 += 1
if count3 == 3 or count4 == 3:
    print("Yes")
    sys.exit()

print("No")

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

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

if sum(A[0]) == 0:
    print('Yes')
elif sum(A[1]) == 0:
    print('Yes')
elif sum(A[2]) == 0:
    print('Yes')
elif sum([i[0] for i in A]) == 0:
    print('Yes')
elif sum([i[1] for i in A]) == 0:
    print('Yes')
elif sum([i[2] for i in A]) == 0:
    print('Yes')
elif sum([A[0][0], A[1][1], A[2][2]]) == 0:
    print('Yes')
elif sum([A[0][2], A[1][1], A[2][0]]) == 0:
    print('Yes')
else :
    print('No')

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

aList = list([A11, A12, A13, A21, A22, A23, A31, A32, A33])

N = int(input())


bList = list([])

for indx in range(N):
    bList.append(int(input()))


for b_indx in range(N):
    for a_indx in range(int(9)):
        if aList[a_indx] == bList[b_indx]:
            aList[a_indx] = -1

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

Solution (Python):
C=[[0]*3 for i in range(3)]
D=[[0]*3 for i in range(3)]
for i in range(3):
    d=list(map(int,input().split()))
    C[i][0]=d[0]
    C[i][1]=d[1]
    C[i][2]=d[2]
N=int(input())
for i in range(N):
    b=int(input())
    for s in range(3):
        for t in range(3):
            if(b==C[s][t]):
                D[s][t]=1

ans="No"
for i in range(3):
    c=0
    for j in range(3):
        c+=D[i][j]
    if(c==3):
        ans="Yes"

for i in range(3):
    c=0
    for j in range(3):
        c+=D[j][i]
    if(c==3):
        ans="Yes"

c=0
c=D[0][0]+D[1][1]+D[2][2]
if(c==3):
    ans="Yes"

c=0
c=D[0][2]+D[1][1]+D[2][0]
if(c==3):
    ans="Yes"
print(ans)

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

for i in range(N):
	for j in range(3):
		for k in range(3):
			if A[j][k] == b[i]:
				A[j][k] = '○'

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

print('No')

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
s = [int(input()) for _ in range(n)]

a = a1+a2+a3
ans = 'No'
for i in range(n):
    for j in range(9):
        if s[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:
    ans = 'Yes'
if a[0]==a[3]==a[6]==0 or a[1]==a[4]==a[7]==0 or a[2]==a[5]==a[8]==0:
    ans = 'Yes'
if a[0]==a[4]==a[8]==0 or a[2]==a[4]==a[6]==0:
    ans = 'Yes'
print(ans)

Solution (Python):
import math
import sys

input = sys.stdin.readline


def main():
    bingo = [list(map(int, input().split())) for _ in range(3)]
    for _ in range(int(input())):
        n = int(input())
        for i in range(3):
            for j in range(3):
                if bingo[i][j] == n:
                    bingo[i][j] = True

    ret = False
    for i in range(3):
        is_break = False
        for j in range(3):
            if bingo[i][j] is not True:
                is_break = True
                break
        if not is_break:
            ret = True
            break

    if ret is True:
        print('Yes')
        return

    for i in range(3):
        is_break = False
        for j in range(3):
            if bingo[j][i] is not True:
                is_break = True
                break
        if not is_break:
            ret = True
            break

    if ret is True:
        print('Yes')
        return

    if bingo[0][0] is True and bingo[1][1] is True and bingo[2][2] is True:
        print('Yes')
        return

    if bingo[0][2] is True and bingo[1][1] is True and bingo[2][0] is True:
        print('Yes')
        return

    print('No')


if __name__ == '__main__':
    main()

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

A = sum(A,[])
for b in B:
    if b in A:
        A[A.index(b)] = -1

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

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

Solution (Python):
A = list()
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 = [0]*101

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

bingo = 'No'

for j in range(3):
  t = 0
  y = 0
  for i in range(3):
    y += B[A[i][j]]
    t += B[A[j][i]]
  if y == 3 or t == 3:
    bingo = 'Yes'


if (B[A[0][0]] + B[A[1][1]] + B[A[2][2]] == 3) or (B[A[2][0]] + B[A[1][1]] + B[A[0][2]] == 3):
    bingo = 'Yes'

print(bingo)

Solution (Python):
import numpy as np 

A = np.ones([3,3])

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

b = np.ones(N)

for i in range(N):
    b[i] = int(input())
    
    
sheet  = np.zeros([3,3])

for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j,k] == b[i]:
                sheet[j,k] +=1
dummy = 0
for i in range(3):
    if all([j>0 for j in sheet[:,i]]):
        dummy+= 1
    elif all([j>0 for j in sheet[i,:]]):
        dummy += 1
if (sheet[0,0] >0) & (sheet[1,1] >0) & (sheet[2,2] >0):
    dummy += 1
if (sheet[2,0] >0) & (sheet[1,1] >0) & (sheet[0,2] >0):
    dummy += 1
        
if dummy >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):
    c = 0
    for j in range(3):
        if A[i][j] in b:
            c += 1
    if c == 3:
        print('Yes')
        exit()

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

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

B=[[0]*3 for i in range(3)]

N=int(input())
for k in range(N):
    n=int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==n:
                B[i][j]=1


if B[0][0]==B[0][1]==B[0][2]==1:
    f=True
elif B[1][0]==B[1][1]==B[1][2]==1:
    f=True
elif B[2][0]==B[2][1]==B[2][2]==1:
    f=True
elif B[0][0]==B[1][0]==B[2][0]==1:
    f=True
elif B[0][1]==B[1][1]==B[2][1]==1:
    f=True
elif B[0][2]==B[1][2]==B[2][2]==1:
    f=True
elif B[0][0]==B[1][1]==B[2][2]==1:
    f=True
elif B[2][0]==B[1][1]==B[0][2]==1:
    f=True
else:
    f=False

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

Solution (Python):

a = [[0 for i2 in range(3)] for i1 in range(3)]
chk = [[0 for i2 in range(3)] for i1 in range(3)]

a[0] = [int(x) for x in input().split()]
a[1] = [int(x) for x in input().split()]
a[2] = [int(x) for x in input().split()]


N = int(input())

for k in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                chk[i][j] = 1
bingo = 0

if chk[0][0]*chk[0][1]*chk[0][2] == 1:
    bingo = 1
if chk[1][0]*chk[1][1]*chk[1][2] == 1:
    bingo = 1
if chk[2][0]*chk[2][1]*chk[2][2] == 1:
    bingo = 1

if chk[0][0]*chk[1][0]*chk[2][0] == 1:
    bingo = 1
if chk[0][1]*chk[1][1]*chk[2][1] == 1:
    bingo = 1
if chk[0][2]*chk[1][2]*chk[2][2] == 1:
    bingo = 1

if chk[0][0]*chk[1][1]*chk[2][2] == 1:
    bingo = 1
if chk[0][2]*chk[1][1]*chk[2][0] == 1:
    bingo = 1

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

Solution (Python):
A = []
for _ in range(3):
    A.extend([int(x) for x in input().rstrip().split()])
N = int(input().rstrip())
for i in range(N):
    tmp = int(input().rstrip())
    for j, x in enumerate(A):
        if A[j] == tmp:
            A[j] = 'o'
if A[0] == 'o' and A[1] == 'o' and A[2] == 'o':
    print('Yes')
elif A[3] == 'o' and A[4] == 'o' and A[5] == 'o':
    print('Yes')
elif A[6] == 'o' and A[7] == 'o' and A[8] == 'o':
    print('Yes')
elif A[0] == 'o' and A[3] == 'o' and A[6] == 'o':
    print('Yes')
elif A[1] == 'o' and A[4] == 'o' and A[7] == 'o':
    print('Yes')
elif A[2] == 'o' and A[5] == 'o' and A[8] == 'o':
    print('Yes')
elif A[0] == 'o' and A[4] == 'o' and A[8] == 'o':
    print('Yes')
elif A[2] == 'o' and A[4] == 'o' and A[6] == 'o':
    print('Yes')
else:
    print('No')