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):
line1 = input().split(" ")
line2 = input().split(" ")
line3 = input().split(" ")
N = int(input())


line1hit = [0,0,0]
line2hit = [0,0,0]
line3hit = [0,0,0]

for i in range(N):
    val = input()

    for index in range(len(line1)):
        if val == line1[index]:
            line1hit[index] =1

        if val == line2[index]:
            line2hit[index] =1

        if val == line3[index]:
            line3hit[index] =1

if line1hit[0] * line1hit[1] * line1hit[2] == 1:
    print('Yes')
elif  line2hit[0] * line2hit[1] * line2hit[2] ==1:
    print('Yes')
elif  line3hit[0] * line3hit[1] * line3hit[2] ==1:
    print('Yes')

elif line1hit[0] * line2hit[0] * line3hit[0] ==1:
    print('Yes')
elif  line1hit[1] * line2hit[1] * line3hit[1] ==1:
    print('Yes')
elif  line1hit[2] * line2hit[2] * line3hit[2] ==1:
    print('Yes')
elif  line1hit[0] * line2hit[1] * line3hit[2] ==1:
    print('Yes')
elif  line1hit[2] * line2hit[1] * line3hit[0] ==1:
    print('Yes')
else:
    print('No')

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

r = [(ai in b) for ai in a]

combs = [
    [0,1,2],
    [3,4,5],
    [6,7,8],
    [0,3,6],
    [1,4,7],
    [2,5,8],
    [0,4,8],
    [2,4,6],
]
if any([all([r[c] for c in comb]) for comb in combs]):
    print('Yes')
else:
    print('No')

Solution (Python):

import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())

for _ in range(n):
    num = int(input())
    if num in card:
        pos = tuple(nd[0] for nd in np.where(card == num))
        card[pos[0], pos[1]] = 0

f = 0

for i in range(3):
    if sum(card[i,:]) == 0 or sum(card[:,i]) == 0:
        f = 1
    if card[0,0]+card[1,1]+card[2,2] == 0 or card[2,0]+card[1,1]+card[2,0] == 0:
        f = 1

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

Solution (Python):

A1 = list(map(int,input().split(' ')))
A2 = list(map(int,input().split(' ')))
A3 = list(map(int,input().split(' ')))
N = int(input())
b = []
for k in range(N):
    b.append(int(input()))

checklist = [A1, A2, A3, [A1[0], A2[0], A3[0]], [A1[1], A2[1], A3[1]], [A1[2], A2[2], A3[2]],[A1[0], A2[1], A3[2]],[A1[2], A2[1], A3[0]]]


ans = "No"

for cl in checklist:
    if set(cl).issubset(b) == True:
        ans = "Yes"
        break

