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):
bingo = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
cnt = [0]*8
for i in range(3):
    for j in range(3):
        if bingo[i][j] in b:
            cnt[i] += 1
            cnt[j+3] += 1
            if i == j:
                cnt[-1] += 1
            if i+j == 2:
                cnt[-2] += 1
ans = "No"
for i in cnt:
    if i >= 3:
        ans = "Yes"
        break
print(ans)

Solution (Python):

a_list = [input().split() for i in range(3)]
N = int(input())
call_num = [input() for i in range(N)]

bingo =""

bingo = "No"
yoko = [i for i in a_list if set(i) & set(call_num) ==set(i)]
if 0 < len(yoko):
    bingo ="Yes"


a_tate =[]
for i,v in enumerate(a_list):
    ta =[]
    for j in range(3):
        ta.append(a_list[j][i])
    a_tate.append(ta)

tate =""
for i in a_tate:
    if len(set(i) & set(call_num) ) ==3 :
        tate +="ss"
if 0 < len(tate):
    bingo ="Yes"


a_naname_1 = set([a_list[0][0],a_list[1][1],a_list[2][2] ])
a_naname_2 = set([a_list[0][2],a_list[1][1],a_list[2][0] ])
if a_naname_1 & set(call_num) == a_naname_1:
    bingo = "Yes"
if a_naname_2 & set(call_num) == a_naname_2:
    bingo = "Yes"
print(bingo)

Solution (Python):
def check_line(start, dxy):
    x, y = start
    dx, dy = dxy
    flg = bingo[x][y]
    for _ in range(2):
        x += dx
        y += dy
        flg &= bingo[x][y]
    return flg

Alist = [list(map(int, input().split())) for _ in range(3)]
Aset = set()
for line in Alist:
    Aset |= set(line)
bingo = [[False] * 3 for i in range(3)]
N = int(input())
br = False
for _ in range(N):
    b = int(input())
    if b in Aset:
        for x in range(3):
            for y in range(3):
                if Alist[x][y] == b:
                    bingo[x][y] = True

ans = False
for i in range(3):
    ans |= check_line((0, i), (1, 0))
    ans |= check_line((i, 0), (0, 1))
