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):
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)

if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Solution (Python):
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


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


if (a[0]in d) and (a[1]in d) and(a[2]in d):
    print("Yes")
    exit()
if (b[0]in d)and(b[1]in d)and(b[2]in d):
    print("Yes")
    exit()
if (c[0]in d)and(c[1]in d)and(c[2]in d):
    print("Yes")
    exit()
if (a[2]in d)and(b[1]in d)and(c[0]in d):
    print("Yes")
    exit()
if (a[0]in d)and(b[1]in d)and(c[2]in d):
    print("Yes")
    exit()
if (a[0]in d)and(b[0]in d)and(c[0]in d):
    print("Yes")
    exit()
if (a[2]in d)and(b[2]in d)and(c[2]in d):
    print("Yes")
    exit()
else:
    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()))
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))

flag = 0
for i in range(N):
  for j in range(3):
    if b[i] == A1[j]:
      A1[j] = 0
    elif b[i] == A2[j]:
      A2[j] = 0
    elif b[i] == A3[j]:
      A3[j] = 0
if A2[1] == 0:
  if A2[0] == 0 and A2[2] == 0:
    flag = 1
  elif A1[1] == 0 and A3[1] == 0:
    flag = 1
  elif A1[0] == 0 and A3[2] == 0:
    flag = 1
  elif A1[2] == 0 and A3[0] == 0:
    flag = 1
elif A1[0] == 0 and A1[1] == 0 and A1[2] == 0:
  flag = 1
elif A1[0] == 0 and A2[0] == 0 and A3[0] == 0:
  flag = 1
elif A1[2] == 0 and A2[2] == 0 and A3[2] == 0:
  flag = 1
elif A3[0] == 0 and A3[1] == 0 and A3[2] == 0:
  flag = 1
  
if flag == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
def bingo(b):
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1

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

A = [[int(i) for i in input().split()] for _ in range(3)]
B = [[0]*3 for _ in range(3)]
N = int(input())
for _ in range(N):
    b = int(input())
    bingo(b)
if judge():
    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())
N = int(input())
num = []
for i in range(N):
    num.append(int(input()))

if (a11 in num and a12 in num and a13 in num) == True:
    print('Yes')
elif (a21 in num and a22 in num and a23 in num) == True:
    print('Yes')
elif (a31 in num and a32 in num and a33 in num) == True:
    print('Yes')
elif (a11 in num and a21 in num and a31 in num) == True:
    print('Yes')
elif (a12 in num and a22 in num and a32 in num) == True:
    print('Yes')
elif (a13 in num and a23 in num and a33 in num) == True:
    print('Yes')
elif (a11 in num and a22 in num and a33 in num) == True:
    print('Yes')
elif (a31 in num and a22 in num and a13 in num) == 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)]

check = [[0, 0, 0] for _ in range(3)]



for i in range(n):
    for j in range(0, 3):
        for k in range(0, 3):
            if int(b[i]) == int(a[j][k]):
                check[j][k] = 1





if sum(check[0]) == 3 or sum(check[1]) == 3 or sum(check[2]) == 3:
    print('Yes')
    exit()
elif check[0][0]+check[1][0]+check[2][0] == 3 or check[0][1]+check[1][1]+check[2][1]== 3 or check[0][2]+check[1][2]+check[2][2] == 3:
    print('Yes')
    exit()
elif check[0][0]+check[1][1]+check[2][2] == 3 or check[0][2]+check[1][1]+check[2][0] == 3:
    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()))
a = a1+a2+a3
n = int(input())
b = list(int(input()) for _ in range(n))

for i in b:
    if i in a :
        a[a.index(i)] = "h"

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

Solution (Python):
a = [int(i) for i in input().split()]
for i in range(2):
	a.extend([int(i) for i in input().split()])
n = int(input())
b = []
for i in range(n):
	b = int(input())
	if b in a:
		a[a.index(b)] = 0
if a.count(0) < 3:
	print("No")		
elif a[0] == 0 and a[1] == 0 and a[2] == 0:
	print("Yes")
elif a[3] == 0 and a[4] == 0 and a[5] == 0:
	print("Yes")
elif a[6] == 0 and a[7] == 0 and a[8] == 0:
	print("Yes")