print(ans)

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [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 a[i][j] in b:mark[i][j] = True
ans = 'No'
for i in range(3):
    if mark[i][0] and mark[i][1] and mark[i][2]:
        ans = 'Yes'
        break

if ans != 'Yes':
    for j in range(3):
        if mark[0][j] and mark[1][j] and mark[2][j]:
            ans = 'Yes'
            break

if ans != 'Yes':
    if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

Solution (Python):
alist = [int(i) for i in input().split()]
blist = [int(i) for i in input().split()]
clist = [int(i) for i in input().split()]
n = int(input())
call_num = []
for i in range(n):
  call_num.append(int(input()))
lists = [alist,blist,clist]
dummy_list = [[0 for i in range(3)] for j in range(3)]
for i in call_num:
  for l,jlist in enumerate(lists):
    for m,k in enumerate(jlist):
      if k == i:
        dummy_list[l][m]=1
flag = 0
for i in range(3):
  if sum(dummy_list[i]) == 3:
    flag = 1
  if dummy_list[0][i]+dummy_list[1][i]+dummy_list[2][i]==3:
    flag = 1
if dummy_list[0][0]+dummy_list[1][1]+dummy_list[2][2] == 3:
  flag=1
if dummy_list[2][0]+dummy_list[1][1]+dummy_list[0][2] == 3:
  flag = 1
if flag==1:
  print('Yes')
else:
  print('No')

Solution (Python):

import sys
import collections

ue = list(map(int, input().split()))
ma = list(map(int, input().split()))
sita = list(map(int, input().split()))

n = int(input())

bingo = []

for s in range(n):
  bing = int(input())
  a = 0
  for i, j, k in zip(ue, ma, sita):
    if a == 3:
      continue
    if i == bing:
      ue[a] = '〇'
    if j == bing:
      ma[a] = '〇'
    if k == bing:
      sita[a] = '〇'
    a += 1

for i, j, k in zip(ue, ma, sita):
  if i == '〇' and j == '〇' and k == '〇':
    print('Yes')
    sys.exit()

x = collections.Counter(ue)
y = collections.Counter(ma)
z = collections.Counter(sita)

if x['〇'] == 3:
  print('Yes')
  sys.exit()
elif y['〇'] == 3:
  print('Yes')
  sys.exit()
elif z['〇'] == 3:
  print('Yes')
  sys.exit()

if ue[0] == '〇' and ma[1] == '〇' and sita[2] == '〇':
  print('Yes')
  sys.exit()
elif ue[2] == '〇' and ma[1] == '〇' and sita[0] == '〇':
  print('Yes')
  sys.exit()
print('No')

Solution (Python):
import sys
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
line2 = lines.pop(0).split(' ')
line3 = lines.pop(0).split(' ')
N = int(lines.pop(0))

for i in range(N):
  for j in range(3):
    if int(lines[i]) == int(line1[j]):
      line1[j] = -1
    elif int(lines[i]) == int(line2[j]):
      line2[j] = -1
    elif int(lines[i]) == int(line3[j]):
      line3[j] = -1

if (line1[0] == line1[1] == line1[2]) or (line2[0] == line2[1] == line2[2]) or (line3[0] == line3[1] == line3[2]) or (line1[0] == line2[0] == line3[0]) or (line1[1] == line2[1] == line3[1]) or (line1[2] == line2[2] == line3[2]) or (line1[0] == line2[1] == line3[2]) or (line1[2] == line2[1] == line3[0]):
  print('Yes')
else:
  print('No')

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

lis_bingo = (
    [X[0], X[1], X[2], 
    [X[0][0], X[1][0], X[2][0]], 
    [X[0][1], X[1][1], X[2][1]], 
    [X[0][2], X[1][2], X[2][2]], 
    [X[0][0], X[1][1], X[2][2]], 
    [X[0][2], X[1][1], X[2][0]]]
)

n = 0
while n <= 7:
    ans_bool = set(lis_bingo[n]) <= set(b)
    if ans_bool:
        break
    n += 1

if ans_bool:
    print('Yes')
else :
    print("No")

Solution (Python):
A = []
A += list(map(int, input().split(' ')))
A += list(map(int, input().split(' ')))
A += list(map(int, input().split(' ')))

N = int(input())

B = []
for _ in range(N):
    b = int(input())
    try:
        idx = A.index(b)
        B.append(idx)
    except ValueError:
        pass

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

is_bingo = 'No'
for indices in bingo_indices:
    if (indices[0] in B) and (indices[1] in B) and (indices[2] in B):
        is_bingo = 'Yes'
        break

print(is_bingo)

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(a1[0]==b):
    a1[0]=0
  if(a1[1]==b):
    a1[1]=0
  if(a1[2]==b):
    a1[2]=0
  if(a2[0]==b):
    a2[0]=0
  if(a2[1]==b):
    a2[1]=0
  if(a2[2]==b):
    a2[2]=0
  if(a3[0]==b):
    a3[0]=0
  if(a3[1]==b):
    a3[1]=0
  if(a3[2]==b):
    a3[2]=0                                   
l1=[a1[0],a2[0],a3[0]]
l2=[a1[1],a2[1],a3[1]]
l3=[a1[2],a2[2],a3[2]]
l4=[a1[0],a1[1],a1[2]]
l5=[a2[0],a2[1],a2[2]]
l6=[a3[0],a3[1],a3[2]]
l7=[a1[0],a2[1],a3[2]]
l8=[a1[2],a2[1],a3[0]]
if(sum(l1)==0 or sum(l2)==0 or sum(l3)==0 or sum(l4)==0 or sum(l5)==0 or sum(l6)==0 or sum(l7)==0 or sum(l8)==0):
  print("Yes")
else:
  print("No")

Solution (Python):
def rtnIdx(bg, num):
    for i in range(len(bg)):
        for j in range(len(bg[0])):
            if bg[i][j] == num:
                return i, j
    return -1, -1


def checkBingo(bg, lis):
    isBingo = [[False for i in range(3)] for j in range(3)]
    for num in lis:
        i, j = rtnIdx(bg, num)
        if i != -1:
            isBingo[i][j] = True

    flag = False

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

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

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

    return flag


bingo = []

for _ in range(3):
    array = list(map(int, input().split()))
    bingo.append(array)

n = int(input())
lis = []
for _ in range(n):
    lis.append(int(input()))

if checkBingo(bingo, lis):
    print("Yes")
else:
    print("No")

Solution (Python):
bingo = []
for _ in range(3):
    row = input().split()
    for i in row:
        bingo.append(int(i))
        
N = int(input())

for i in range(N):
    num = int(input())
    bingo = [0 if b == num else b for b in bingo]

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

Solution (Python):
import numpy as np


def resolve():
    a_list = list(map(int,input().split()))
    b_list = list(map(int,input().split()))
    c_list = list(map(int,input().split()))
    arr = np.array([a_list, b_list, c_list])

    n = int(input())
    for _ in range(n):
        num = int(input())
        arr = np.where(arr == num, 0, arr)

    if True in np.all(arr == 0, axis=0):
        print('Yes')
        return

    elif True in np.all(arr == 0, axis=1):
        print('Yes')
        return

    elif arr[0, 0] == 0 and arr[1, 1] == 0 and arr[2, 2] == 0:
        print('Yes')
        return

    elif arr[2, 0] == 0 and arr[1, 1] == 0 and arr[0, 2] == 0:
        print('Yes')
        return

    else:
        print('No')
        return
      
resolve()

Solution (Python):
x = [0] * 3
y = [0] * 3
z = [0] * 3
x[0], y[0], z[0] = map(int, input().split())
x[1], y[1], z[1] = map(int, input().split())
x[2], y[2], z[2] = map(int, input().split())
N=int(input())

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

for i in range(N):
    for j in range(3):
        if x[j]==b[i]:
            x[j]=0
        if y[j]==b[i]:
            y[j]=0
        if z[j]==b[i]:
            z[j]=0

ans=0

for i in range(3):
    if x[i]==0 and y[i]==0 and z[i]==0:
        ans=1
        break

if x[0]==0 and x[1]==0 and x[2]==0:
    ans=1
if y[0]==0 and y[1]==0 and y[2]==0:
    ans=1
if z[0]==0 and z[1]==0 and z[2]==0:
    ans=1
if x[0]==0 and y[1]==0 and z[2]==0:
    ans=1
if z[0]==0 and y[1]==0 and x[2]==0:
    ans=1

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

Solution (Python):
import sys

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

n = input()
n = int(n)

for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = 0
        
      if j == 2 and (a[0][k] == 0 and a[1][k] == 0 and a[2][k] == 0):
        print("Yes")
        sys.exit()
      
    if a[j][0] == 0 and a[j][1] == 0 and a[j][2] == 0:
      print("Yes")
      sys.exit()
    
  if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    print("Yes")
    sys.exit()
    
  if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    print("Yes")
    sys.exit()
  
print("No")

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



C = []

for i in range(3):
    _c = []
    for j in range(3):
        _c.append(A[i][j] in b)
    C.append(_c)



flag = False

for i in range(3):
    if all(C[i]):
        flag = True

for i in range(3):
    _c = []
    for j in range(3):
        _c.append(C[j][i])
    if all(_c):
        flag = True

if C[0][0] and C[1][1] and C[2][2]:
    flag = True

if C[0][2] and C[1][1] and C[2][0]:
    flag = True

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

Solution (Python):
b1=list(map(int,input().split()))
b2=list(map(int,input().split()))
b3=list(map(int,input().split()))
n=int(input())

for i in range(n):
    bb=int(input())
    for j in range(3):
        if bb==b1[j]:
            b1[j]=0
        elif bb==b2[j]:
            b2[j]=0
        elif bb==b3[j]:
            b3[j]=0
if sum(b1)==0 or sum(b2)==0 or sum(b3)==0:
    print("Yes")
elif b1[0]==b2[0]==b3[0]==0:
    print("Yes")
elif b1[1]==b2[1]==b3[1]==0:
    print("Yes")
elif b1[2]==b2[2]==b3[2]==0:
    print("Yes")
elif b1[0]==b2[1]==b3[2]==0:
    print("Yes")
elif b1[2]==b2[1]==b3[0]==0:
    print("Yes")
else:
    print("No")

Solution (Python):
a = []

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

n = int(input())

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



ans = min(sum(a[0]), sum(a[1]), sum(a[2]),(a[0][0] + a[1][1] + a[2][2]), (a[0][2] + a[1][1] + a[2][0]),(a[0][0] + a[1][0] + a[2][0]),(a[0][1] + a[1][1] + a[2][1]),(a[0][2] + a[1][2] + a[2][2]))

print(["No","Yes"][ans == 0])

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
maru = []
for i in range(N):
  tmp = int(input())
  
  for y, row in enumerate(A):
    try:
      A[y][row.index(tmp)] = 0
      print([y, row.index(tmp)], "a")
      maru.append([y, row.index(tmp)])
      break
    except ValueError:
      pass

f = False
for i in range(3):
  if A[i][0] == 0 and A[i][0] == A[i][1] and A[i][1] == A[i][2]:
    f = True
for i in range(3):
  if A[0][i] == 0 and A[0][i] == A[1][i] and A[1][i] == A[2][i]:
    f = True
if A[0][0] == 0 and A[0][0] == A[1][1] and A[1][1] == A[2][2]:
  f = True
if A[0][2] == 0 and A[0][2] == A[1][1] and A[1][1] == A[2][0]:
  f = True
if f:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)