ans |= check_line((0, 0), (1, 1))
ans |= check_line((0, 2), (1, -1))
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
a = [[int(i) for i in input().split()] for l in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for target in b:
    for i in range(len(a)):
        for j in range(len(a[0])):
            if a[i][j] == target:
                a[i][j]=0

for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0 or a[0][i]==a[1][i]==a[2][i]==0:
        print("Yes")
        sys.exit()

if a[1][1] == a[2][2] == a[0][0]==0 or a[0][2] == a[1][1] == a[2][0]==0:
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
a = []
a_bool = [False for i in range(9)]
for j in range(3):[a.append(i) for i in list(map(int, input().split()))]
n = int(input())
for i in range(n):
    b = int(input())
    if b in a:
        a_bool[a.index(b)] = True
if (a_bool[0] and a_bool[1] and a_bool[2]) or (a_bool[3] and a_bool[4] and a_bool[5]) or (a_bool[6] and a_bool[7] and a_bool[8]) or (a_bool[0] and a_bool[3] and a_bool[6]) or (a_bool[1] and a_bool[4] and a_bool[7]) or (a_bool[2] and a_bool[5] and a_bool[8]) or (a_bool[0] and a_bool[4] and a_bool[8]) or (a_bool[2] and a_bool[4] and a_bool[6]):
    print('Yes')
else:
    print('No')

Solution (Python):
data = []
for j in range(3):
  data.extend([int (i) for i in input().split()])

bingo_dic = {}
for i, d in enumerate(data):
  bingo_dic[d] = i
  
N = int(input())

bingo = [0,0,0,0,0,0,0,0,0]
for _ in range(N):
  i = int(input())
  if i in bingo_dic.keys():
    bingo[bingo_dic[i]] = 1
    
if bingo[0] + bingo[1] + bingo[2] == 3:
  print('Yes')
  exit()
  
if bingo[3] + bingo[4] + bingo[5] == 3:
  print('Yes')
  exit()
  
if bingo[6] + bingo[7] + bingo[8] == 3:
  print('Yes')
  exit()
  
if bingo[0] + bingo[3] + bingo[6] == 3:
  print('Yes')
  exit()

if bingo[1] + bingo[4] + bingo[7] == 3:
  print('Yes')
  exit()
  
if bingo[2] + bingo[5] + bingo[8] == 3:
  print('Yes')
  exit()
  
if bingo[0] + bingo[4] + bingo[8] == 3:
  print('Yes')
  exit()

if bingo[2] + bingo[4] + bingo[6] == 3:
  print('Yes')
  exit()

print('No')

Solution (Python):
import numpy as np
a = list(map(int,input().split(' ')))
b = list(map(int,input().split(' ')))
c = list(map(int,input().split(' ')))
x = [a,b,c]
hit = []
zero = np.zeros((3,3))
count = int(input())
for i in range(count):
  hit.append(int(input()))

  

flag = np.zeros((3,3))
for j in hit:
  for n,i in enumerate(x):
    if j in i:
      one = i.index(j)
      zero[n][one] = 1



point = np.sum(zero,axis=0)
point2 = np.sum(zero,axis=1)
apoint =      np.append(point,point2,)
hnaname = zero[0][0]+zero[1][1]+zero[2][2] 
mnaname = zero[0][2]+zero[1][1]+zero[2][0] 
apoint = np.append(apoint,hnaname)
apoint = np.append(apoint,mnaname)

if 3 in apoint:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys

def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

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



done = [[0] * 3 for _ in range(3)]
for k in range(N):
    for i in range(3):
        for j in range(3):
            if b[k] == A[i][j]:
                done[i][j] = 1


ans = "No"
for i in range(3):
    flg = True
    for j in range(3):
        if done[i][j] == 0:
            flg = False
    if flg:
        ans = "Yes"
for i in range(3):
    flg = True
    for j in range(3):
        if done[j][i] == 0:
            flg = False
    if flg:
        ans = "Yes"

flg = True
for j in range(3):
    if done[j][j] == 0:
        flg = False
if flg:
    ans = "Yes"
flg = True
for j in range(3):
    if done[2-j][j] == 0:
        flg = False
if flg:
    ans = "Yes"

print(ans)

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

result = [[0] * 3 for _ in range(3)]

for b in B:
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                result[i][j] = 1

flg = False

for i in range(3):
    if sum([result[i][j] for j in range(3)]) == 3:
        flg = True

for j in range(3):
    if sum([result[i][j] for i in range(3)]) == 3:
        flg = True

if sum([result[i][i] for i in range(3)]) == 3:
    flg = True

if sum([result[i][2-i] for i in range(3)]) == 3:
    flg = True

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

Solution (Python):
A = [[0 for j in range(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())

s = [[False for j in range(3)] for i in range(3)]
for k in range(N):
    b_k = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b_k:
                s[i][j] = True

bingo = False
if s[0][0] and s[0][1] and s[0][2]:
    bingo = True
if s[1][0] and s[1][1] and s[1][2]:
    bingo = True
if s[2][0] and s[2][1] and s[2][2]:
    bingo = True
if s[0][0] and s[1][0] and s[2][0]:
    bingo = True
if s[0][1] and s[1][1] and s[2][1]:
    bingo = True
if s[0][2] and s[1][2] and s[2][2]:
    bingo = True
if s[0][0] and s[1][1] and s[2][2]:
    bingo = True
if s[2][0] and s[1][1] and s[0][2]:
    bingo = True

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

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]
d = [[0] * 3 for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
def bingo(l1, l2):
    global d
    for i in l2:
        for j in range(3):
            for k in range(3):
                if l1[j][k] == i:
                    d[j][k] = 1
    for i in range(3):
        if d[i][0] == 1 and d[i][1] == 1 and d[i][2] == 1:
            return "Yes"
        elif d[0][i] == 1 and d[1][i] == 1 and d[2][i] == 1:
            return "Yes"
    if d[0][0] == 1 and d[1][1] == 1 and d[2][2]:
        return "Yes"
    elif d[2][0] == 1 and d[1][1] == 1 and d[0][2]:
        return "Yes"
    else:
        return "No"
print(bingo(a,b))

Solution (Python):
line_0 = list(map(int, input().split()))
line_1 = list(map(int, input().split()))
line_2 = list(map(int, input().split()))
num = int(input())

is_open = [[False, False, False], [False, False, False], [False, False, False]]
for i in range(num):
    open_num = int(input())
    for j in range(3):
        if line_0[j] == open_num:
            is_open[0][j] = True
        if line_1[j] == open_num:
            is_open[1][j] = True
        if line_2[j] == open_num:
            is_open[2][j] = True

clear = "No"

if is_open[0] == [True, True, True]:
    clear = "Yes"
if is_open[1] == [True, True, True]:
    clear = "Yes"
if is_open[2] == [True, True, True]:
    clear = "Yes"

for i in range(3):
    if is_open[0][i] == is_open[1][i] == is_open[2][i] == True:
        clear = "Yes"

if is_open[0][0] == is_open[1][1] == is_open[2][2] == True:
    clear = "Yes"
if is_open[0][2] == is_open[1][1] == is_open[2][0] == True:
    clear = "Yes"

print(clear)

Solution (Python):
array= []
for i in range(3):
    array.append(list(map(int,input().split())))
n= int(input())
number=[]
answer = "No"
for i in range(n):
    number.append(input())

for i in range (3):
    for j in range(3):
        for k in range(n):
            if int(array[i][j]) == int(number[k]):
                array[i][j] = 8101919

for i in range (3):
    if array[i][0] & array[i][1] & array[i][2] == 8101919:        
        answer = "Yes"

for i in range(3):
    if array[0][i] & array[1][i] & array[2][i] == 8101919:
        answer = "Yes"

if array[0][0] & array[1][1] & array[2][2] == 8101919:
    answer = "Yes"
           
if array[2][0] & array[1][1] & array [0][2] == 8101919:
    answer = "Yes"

print(answer)

Solution (Python):
Field = [list(map(int, input().split(" "))) for i in range(3)]
N = int(input())
num =[]
for i in range(N):
    t = int(input())
    num.append(t)
count=0
for i in Field:
    for t in range(3):
        if i[t] in num:
            i[t] = 0

for i in Field:
    if sum(i) == 0:
        count+=1

for i in range(3):
    if Field[0][i] == 0 and Field[1][i] == 0 and Field[2][i] == 0:
        count+=1

if Field[0][0] == 0 and Field[1][1] == 0 and Field[2][2] == 0:
    count+=1
if Field[0][2] == 0 and Field[1][1] == 0 and Field[2][0] == 0:
    count+=1

if count != 0:
    print("Yes")
else:
    print("No")

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

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

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

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

Solution (Python):
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
for i in range(n):
  b = int(input())
  if b in a1:
    
    num = a1.index(b)
    a1[num] = "v"
  elif b in a2:
    num = a2.index(b)
    a2[num] = "v"
  elif b in a3:
    num = a3.index(b)
    a3[num] = "v"
if a1.count("v")==3 or a2.count("v")==3 or a3.count("v")==3 or a1[0]==a2[0]==a3[0]=="v" or a1[1]==a2[1]==a3[1]=="v" or a1[2]==a2[2]==a3[2]=="v" or a1[0]==a2[1]==a3[2]=="v" or a1[2]==a2[1]==a3[0]=="v":
  print("Yes")
else:
  print("No")

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

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

ans = "No"

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 0:
        ans = "Yes"
    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):
a = []
for i in range(3):
    a += list(map(int, input().split()))
bg = [False]*9
n = int(input())
for i in range(n):
    b = int(input())
    if b in a:
        bg[a.index(b)] = True

num = [[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 num:
    if bg[x] and bg[y] and bg[z]:
        print('Yes')
        exit()
print('No')

Solution (Python):
class BingoCard:
    def __init__(self, bingolist):
        self.bingocard = bingolist

    def call(self, b):
        for i in range(3):
            for j in range(3):
                if b == self.bingocard[i][j]:
                    self.bingocard[i][j] = 0

    def check_bingo(self):
        bingo = False
        
        for row in self.bingocard:
            if row[0] + row[1] + row[2] == 0:
                bingo = True
        
        for i in range(3):
            if self.bingocard[0][i] == 0:
                if self.bingocard[1][i] + self.bingocard[2][i] == 0:
                    bingo = True
        
        if self.bingocard[1][1] == 0:
            if self.bingocard[0][0] + self.bingocard[2][2] == 0 or\
                self.bingocard[0][2] + self.bingocard[2][0] == 0:
                bingo = True
        return bingo


bingo0 = list(map(int, input().split(" ")))
bingo1 = list(map(int, input().split(" ")))
bingo2 = list(map(int, input().split(" ")))

bc = BingoCard([bingo0, bingo1, bingo2])


n = int(input())

while n:
    b = int(input())
    bc.call(b)
    n -= 1

if bc.check_bingo():
    print("Yes")
else:
    print("No")

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if A[x][y] == b:
                A[x][y] = -1

for x in range(3):
    f = True
    for y in range(3):
        if A[x][y] != -1:
            f = False
    if f:
        print("Yes")
        exit()

for x in range(3):
    f = True
    for y in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print("Yes")
        exit()

f = True
for x in range(3):
    if A[x][x] != -1:
        f = False

if f:
    print("Yes")
    exit()

f = True
for x in range(3):
    if A[2 - x][x] != -1:
        f = False

if f:
    print("Yes")
    exit()

print("No")

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

for i in range(n):
  o=int(input())
  for x in range(3):
    for y in range(3):
      if o == A[y][x]:
        A[y][x]=-1

for x in range(3):
  f=True
  for y in range(3):
    if A[y][x]!=-1:
      f=False
  if f:
    print('Yes')
    exit()

for y in range(3):
  f=True
  for x in range(3):
    if A[y][x]!=-1:
      f=False
  if f:
    print('Yes')
    exit()


f=True
for i in range(3):
  if A[i][i]!=-1:
    f=False
if f:
  print('Yes')
  exit()
f=True


for i in range(3):
  if A[i][2-i]!=-1:
    f=False
if f:
  print('Yes')
  exit()

print('No')

Solution (Python):
import sys
import math
from io import StringIO
import unittest

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

def resolve():
    table = [int(s) for s in input().split()]
    table += [int(s) for s in input().split()]
    table += [int(s) for s in input().split()]

    lis = [int(input()) for _ in range(int(input()))]

    ans = [ n in lis for n in table ]

    for line in lines:
        valid = True
        for num in line:
            if not ans[num] :
                valid = False
                break

        if valid:
            print('Yes')
            return

    print('No')
resolve()

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

for _ in range(N):
    b = int(input())
    for y in range(3):
        for x in range(3):
            if A[y][x] == b:
                A[y][x] = -1

for y in range(3):
    f = True
    for x in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

for x in range(3):
    f = True
    for y in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

f = True
for x in range(3):
    if A[x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

f = True
for x in range(3):
    if A[2 - x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')

Solution (Python):
sheet=[list(map(int,input().split())) for i in range(3)]
n=int(input())
number=[int(input()) for i in range(n)]
answer="No"

for i in range(3):
   for j in range(3):
      if sheet[i][j] in number:
        sheet[i][j]=0

if sheet[0][0]+sheet[1][1]+sheet[2][2]==0 or sheet[2][0]+sheet[1][1]+sheet[0][2]==0:
  answer="Yes"
else:        
  for i in range (3):
    if sheet[i]==[0,0,0]:
      answer="Yes"
    elif sheet[0][i]==0 and sheet[1][i]==0 and sheet[2][i]==0:
      answer="Yes"

print(answer)

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

n = int(input())

for i in range(n):
    b = int(input())
    if b in a_list:
        place = a_list.index(b)
        check_list[place] = True

bingo = False
while True:
    for i in range(3):
        if check_list[i*3] and check_list[i*3+1] and check_list[i*3+2]:
            bingo = True
            break
        if check_list[i] and check_list[i+3] and check_list[i+6]:
            bingo = True
            break
    if check_list[0] and check_list[4] and check_list[8]:
        bingo = True
        break
    if check_list[2] and check_list[4] and check_list[6]:
        bingo = True
        break
    break

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

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

 
check = [[0,0,0],[0,0,0],[0,0,0]]

 

N = int(input())

 
for i in range(N):
    data = int(input())
    for k in range(3):
        for j in range(3):
            if data == arr[j][k]:
                check[j][k]= 1

 

answer = "No"
for k in range(3):
    if check[k][0] == 1 and check[k][1]== 1 and check[k][2] == 1:
        answer = "Yes"
 
for j in range(3):
    if check[0][j] == 1 and check[1][j] == 1 and check[2][j] == 1:
        answer = "Yes"
 
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
    answer = "Yes"
 
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
    answer = "Yes"
 
 
print(answer)

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

buf = [[-1,-1,-1] 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 b==a[j][k]:
        buf[j][k]=1

bingo = buf
for i in range(3):
	bingo = bingo+[[buf[0][i],buf[1][i],buf[2][i]]]
bingo = bingo + [[buf[0][0],buf[1][1],buf[2][2]]] + [[buf[2][0],buf[1][1],buf[0][2]]]
flag = False
for i in range(8):
  if bingo[i]==[1,1,1]:
    flag = True
    print("Yes")
    break
if flag==False:
  print("No")

Solution (Python):
op = [list(map(int, inp.split())) for inp in open(0)]
a = [op[0], op[1], op[2]]
n = int(op[3][0])
b = []
for i in range(n):
  b.append(int(op[4 + i][0]))
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = -1
res = 'No'
for i in range(3):
  if a[0][i] == a[1][i] == a[2][i] == -1:
    res = 'Yes'
  if a[i][0] == a[i][1] == a[i][2] == -1:
    res = 'Yes'
if a[0][0] == a[1][1] == a[2][2] == -1:
  res = 'Yes'
if a[2][0] == a[1][1] == a[0][2] == -1:
  res = 'Yes'
print(res)

Solution (Python):
data_list = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
bingo_list = [int(input()) for _ in range(N)]
mark = [[False, False, False] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if data_list[i][j] in bingo_list:
            mark[i][j] = True
ans = "No"
for i in range(3):
    if all(mark[i]):
        ans = "Yes"
        break
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = "Yes"
        break
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[2][0] and mark[1][1] and mark[0][2]) :
    ans = "Yes"
print(ans)

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

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

ans = "No"

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

if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = "Yes"
if a[2][0] == a[1][1] == a[0][2] == 0:
    ans = "Yes"

print(ans)

Solution (Python):
row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
bingo=row1+row2+row3
num=int(input())
num_list=set()
for i in range(num):
  num_list.add(int(input()))

bingo_list=[[0,3,6],[1,4,7],[2,5,8],[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6]]
num_list=list(num_list)
for i in num_list:
  if i in bingo:
    bingo[bingo.index(i)] = True

for i in bingo_list:
  if bingo[i[0]] ==True and bingo[i[1]] == True and bingo[i[2]] == True:
    print('Yes')
    break
  if i == [2,4,6]:
    print('No')

Solution (Python):
import numpy as np

A = []
for _ in range(3):
    A.append(list(map(int, input().split())))
N = input()
N = int(N)
B = []
for _ in range(N):
    b = input()
    B.append(int(b))
npA = np.array(A)
check = 'No'
for a in npA:
    if a[0] in B and a[1] in B and a[2] in B:
        check = 'Yes'
for a in npA.T:
    if a[0] in B and a[1] in B and a[2] in B:
        check = 'Yes'
dia = np.diag(npA)
if dia[0] in B and dia[1] in B and dia[2] in B:
    check = 'Yes'
diaT = np.diag(np.fliplr(npA))
if diaT[0] in B and diaT[1] in B and diaT[2] in B:
    check = 'Yes'
print(check)

Solution (Python):

a = [None for i in range(9)]
b = [False for i in range(9)]

a[0], a[1], a[2] = input().split()
a[3], a[4], a[5] = input().split()
a[6], a[7], a[8] = input().split()

N = int(input())

for i in range(N):
    target = input()
    for j in range(9):
        if a[j] == target:
            b[j] = True

bl = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]

ret = "No"
for i in bl:
    for j in i:
        if b[j] is False:
            break
    else:
        ret = "Yes"

print(ret)

Solution (Python):

import copy

a1 = input().split()
a2 = input().split()
a3 = input().split()
n = int(input())
binhot = [0,0,0,0,0,0,0,0,0]
memo = [0,0,0,0,0,0,0,0,0]
ans = "No"

for i in range(n):
  b = str(input())
  count = 0
  for f in a1:
    if(b == f):
      binhot[count] = 1
    count += 1
  for f in a2:
    if(b == f):
      binhot[count] = 1
    count += 1
  for f in a3:
    if(b == f):
      binhot[count] = 1
    count += 1

saver = binhot
teacher = [[1,1,1,0,0,0,0,0,0],
           [0,0,0,1,1,1,0,0,0],
           [0,0,0,0,0,0,1,1,1],
           [1,0,0,1,0,0,1,0,0],
           [0,1,0,0,1,0,0,1,0],
           [0,0,1,0,0,1,0,0,1],
           [1,0,0,0,1,0,0,0,1],
           [0,0,1,0,1,0,1,0,0]]

for i in teacher:
  memo = copy.deepcopy(saver)
  for j in range(9):
    memo[j] = i[j] * memo[j]
  if(memo == i):
    ans = "Yes"

print("{}".format(ans))

Solution (Python):




def main():
    a = []
    b = []
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    n = int(input().strip())
    for i in range(n):
        b.append(int(input().strip()))

    n_to_k = {}
    for i in range(3):
        for j in range(3):
            n_to_k[a[i][j]] = (i, j)

    board = set()
    for i in b:
        if i not in n_to_k:
            continue
        board.add(n_to_k[i])

    
    for i in range(3):
        if (i, 0) in board and (i, 1) in board and (i, 2) in board:
            print("Yes")
            return
        if (0, i) in board and (1, i) in board and (2, i) in board:
            print("Yes")
            return
    if (0, 0) in board and (1, 1) in board and (2, 2) in board:
        print("Yes")
        return
    if (2, 0) in board and (1, 1) in board and (0, 2) in board:
        print("Yes")
        return

    print("No")

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
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()))

for i,a in enumerate(A):
  for j,x in enumerate(a):
    if x in B:
      A[i][j] = 0

def bingo(x):
  if sum(x) == 0:
    print('Yes')
    exit()

for x in A:
  bingo(x)

AT = [list(x) for x in zip(*A)]
for x in AT:
  bingo(x)

AD = [A[i][i] for i in range(3)]
bingo(AD)

AD = [A[i][2-i] for i in range(3)]
bingo(AD)

print('No')

Solution (Python):
import numpy as np
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()))

for i,a in enumerate(A):
  for j,x in enumerate(a):
    if x in B:
      A[i][j] = 0
ans = 'No'
def bingo(x):
  if sum(x) == 0:
    print('Yes')
    exit()

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

print(ans)

Solution (Python):
A = []
b = []
for i in range(3):
    A.extend(list(map(int, input().split())))
N = int(input())
for i in range(N):
    num = int(input())
    if num in A:
        idx = A.index(num)
        A[idx] = 0
        if A.count(0) >= 3:
            if (A[0] == A[3] and A[0] == A[6]
              or A[1] == A[4] and A[1] == A[7]
              or A[2] == A[5] and A[2] == A[8]
              or A[0] == A[1] and A[0] == A[2]
              or A[3] == A[4] and A[3] == A[5]
              or A[6] == A[7] and A[6] == A[8]
              or A[0] == A[4] and A[0] == A[8]
              or A[2] == A[4] and A[2] == A[6]):
                print("Yes")
                exit()
print("No")

Solution (Python):
import numpy as np
A = np.array([])
f=False
B= np.zeros((3,3))

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

n=int(input())

for i in range(n):
  x=int(input())
  B+=(A==x)*1
  
for i,j in zip(sum(B),sum(B.T)):
  f=f or (i//3) or (j//3) 
f = f or (sum(np.diag(B))//3)
f = f or (sum(np.diag(np.fliplr(B)))//3)
print("Yes" if f else "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):
    if set(A[i]) <= set(b):
        print("Yes")
        exit()
    if set([A[0][i], A[1][i], A[2][i]]) <= set(b):
        print("Yes")
        exit()
if set([A[0][0], A[1][1], A[2][2]]) <= set(b) or set([A[0][2], A[1][1], A[2][0]]) <= set(b):
    print("Yes")
    exit()
print("No")

Solution (Python):
A=[]
for _ in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
for _ in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if b==A[i][j]:
                A[i][j]=0
for k in range(3):
    ans=A[0][k]+A[1][k]+A[2][k]
    if ans==0:
        print("Yes");exit()
for k in range(3):
    ans=A[k][0]+A[k][1]+A[k][2]
    if ans==0:
        print("Yes");exit()
if A[0][0]+A[1][1]+A[2][2]==0:
    print("Yes")
elif A[0][2]+A[1][1]+A[2][0]==0:
    print("Yes")
else:
    print("No")

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

for i in range(N):
    bi = int(input())
    
    for j in range(3):
        if bi in A[j]:
            A[j][A[j].index(bi)] = 0
            
judge = False
for i in range(3):
    if A[i] == [0, 0, 0]:
        judge = True
    if A[0][i] == A[1][i] == A[2][i] == 0:
        judge = True
if A[0][0] == A[1][1] == A[2][2] == 0 or A[0][2] == A[1][1] == A[2][0] == 0:
    judge = True
    
if judge == True:
    print('Yes')
else:
    print('No')

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

for i in range(N):
    for j in range(3):
        for k in range(3):
            if a[i] == num[j][k]:
                num[j][k] = False
bingo = 0
for m in range(3):
    if num[0][m] == num[1][m] == num[2][m] == False:bingo = 1

for n in range(3):
    if num[n][0] ==  num[n][1] ==  num[n][2] == 0:bingo = 1 
if num[0][0] == num[1][1] == num[2][2] == 0 :bingo = 1
if num[0][2] == num[1][1] == num[2][0] == 0 :bingo = 1

if bingo == 1:print("Yes")
elif bingo == 0:print("No")

Solution (Python):
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
t = []
t.append(A);t.append(B);t.append(C)
N = int(input()) 
num = [(int(input())) for x in range(N)]
for i in range(3):
  if t[i][0] in num and t[i][1] in num and t[i][2] in num:
    print('Yes')
    exit()
  if t[0][i] in num and t[1][i] in num and t[2][i] in num:
    print('Yes')
    exit()
if (t[0][0] in num and t[1][1] in num and t[2][2] in num) or (t[0][2] in num and t[1][1] in num and t[2][0] in num):
  print('Yes')
  exit()
print('No')

Solution (Python):
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
numbers = list()
for i in range(N):
    numbers.append(int(input()))

bingo = False
for a in A:
    if a not in numbers:
        break
else:
    bingo = True

for b in B:
    if b not in numbers:
        break
else:
    bingo = True

for c in C:
    if c not in numbers:
        break
else:
    bingo = True

columnA = [A[0],B[0],C[0]]
for i in columnA:
    if i not in numbers:
        break
else:
    bingo = True

columnB = [A[1],B[1],C[1]]
for i in columnB:
    if i not in numbers:
        break
else:
    bingo = True

columnC = [A[2],B[2],C[2]]
for i in columnC:
    if i not in numbers:
        break
else:
    bingo = True

diagA = [A[0],B[1],C[2]]
for i in diagA:
    if i not in numbers:
        break
else:
    bingo = True

diagB = [A[2],B[1],C[0]]
for i in diagB:
    if i not in numbers:
        break
else:
    bingo = True

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