elif a[0] == 0 and a[3] == 0 and a[6] == 0:
	print("Yes")
elif a[1] == 0 and a[4] == 0 and a[7] == 0:
	print("Yes")
elif a[2] == 0 and a[5] == 0 and a[8] == 0:
	print("Yes")
elif a[0] == 0 and a[4] == 0 and a[8] == 0:
	print("Yes")
elif a[2] == 0 and a[4] == 0 and a[6] == 0:
	print("Yes")
else:
	print("No")

Solution (Python):
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())

r = {
    'r0': 0,
    'r1': 0,
    'r2': 0,
    'c0': 0,
    'c1': 0,
    'c2': 0,
    'x0': 0,
    'x1': 0,

}

for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                r['r{}'.format(j)] += 1
                r['c{}'.format(k)] += 1
                if j == k:
                    r['x0'] += 1
                if (j == 0 and k == 2) or (j == 1 and k == 1) or (j == 2 and k == 0):
                    r['x1'] += 1

for b in r.values():
    if b == 3:
        print('Yes')
        exit() 
print('No')

Solution (Python):
from itertools import combinations as comb

A = [[int(i) for i in input().split(' ')] for j in  range(3)]
n = int(input())
B = [int(input()) for i in range(n)]

flat = A[0] + A[1] + A[2]
ls = [b for b in B if b in flat]
ls = list(sorted(c) for c in comb(ls, 3))

bingo = [
	sorted(A[0]),
	sorted(A[1]),
	sorted(A[2]),
	sorted([A[0][0], A[1][0], A[2][0]]),
	sorted([A[0][1], A[1][1], A[2][1]]),
	sorted([A[0][2], A[1][2], A[2][2]]),
	sorted([A[0][0], A[1][1], A[2][2]]),
	sorted([A[0][2], A[1][1], A[2][0]])
]

ans = 'No'
for b in bingo:
  if b in ls:
    ans = 'Yes'
    break

print(ans)

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


result = 'No'

for i in range(3):
    if set(A[i]) <= set(b):
        result = 'Yes'

for i in range(3):
    if set([A[0][i], A[1][i], A[2][i]]) <= set(b):
        result = 'Yes'

if set([A[0][0], A[1][1], A[2][2]]) <= set(b):
    result = 'Yes'

if set([A[0][2], A[1][1], A[0][2]]) <= set(b):
    result = 'Yes'

print(result)

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

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

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

    ans = 'No'

    for bbb in list(B):
        for i in range(3):
            if A[i][0] == bbb:
                A[i][0] = 1000
            if A[i][1] == bbb:
                A[i][1] = 1000
            if A[i][2] == bbb:
                A[i][2] = 1000

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

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

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

    print(ans)


resolve()

Solution (Python):
A = [[]*3]*3

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

N = int(input())

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

result = "No"

if(A[0][0] in B and A[0][1] in B and A[0][2] in B):
  result = "Yes"
if(A[1][0] in B and A[1][1] in B and A[1][2] in B):
  result = "Yes"
if(A[2][0] in B and A[2][1] in B and A[2][2] in B):
  result = "Yes"
if(A[0][0] in B and A[1][0] in B and A[2][0] in B):
  result = "Yes"
if(A[0][1] in B and A[1][1] in B and A[2][1] in B):
  result = "Yes"
if(A[0][2] in B and A[1][2] in B and A[2][2] in B):
  result = "Yes"
if(A[0][0] in B and A[1][1] in B and A[2][2] in B):
  result = "Yes"
if(A[0][2] in B and A[1][1] in B and A[2][0] in B):
  result = "Yes"

print(result)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    
    line = [a for a in A]
    
    line.append([A[i][0] for i in range(3)])
    line.append([A[i][1] for i in range(3)])
    line.append([A[i][2] for i in range(3)])
    line.append([A[0][0], A[1][1], A[2][2]])
    line.append([A[0][2], A[1][1], A[2][0]])

    
    
    for Al in line:
        
        if len(set(b) & set(Al)) == 3:
            print(YES)
            sys.exit()
    print(NO)

    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)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

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

aa = [0] * 8
for i in range(3):
    for j in range(3):
        if bingo[i][j] in b:
            aa[i] += 1
            aa[j+3] += 1
            if i == j:
                aa[-2] += 1
            if i + j == 2:
                aa[-1] += 1