for i in range(3):
    a,b,c = map(int,input().split())
    dic[a] = i*3+1
    dic[b] = i*3+2
    dic[c] = i*3+3
ansl = []
n = int(input())
for _ in range(n):
    k = int(input())
    if dic[k] and dic[k] not in ansl:
        ansl.append(dic[k])
if 1 in ansl and 2 in ansl and 3 in ansl:
    print("Yes")
    exit()
if 4 in ansl and 5 in ansl and 6 in ansl:
    print("Yes")
    exit()
if 7 in ansl and 8 in ansl and 9 in ansl:
    print("Yes")
    exit()
if 1 in ansl and 4 in ansl and 7 in ansl:
    print("Yes")
    exit()
if 2 in ansl and 5 in ansl and 8 in ansl:
    print("Yes")
    exit()
if 3 in ansl and 6 in ansl and 9 in ansl:
    print("Yes")
    exit()
if 1 in ansl and 5 in ansl and 9 in ansl:
    print("Yes")
    exit()
if 3 in ansl and 5 in ansl and 7 in ansl:
    print("Yes")
    exit()
print("No")

Solution (Python):
import numpy as np
a = []
a.append([int(x) for x in input().split()])
a.append([int(x) for x in input().split()])
a.append([int(x) for x in input().split()])
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))

ans = 'No'
for i in range(3):
  if set(np.array(a)[:, i]) <= set(b) or set(np.array(a)[i, :]) <= set(b):
    ans = 'Yes'

if set([a[0][0], a[1][1], a[2][2]]) <= set(b) or set([a[2][0], a[1][1], a[0][2]]) <= set(b):
  ans = 'Yes'
print(ans)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    for i in range(N):
        searchAndPut(A,b[i])

    
    if A[0][0] == A[0][1] == A[0][2] == -1:
            print(YES)
    elif A[1][0] == A[1][1] == A[1][2] == -1:
            print(YES)
    elif A[2][0] == A[2][1] == A[2][2] == -1:
            print(YES)
    
    elif A[0][0] == A[1][0] == A[2][0] == -1:
            print(YES)
    elif A[0][1] == A[1][1] == A[2][1] == -1:
            print(YES)
    elif A[0][2] == A[1][2] == A[2][2] == -1:
            print(YES)
    
    elif A[0][0] == A[1][1] == A[2][2] == -1:
            print(YES)
    elif A[0][2] == A[1][1] == A[2][0] == -1:
            print(YES)
    else:
        print(NO)

def searchAndPut(A: "List[List[int]]",b):
    for i in range(3):
        list = A[i]
        if (b in list):
            list[list.index(b)] = -1
            break

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):
A = []
for i in range(3):
    A += [[int(i) for i in input().split()]]

N = int(input())

b=[]
ans = [[False]*3,[False]*3, [False]*3]
for i in range(N):
    b += [int(input())]