ans = 'No'
for a in aa:
    if a >= 3:
        ans = "Yes"
        break
print(ans)

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())
B = []
for _ in range(N):
    B.append(int(input()))
ans =  [0]*9
for i in range(N):
    if B[i] in A:
        ans[A.index(B[i])] = 1

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

Solution (Python):

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

N = int(input())
for _ in range(N):
    K = int(input())
    for i in range(3):
        for j in range(3):        
            if K == bingo[i][j]:
                bingo[i][j] = 1000

ans = False
for i in range(3):
    if set(bingo[i]) == {1000}:
        ans = True

for i in range(3):
    cnt = []
    for k in range(3):
        cnt.append(bingo[k][i])
    if set(cnt) == {1000}:
        ans = True
cnt1 = []
cnt2 = []
cnt3 = []
cnt4 = []
for i in range(3):    
    k = 2-i
    cnt1.append(bingo[i][k])
    cnt2.append(bingo[k][i])
    cnt3.append(bingo[i][i])
    cnt4.append(bingo[k][k])
if set(cnt1) == {1000}:
    ans = True
if set(cnt2) == {1000}:
    ans = True
if set(cnt3) == {1000}:
    ans = True
if set(cnt4) == {1000}:
    ans = True
if ans:
    print("Yes")
if ans == False:
    print("No")

Solution (Python):
A = []
for _ in range(3):
    A += [int(v) for v in input().strip().split()]
N = int(input())
nums = [int(input()) for _ in range(N)]

for n in nums:
    try:
        A[A.index(n)] = -1
    except ValueError:
        pass

def _(A):
    for i in range(3):
        if len(set(A[i*3:(i*3+3)])) == 1:
            return "Yes"
    for i in range(3):
        if len(set(A[i::3])) == 1:
            return "Yes"
    if A[0] * A[4] * A[8] == -1:
        return "Yes"
    if A[2] * A[4] * A[6] == -1:
        return "Yes"
    return "No"

print(_(A))

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 n in range(N):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j] == a:
        A[i][j] = -1
      
for i in range(3):
  if all(a == -1 for a in A[i]):
    print('Yes')
    exit()
        
for j in range(3):
  if all(a[j] == -1 for a in A):
    print('Yes')
    exit()

if all(a == -1 for a in [A[0][0], A[1][1], A[2][2]]):
  print('Yes')
  exit()

if all(a == -1 for a in [A[0][2], A[1][1], A[2][0]]):
  print('Yes')
  exit()

print('No')

Solution (Python):
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst3 = list(map(int, input().split()))
n = int(input())
lst = []
for i in range(n):
    
    inp = int(input())
    if inp in lst1:
        lst.append((1, lst1.index(inp)+1))
    if inp in lst2:
        lst.append((2, lst2.index(inp)+1))
    if inp in lst3:
        lst.append((3, lst3.index(inp)+1))
row_wise = [[(1, 1), (1, 2), (1, 3)], [(2, 1), (2, 2), (2, 3)],
            [(3, 1), (3, 2), (3, 3)]]
column_wise = [[(1, 1), (2, 1), (3, 1)], [
    (1, 2), (2, 2), (3, 2)], [(1, 3), (2, 3), (3, 3)]]
diagonal_wise = [[(1, 1), (2, 2), (3, 3)], [(3, 1), (2, 2), (1, 3)], ['Blank']]

is_bingo = False
for i in range(3):
    if all(elem in lst for elem in row_wise[i]):
        is_bingo = True
        print('Yes')
        break
    if all(elem in lst for elem in column_wise[i]):
        is_bingo = True
        print('Yes')
        break
    if all(elem in lst for elem in diagonal_wise[i]):
        is_bingo = True
        print('Yes')
        break
if not is_bingo:
    print('No')

Solution (Python):
A = []
for i in range(3):
    p,q,r = map(int, input().split())
    A.append(p)
    A.append(q)
    A.append(r)
n = int(input())
for i in range(n):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0

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

Solution (Python):
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
n = int(input())
b_n = [int(input()) for i in range(n)]

for b in b_n:
    for i in range(3):
        if a_1[i] == b:
            a_1[i] = 0
        if a_2[i] == b:
            a_2[i] = 0
        if a_3[i] == b:
            a_3[i] = 0
            
            