for i in range(N):
    num = b[i]
    for j in range(3):
        for k in range(3):
            if A[j][k]==num:
                ans[j][k] = True;
                


answer = ans[0][0] and ans[1][1] and ans[2][2]
answer = answer or (ans[0][2] and ans[1][1] and ans[2][0])

for i in range(3):
    answer = answer or (ans[i][0] and ans[i][1] and ans[i][2])
    answer = answer or (ans[0][i] and ans[1][i] and ans[2][i])

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

Solution (Python):
import numpy as np

A = np.array([[int(val) for val in input().split(" ")] for i in range(3)])
N = int(input())
b = np.array([int(input()) for i in range(N)])

A_ = np.zeros_like(A)
for bi in b:
    row, col = np.where(A == bi)
    if row.size and col.size:
        A_[row[0]][col[0]] = 1

ans1 = sum(np.sum(A_, axis=0) == 3)
ans2 = sum(np.sum(A_, axis=1) == 3)
ans3 = (sum([A_[i,i] for i in range(3)]) == 3).astype(int)
ans4 = (sum([A_[i,2-i] for i in range(3)]) == 3).astype(int)
if ans1 or ans2 or ans3 or ans4:
    print("Yes")
else:
    print("No")

Solution (Python):
b = []
b.append([int(s) for s in input().split()])
b.append([int(s) for s in input().split()])
b.append([int(s) for s in input().split()])

n = int(input())

for i in range(0, n):
    v = int(input())

    for i in range(0, 3):
        for j in range(0, 3):
            if b[i][j] == v:
                b[i][j] = 999

ans = 'No'

for i in range(0, 3):
    s = set(b[i])

    if len(s) == 1:
        ans = 'Yes'

for i in range(0, 3):
    s = set([b[0][i], b[1][i], b[2][i]])

    if len(s) == 1:
        ans = 'Yes'

c = set([b[0][0], b[1][1], b[2][2]])

if len(c) == 1:
    ans = 'Yes'

c = set([b[0][2], b[1][1], b[2][0]])

if len(c) == 1:
    ans = 'Yes'

print(ans)

Solution (Python):
bingo = []

for _ in range(3):
	bingo.extend(list(map(int, input().split(' '))))



n = int(input())

nums = []
for _ in range(n):
  nums.append(int(input()))
  

flag = [False for _ in range(9)]
for n in nums:
  for i in range(9):
    if bingo[i] == n:
      flag[i] = True
      


result = False
for i in [0, 3, 6]:
  if (flag[i] and flag[i+1] and flag[i+2]):
    result = True
    
for i in [0, 1, 2]:
  if (flag[i] and flag[i+3] and flag[i+6]):
    result = True
    
if (flag[0] and flag[4] and flag[8]):
    result = True
    
if (flag[2] and flag[4] and flag[6]):
    result = True
    
if result:
  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)]

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


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

x = [0, 1, 2, 0, 0, 0, 0, 2]
y = [0, 0, 0, 0, 1, 2, 0, 0]
dx = [0, 0, 0, 1, 1, 1, 1, -1]
dy = [1, 1, 1, 0, 0, 0, 1, 1]

flag = True
ans = False

for i in range(8) :
    xx = x[i]
    yy = y[i]
    flag = True
    for j in range(3) :
        
        if emp[xx][yy] != 1 :
            flag = False
            break
        xx += dx[i]
        yy += dy[i]
    if flag == True :
        ans = True
if ans :
    print('Yes')
else :
    print('No')

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)






A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
A = ["x"]*9

N = int(input())
b = []
ans = "No"

for i in range(N):
  b.append(int(input()))
  for j in range(3):
    if(b[i]==A1[j]):
      A[j]="o"
    elif(b[i]==A2[j]):
      A[j+3]="o"
    elif(b[i]==A3[j]):
      A[j+6]="o"

for i in range(3):
  if(A[i*3]=="o" and A[i*3+1]=="o" and A[i*3+2]=="o"):
    ans = "Yes"
  if(A[i]=="o" and A[i+3]=="o" and A[i+6]=="o"):
    ans = "Yes"

if(A[0]=="o" and A[4]=="o" and A[8]=="o"):
  ans = "Yes"
if(A[2]=="o" and A[4]=="o" and A[6]=="o"):
  ans = "Yes"



print(ans)

Solution (Python):
A = list()
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
B = [int(input()) for _ in range(N)]
checkList = [[False, False, False], [False, False, False], [False, False, False]]
for b in B:
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                checkList[i][j] = True
checkListT = [list(x) for x in zip(*checkList)]

ans = "No"
if all(checkList[0]):
   ans = "Yes"
if all(checkList[1]):
   ans = "Yes"
if all(checkList[2]):
   ans = "Yes"

if all(checkListT[0]):
   ans = "Yes"
if all(checkListT[1]):
   ans = "Yes"
if all(checkListT[2]):
   ans = "Yes"

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

print(ans)

Solution (Python):
import sys
bingo = [list(map(int, input().split())) for _ in range(3)]
input_num = int(input())
input_list = [int(input()) for _ in range(input_num)]
flag = False

for l in bingo:
	match_count = 0
	if [x for x in l if x in input_list]:
		match_count = len([x for x in l if x in input_list])
		if match_count == 3:
			print('Yes')
			sys.exit()


match_count = 0
for l in list(zip(*bingo)):
	match_count = 0
	if [x for x in l if x in input_list]:
		match_count = len([x for x in l if x in input_list])
		if match_count == 3:
			print('Yes')
			sys.exit()

match_count = 0
for n, l in zip([0,1,2], bingo):
	if l[n] in input_list:
		match_count += 1
	if match_count == 3:
		print('Yes')
		sys.exit()

match_count = 0
for n, l in zip([-1,-2,-3], bingo):
	if l[n] in input_list:
		match_count += 1
	if match_count == 3:
		print('Yes')
		sys.exit()

print('No')

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

a = a1 + a2 + a3

n = int(input())

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

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

            
if a[0] == a[1] == a[2] == 0:
    print("Yes")
elif a[3] == a[4] == a[5] == 0:
    print("Yes")
elif a[6] == a[7] == a[8] == 0:
    print("Yes")
elif a[0] == a[3] == a[6] == 0:
    print("Yes")
elif a[1] == a[4] == a[7] == 0:
    print("Yes")
elif a[2] == a[8] == a[5] == 0:
    print("Yes")
elif a[0] == a[4] == a[8] == 0:
    print("Yes")
elif a[2] == a[4] == a[6] == 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())
N=int(input())
i=0
B=[]
while i<N:
  B.append(int(input()))
  i+=1
ans=0
c11=c12=c13=c21=c22=c23=c31=c32=c33=0
  
for k in B:
  if k==a11:
    c11+=1
  elif k==a12:
    c12+=1
  elif k==a13:
    c13+=1
  elif k==a21:
    c21+=1
  elif k==a22:
    c22+=1
  elif k==a23:
    c23+=1
  elif k==a31:
    c31+=1
  elif k==a32:
    c32+=1
  elif k==a33:
    c33+=1
  
if c11>0 and c12>0 and c13>0:
  ans+=1
elif c21>0 and c22>0 and c23>0:
  ans+=1
elif c31>0 and c32>0 and c33>0:
  ans+=1
elif c11>0 and c21>0 and c31>0:
  ans+=1
elif c12>0 and c22>0 and c32>0:
  ans+=1
elif c13>0 and c23>0 and c33>0:
  ans+=1
elif c11>0 and c22>0 and c33>0:
  ans+=1
elif c31>0 and c22>0 and c13>0:
  ans+=1


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

Solution (Python):
card = []
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
N = int(input())
for i in range(N):
    b = int(input())
    try:
        card[card.index(b)] = -1
    except:
        continue
if card[0] == card[1] == card[2] or card[3] == card[4] == card[5] or card[6] == card[7] == card[8] or card[0] == card[3] == card[6] or card[1] == card[4] == card[7] or card[2] == card[5] == card[8] or card[0] == card[4] == card[8] or card[2] == card[4] == card[6]:
    print("Yes")
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(0,N):
    d=int(input())
    b.append(d)
c1=[False,False,False]
c2=[False,False,False]
c3=[False,False,False]

for j in range(0,N):
    for k in range(0,3):
        if A1[k]==b[j]:
            c1[k]=True
        if A2[k]==b[j]:
            c2[k]=True
        if A3[k]==b[j]:
            c3[k]=True
if c1[0]==True and c1[1]==True and c1[2]==True:
    print("Yes")