flag = "No"
if a_1[0] == 0 and a_1[1] == 0 and a_1[2] == 0:
    flag = "Yes"
if a_2[0] == 0 and a_2[1] == 0 and a_2[2] == 0:
    flag = "Yes"
if a_3[0] == 0 and a_3[1] == 0 and a_3[2] == 0:
    flag = "Yes"

for i in range(3):
    if a_1[i] == 0 and a_2[i] == 0 and a_3[i] == 0:
        flag = "Yes"
       
     
if a_1[0] == 0 and a_2[1] == 0 and a_3[2] == 0:
    flag = "Yes"
if a_3[0] == 0 and a_2[1] == 0 and a_1[2] == 0:
    flag = "Yes"

print(flag)

Solution (Python):
import itertools
L = [list(map(int, input().split())) for i in range(3)]
L = list(itertools.chain.from_iterable(L))
bool_L = [[False, False, False] for i in range(3)]
N = int(input())
b_L = [int(input()) for i in range(N)]

for b in b_L:
    if b in L:
        index = L.index(b)
        show = index // 3
        amari = index % 3
        bool_L[show][ amari] = True
        
flag = "No"
for i in bool_L:
    if i == [True, True, True]:
        flag = "Yes"
        break
        
for j in range(3):
    temp_l = []
    for i in range(3):
        temp_l.append(bool_L[i][j])
    if temp_l == [True, True, True]:
        flag = "Yes"
        break

if [bool_L[0][0],bool_L[1][1],bool_L[2][2]] == [True, True, True]:
    flag = "Yes"
elif [bool_L[2][0],bool_L[1][1],bool_L[0][2]] == [True, True, True]:
     flag = "Yes"
print(flag)

Solution (Python):
ban=[]
result=[False]*9
for i in range(3):
    a,b,c=map(int,input().split())
    ban.append(a)
    ban.append(b)
    ban.append(c)
n=int(input())
sen=[]
for i in range(n):
    temp=int(input())
    for i in range(9):
        if(ban[i]==temp):
            result[i]=True