elif c2[0]==True and c2[1]==True and c2[2]==True:
    print("Yes")
elif c3[0]==True and c3[1]==True and c3[2]==True:
    print("Yes")
elif c1[0]==True and c2[0]==True and c3[0]==True:
    print("Yes")
elif c1[1]==True and c2[1]==True and c3[1]==True:
    print("Yes")
elif c1[2]==True and c2[2]==True and c3[2]==True:
    print("Yes")
elif c1[0]==True and c2[1]==True and c3[2]==True:
    print("Yes")
elif c3[0]==True and c2[1]==True and c1[2]==True:
    print("Yes")
else:
    print("No")

Solution (Python):
def bingo(a):
    for i in range(3):
        if sum([a[j][i] for j in range(3)]) == 0:
            return 'Yes'
        if sum(a[i]) == 0:
            return 'Yes'
    if a[0][0] + a[1][1] + a[2][2] == 0:
        return 'Yes'
    if a[2][0] + a[1][1] + a[0][2] == 0:
        return 'Yes'
    return 'No'

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

for num in b:
    for i, ai in enumerate(a):
        for j, aij in enumerate(ai):
            if aij == num:
                a[i][j] = 0
print(bingo(a))

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

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

if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
  print("Yes")
  exit()
if a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
  print("Yes")
  exit()
if a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0:
  print("Yes")
  exit()
if a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
  print("Yes")
  exit()
if a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
  print("Yes")
  exit()
if a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 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):
listA = []
import itertools
listB = [0] * 9
for i in range(3):
    listA.append(input().split())
listA = list(itertools.chain.from_iterable(listA))
N = int(input())
for i in range(N):
    B = input()
    if B in listA:
        listB[listA.index(B)] = 1
for i in range(3):
    if listB[i*3] == 1 and listB[i*3+1] == 1 and listB[i*3+2] == 1:
        print("Yes")
        exit()
for i in range(3):
    if listB[i] == 1 and listB[i+3] == 1 and listB[i+6] == 1:
        print("Yes")
        exit()
if listB[0] == 1 and listB[4] == 1 and listB[8] == 1:
    print("Yes")
    exit()
if listB[2] == 1 and listB[4] == 1 and listB[6] == 1:
    print("Yes")
    exit()
print("No")

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

N = int(input())

grid = [[0] * 3] + [[0] * 3] + [[0] * 3]

for i in range(N):
    b = int(input())

    for j in range(3):
        for k in range(3):
            if b == A[j][k]:
                grid[j][k] = 1

ans = "No"

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


for k in range(3):
    tmp = 0
    for j in range(3):
        tmp += grid[j][k]
    if tmp == 3:
        ans = "Yes"

tmp = 0
for i in range(3):
    tmp += grid[i][i]
if tmp == 3:
    ans = "Yes"

tmp = 0
for i in range(3):
    tmp += grid[i][2-i]
if tmp == 3:
    ans = "Yes"


print(ans)

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nms = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
a=[list(map(int, input().split())) for i in range(3)]
n=int(input())
b=[]
for i in range(n):
    bb=int(input())
    b.append(bb)

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

for bb in b:
    for i in range(3):
        for j in range(3):
            if bb==a[i][j]:
                mat[i][j]=1
a1=mat[0][0]+mat[1][0]+mat[2][0]
a2=mat[0][1]+mat[1][1]+mat[2][1]
a3=mat[0][2]+mat[1][2]+mat[2][2]



a4=mat[0][0]+mat[1][1]+mat[2][2]
a5=mat[0][2]+mat[1][1]+mat[2][0]
if a1==3 or a2==3 or a3==3 or a4==3 or a5==3:
    print('Yes')
    exit()




for mm in mat:
    if sum(mm)==3:
        print('Yes')
        exit()
print('No')

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

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

for i in range(3):
    flg = True
    for j in range(3):
        flg &= l[i][j] == -1
    if flg:
        print('Yes')
        exit()

for i in range(3):
    flg = True
    for j in range(3):
        flg &= l[j][i] == -1
    if flg:
        print('Yes')
        exit()

flg = True
for i in range(3):
    flg &= l[i][i] == l[0][0]
if flg:
    print('Yes')
    exit()

flg = True
for i in range(3):
    flg &= l[i][2 - i] == l[0][2]
if flg:
    print('Yes')
    exit()

print('No')