ans=False
check=[[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 c in check:
    if(result[c[0]] and result[c[1]] and result[c[2]]):
       ans=True

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

Solution (Python):
r1 = list(map(int, input().split(' ')))
r2 = list(map(int, input().split(' ')))
r3 = list(map(int, input().split(' ')))
card = [r1, r2, r3]
card_after = card

N = int(input())

b_list = []

for _ in range(N):
	b_list.append(int(input()))

for b in b_list:
	for i, row in enumerate(card):
		for j, A in enumerate(row):
			if A == b:
				card_after[i][j] = True

card = card_after
bingo = False


if card[0][0] == card[0][1] == card[0][2] or card[1][0] == card[1][1] == card[1][2] or card[2][0] == card[2][1] == card[2][2]:
	bingo = True


if card[0][0] == card[1][0] == card[2][0] or card[0][1] == card[1][1] == card[2][1] or card[0][2] == card[1][2] == card[2][2]:
	bingo = True


if card[0][0] == card[1][1] == card[2][2] or card[2][0] == card[1][1] == card[2][0]:
	bingo = True

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

Solution (Python):

A = list()
for _ in range(3):
    a1, a2, a3 = list(map(int, input().split()))
    A.append(a1)
    A.append(a2)
    A.append(a3)

N = int(input())

for _ in range(N):
    b = int(input())
    for i in range(len(A)):
        if A[i] == b:
            A[i] = 0

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

Solution (Python):
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()
n=int(input())
l=[]
for _ in range(n):
   l.append(input())
if e in l:
    if i in l and a in l or b in l and h in l or c in l and g in l or d in l and f in l:
        print('Yes')
    else:
        print('No')
elif a in l:
    if d in l and g in l or b in l and c in l:
        print('Yes')
    else:
        print('No')
elif i in l:
    if c in l and f in l or g in l and h in l:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from collections import OrderedDict


a = OrderedDict()
for i in range(3):
    for j in input().split():
        a[j] = 0

n = int(input())
for i in range(n):
    inp = input()
    if inp in a.keys():
        a[inp] = 1

anss = list(a.values())
lines = [(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 x,y,z in lines:
    if anss[x] + anss[y] + anss[z] == 3:
        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())
bg1, bg2, bg3 = [0]*3, [0]*3, [0]*3
for i in range(N):
  b = int(input())
  for j in range(3):
    if b == A1[j]:
      bg1[j] = 1
    if b == A2[j]:
      bg2[j] = 1
    if b == A3[j]:
      bg3[j] = 1
if sum(bg1) == 3 or sum(bg2) == 3 or sum(bg3) == 3:
  print("Yes")
elif bg1[0]+bg2[0]+bg3[0]==3 or bg1[1]+bg2[1]+bg3[1]==3 or bg1[2]+bg2[2]+bg3[2]==3:
  print("Yes")
elif bg1[0]+bg2[1]+bg3[2]==3 or bg1[2]+bg2[1]+bg3[0]==3:
  print("Yes")
else:
  print("No")

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

N = int(input())
card = np.array(card)
atari = np.zeros((3,3))

for _ in range(N):
  b = int(input())
  atari[card==b] = 1



if any([atari.all(axis=0).any(), atari.all(axis=1).any(), all([atari[0,0], atari[1,1], atari[2,2]]), all([atari[0,2], atari[1,1], atari[2,0]])]):
  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())
b = []
for _ in range(n):
    _b = int(input())
    b.append(_b)
    for i in range(3):
        for j in range(3):
            if a[i][j] == _b:
                a[i][j] = 0

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

Solution (Python):
AA = []

for i in range(3):
    AA.append(input().split())

N = int(input())
for i in range(N):
    bi = input()
    for i in range(3):
        aa = AA[i]
        for a in range(3):
            if bi == aa[a]:
                AA[i][a] = 'B'
            

flag = 0
for i in range(3):
    aa = AA[i]
    flag = 1
    for j in range(3):
        if aa[j] != 'B':
            flag = 0 
    if flag == 1:
        break

if flag == 0:
    for i in range(3):
        flag = 1
        for j in range(3):
            if AA[j][i] != 'B':
                flag = 0
        if flag == 1:
            break


if flag == 0:
    flag = 1
    for i in range(3):
        if AA[i][i] != 'B':
            flag = 0
if flag ==0: 
    flag = 1
    for i in range(3):
        if AA[i][2-i] != 'B':
            flag = 0


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

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


def main(A, N, lst_b):
    
    matrix_result = [[False]*3 for i in range(3)]
    flag_bingo = False

    for b in lst_b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    matrix_result[i][j] = True
        
    for i in range(3):
        
        if (matrix_result[0][i] and matrix_result[1][i] and matrix_result[2][i]):
            flag_bingo = True
        
        if (matrix_result[i][0] and matrix_result[i][1] and matrix_result[i][2]):
            flag_bingo = True
    
    
    if (matrix_result[0][0] and matrix_result[1][1] and matrix_result[2][2]):
        flag_bingo = True
    elif (matrix_result[0][2] and matrix_result[1][1] and matrix_result[2][0]):
        flag_bingo = True
    
    if flag_bingo: return "Yes"
    else         : return "No"
    

if __name__ == "__main__":

    answer = main(A, N, lst_b)
    print(answer)

Solution (Python):
a=[[0,0,0] for i in range(3)]
for i in range(3):
    *a[i], = map(int, input().split())    
def check(b):
    for i in range(3):
        for j in range(3):
            if b==a[i][j]:
                a[i][j]=0
                break
def bingo():
    if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
        return True
    if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
        return True    
    for i in range(3):
         if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
                return True
    for j in range(3):
         if a[0][j]==0 and a[1][j]==0 and a[2][j]==0:
                return True
    return False

n=int(input())
for i  in range(n):
    check(int(input()))

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

Solution (Python):
import numpy as np

def bingo(A):
    for i in range(3):
        if (A[i,0] == 0) and (A[i,1] == 0) and (A[i,2] == 0):
            return True
        
        if (A[0,i] == 0) and (A[1,i] == 0) and (A[2,i] == 0):
            return True
    
    if A[1, 1] == 0:
        if (A[0, 0] == 0) and (A[2, 2] == 0):
            return True
        if (A[0, 0] == 0) and (A[2, 2] == 0):
            return True
        if (A[2, 0] == 0) and (A[0, 2] == 0):
            return True
        if (A[2, 0] == 0) and (A[2, 0] == 0):
            return True
    else:
        return False
    
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A1 = np.array(A1)
A2 = np.array(A2)
A3 = np.array(A3)
A = np.array([A1,A2,A3])

n = int(input())


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

if bingo(A) == True:
    print("Yes")

else:
    print("No")

Solution (Python):

a=[]
call_num=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
n=int(input())
for i in range(n):
    x=int(input())
    if x in a:
        call_num.append(a.index(x))
bingo=False
ans=[[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 x in ans:
    flag=True
    for y in x:
        if y not in call_num:
            flag=False
    if flag:
        print("Yes")
        bingo=True
        break
if bingo!=True:
    print("No")

Solution (Python):
a1 = input().split(" ")
a2 = input().split(" ")
a3 = input().split(" ")
A = [a1, a2, a3]
N = int(input())
for i in range(N):
    j = input()
    for k in A:
        for l in k:
            if l == j:
                x = k.index(l)
                k.pop(x)
                k.insert(x, "○")
            else:
                pass
ans = 0
for i in A:
    if len(set(i)) == 1:
        ans += 1
    else:
        pass
if a1[0] =="○":
    if a2[0] == "○":
        if a3[0] == "○":
            ans += 1
if a1[1] == "○":
    if a2[1] == "○":
        if a3[1] == "○":
            ans += 1
if a1[2] == "○":
    if a2[2] == "○":
        if a3[2] == "○":
            ans += 1
if a1[0] == "○":
    if a2[1] == "○":
        if a3[2] == "○":
            ans += 1
if a1[2] == "○":
    if a2[1] == "○":
        if a3[0] == "○":
            ans += 1
if ans >= 1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

a1i = list(map(int, input().split()))
a2i = list(map(int, input().split()))
a3i = list(map(int, input().split()))
n = int(input())
bi = [int(input()) for i in range(n)]

for b in bi:
    a1i = [0 if a == b else a for a in a1i]
    a2i = [0 if a == b else a for a in a2i]
    a3i = [0 if a == b else a for a in a3i]
    
for i in range(3):
    if (a1i[i] == 0 and a2i[i] == 0 and a3i[i] == 0):
        print('Yes')
        sys.exit()

if (a1i[0] == 0 and a2i[1] == 0 and a3i[2] == 0) \
    or (a1i[2] == 0 and a2i[1] == 0 and a3i[0] == 0):
        print('Yes')
        sys.exit()
        
if (len(set(a1i)) == 1 or len(set(a2i)) == 1 or len(set(a3i)) == 1):
    print('Yes')
    sys.exit()

print('No')

Solution (Python):
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))
n = int(input())
bs = []
for i in range(n):
    bs.append(int(input()))

bs = set(bs)

atari = (set(row1) <= bs or
set(row2) <= bs or
set(row3) <= bs or
set([row1[0], row2[0], row3[0]]) <= bs or
set([row1[1], row2[1], row3[1]]) <= bs or
set([row1[2], row2[2], row3[2]]) <= bs or
set([row1[0], row2[1], row3[2]]) <= bs or
set([row1[2], row2[1], row3[0]]) <= bs
)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A = [tuple(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]

    ans = [[[] for _ in range(3)] for _ in range(3)]
    for i, A_ in enumerate(A):
        for j, a in enumerate(A_):
            ans[i][j] = a in B

    if (all(ans[0]) or all(ans[1]) or all(ans[2])
        or all([ans[0][0], ans[1][0], ans[2][0]])
        or all([ans[0][1], ans[1][1], ans[2][1]])
        or all([ans[0][2], ans[1][2], ans[2][2]])
        or all([ans[0][0], ans[1][1], ans[2][2]])
        or all([ans[2][0], ans[1][1], ans[0][2]])):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):


from fractions import gcd
import math
from math import ceil,floor
import collections






def func(a):
   return tmp

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

ans="No"

for i in range(0,N):
    for j in range(0,3):
        for k in range(0,3):
            if B[i]==A[j][k]:
                A[j][k]=0
                
for i in range(0,3):
    if A[i][0]==0 and A[i][1]==0 and A[i][2]==0:
        ans = "Yes"

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

if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    ans = "Yes"

if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    ans = "Yes"

print(ans)