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


def check_bingo(A):
    for i in range(3):
        if np.all(A[i] == -1) or np.all(A[:, i] == -1):
            return 'Yes'
    if np.all(A[list(range(3)), list(range(3))] == -1) \
            or np.all(A[list(range(3)), list(range(3))[::-1]] == -1):
        return 'Yes'

    return 'No'


def main():
    A = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    for i in range(n):
        b = int(input())
        A = np.where(A == b, -1, A)
    ans = check_bingo(A)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def is_bingo(ary):
    flag = False
    for i in range(3):
        if ary[i][0] == "hit" and ary[i][1] == 'hit' and ary[i][2] == 'hit':
            flag = True
            break
        if ary[0][i] == "hit" and ary[1][i] == 'hit' and ary[2][i] == 'hit':
            flag = True
            break
    if ary[0][0] == "hit" and ary[1][1] == 'hit' and ary[2][2] == 'hit':
        flag = True
    if ary[0][2] == "hit" and ary[1][1] == 'hit' and ary[2][0] == 'hit':
        flag = True
    return flag

answer_seets = [[0,0,0] for _ in range(3)]
for i in range(3):
    tmp_lis = list(input().split())
    for idx, tmp in enumerate(tmp_lis):
        answer_seets[i][idx] = tmp
N = int(input())
for _ in range(N):
    b = input()
    for i in range(3):
        for j in range(3):
            if answer_seets[i][j] == b:
                answer_seets[i][j] = "hit"
                break
        else:
            continue
        break

if is_bingo(answer_seets):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
card = [ list(map(int,input().split())) for a in range(3) ]
N = int(input())
point = [ int(input()) for a in range(N) ]


for I in point:
    for J in card:
        if I in J:
            J.index(I)
            J[J.index(I)] = "H"

for K in range(3):
    check = set([ x[K] for x in card ])
    if len(check) == 1 and list(check)[0] == "H":
        print('Yes')
        sys.exit()

for L in card:
    check = set(L)
    if len(check) == 1 and list(check)[0] == "H":
        print('Yes')
        sys.exit()

LtoR = set([ card[M][M] for M in range(3)])
RtoL = set([ card[M][-M-1] for M in range(3)])
if len(LtoR) == 1 and list(LtoR)[0] == "H" or  len(RtoL) == 1 and list(RtoL)[0] == "H":    
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
import sys
from itertools import product


def main():
    input = sys.stdin.buffer.readline
    card = [[0] * 3 for _ in range(3)]
    for i in range(3):
        line = list(map(int, input().split()))
        card[i] = line
    mark = [[0] * 3 for _ in range(3)]
    n = int(input())
    for _ in range(n):
        b = int(input())
        for i, j in product(range(3), repeat=2):
            if card[i][j] == b:
                mark[i][j] = 1
                break

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

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

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

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

    print("No")


if __name__ == "__main__":
    main()

Solution (Python):
A = []
for _ in range(3):
    a = [int(a) for a in input().split()]
    A.append(a)
N = int(input())
for _ in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==num:
                A[i][j] = -1


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

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


bingo_naname = True
for i in range(3):
    col, row = i, i
    if A[row][col] != -1:
        bingo_naname = False
if bingo_naname:
    print('Yes')
    exit()
bingo_naname = True
for i in range(3):
    col, row = 2-i, i
    if A[row][col] != -1:
        bingo_naname = False
if bingo_naname:
    print('Yes')
    exit()

print('No')

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

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

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

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

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

    print('No')


if __name__ == "__main__":
    main()

Solution (Python):
A = []
for _ in range(3):
	A += list(map(int, input().split()))
for _ in range(int(input())):
  b = int(input())
  if b in A:
    A[A.index(b)] = False

res = "No"


if not(any([A[0], A[1], A[2]])) or not(any([A[3], A[4], A[5]])) or not(any([A[6], A[7], A[8]])):
  res = "Yes"


if not(any([A[0], A[3], A[6]])) or not(any([A[1], A[4], A[7]])) or not(any([A[2], A[5], A[8]])):
  res = "Yes"


if not(any([A[0], A[4], A[8]])) or not(any([A[2], A[4], A[6]])):
  res = "Yes"
print(res)

Solution (Python):
import numpy as np
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = []
for j in range(N):
    b = int(input())
    B.append(b)
A = np.array(A)
B = np.array(B)
boolean_matrix = np.isin(A, B)
if boolean_matrix.sum(axis=1).max() >= 3 or \
   boolean_matrix.sum(axis=0).max() >= 3 or \
   np.diag(boolean_matrix).sum() >= 3 or \
   np.diag(np.fliplr(boolean_matrix)).sum() >= 3:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict
dic = defaultdict(list)
for i in range(3):
    a = list(map(int,input().split()))
    for j in range(3):
        dic[a[j]].append([i,j])
n = int(input())
B = []
for _ in range(n):
    b = int(input())
    B.append(b)
h = [0]*3
w = [0]*3
d = 0
di = 0
for b in B:
    if b not in dic:
        continue
    x,y = dic[b][0]
    if x== y:
        d += 1
    if x + y ==2:
        di += 1
    h[x] += 1
    w[y] += 1
for i in range(3):
    if h[i]==3 or w[i]==3:
        print('Yes');exit()
if d ==3 or di ==3:
    print('Yes');exit()
print('No')

Solution (Python):
import numpy as np

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

for i in bs:
    bingo = np.where(bingo == i, 101, bingo)

h = False
if bingo[0][0] == bingo[1][1] == bingo[2][2] or bingo[0][2] == bingo[1][1] == bingo[2][0]:
    h = True
if h == False:
    for i in range(3):
        if bingo[i][0] == bingo[i][1] == bingo[i][2]:
            h = True
            break
    for j in range(3):
        if bingo[0][j] == bingo[1][j] == bingo[2][j]:
            h = True
            break

print('Yes') if h == True else print('No')

Solution (Python):
list = [list(map(int,input().split())) for i in range(3)]
N = int(input())
A = [[0] * 3 for i in range(3)]
for i in range(N):
  B = int(input())
  for j in range(3):
    for k in range(3):
      if list[j][k] == B:
        A[j][k] += 1
        
result = A[0][0] * A[0][1] * A[0][2]
result += A[1][0] * A[1][1] * A[1][2]
result += A[2][0] * A[2][1] * A[2][2]
result += A[0][0] * A[1][0] * A[2][0]
result += A[0][1] * A[1][1] * A[2][1]
result += A[0][2] * A[1][2] * A[2][2]
result += A[0][0] * A[1][1] * A[2][2]
result += A[0][2] * A[1][1] * A[2][0]
if result >= 1:
  print('Yes')
else:
  print('No')

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

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

for i in range(3):
    for j in range(3):
        for k in b:
            if bingo[i][j]==k:
                bingo[i][j]=-1

flg=False
for i in range(3):
    if bingo[i][0]==-1 and bingo[i][1]==-1 and bingo[i][2]==-1:
        flg=True
        break
    if bingo[0][i]==-1 and bingo[1][i]==-1 and bingo[2][i]==-1:
        flg=True
        break

if bingo[0][0]==-1 and bingo[1][1]==-1 and bingo[2][2]==-1:
    flg=True
elif bingo[0][2]==-1 and bingo[1][1]==-1 and bingo[2][0]==-1:
    flg=True

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

Solution (Python):
List = []
for i in range (3):
  List.append(list(map(int, input().split())))
Row = int(input())
Ball = []
for i in range (Row):
  Ball.append(int(input()))
for x in range(Row):
  for i in range(3):
    for j in range(3):
      if Ball[x] == List[i][j]:
        List[i][j] = 0
if List[0][0] == 0 and List[0][1] == 0 and List[0][2] == 0:
  print("Yes")
elif List[1][0] == 0 and List[1][1] == 0 and List[1][2] == 0:
  print("Yes")
elif List[2][0] == 0 and List[2][1] == 0 and List[2][2] == 0:
  print("Yes")
elif List[0][0] == 0 and List[1][0] == 0 and List[2][0] == 0:
  print("Yes")
elif List[0][1] == 0 and List[1][1] == 0 and List[2][1] == 0:
  print("Yes")
elif List[0][2] == 0 and List[1][2] == 0 and List[2][2] == 0:
  print("Yes")
elif List[0][0] == 0 and List[1][1] == 0 and List[2][2] == 0:
  print("Yes")
elif List[0][2] == 0 and List[1][1] == 0 and List[2][0] == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
def bingo_judge(li,a,b,c,d,e,f,flag):
    if li[a-1][b-1] + li[c-1][d-1] + li[e-1][f-1] == 3:
        return True
    if flag:
        return True
    else:
        return False

card = []
card_judge = []
for i in range(3):
    li = list(map(int, input().split()))
    card.append(li)
    card_judge.append([0,0,0])
N = int(input())
for i in range(N):
    number = int(input())
    for t in range(3):
        for u in range(3):
            if number == card[t][u]:
                card_judge[t][u] = 1
flag = False
flag = bingo_judge(card_judge,1,1,2,1,3,1,flag)
flag = bingo_judge(card_judge,1,2,2,2,3,2,flag)
flag = bingo_judge(card_judge,1,3,2,3,3,3,flag)
flag = bingo_judge(card_judge,1,1,1,2,1,3,flag)
flag = bingo_judge(card_judge,2,1,2,2,2,3,flag)
flag = bingo_judge(card_judge,3,1,3,2,3,3,flag)
flag = bingo_judge(card_judge,1,1,2,2,3,3,flag)
flag = bingo_judge(card_judge,1,3,2,2,3,1,flag)
if flag:
    print('Yes')
else:
    print('No')

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

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

n = int(input())

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


for i in range(8):
    flag = 0
    for j in range(3):
        if d[i][j] in c:
            flag +=1
            if flag ==3:
                print("Yes")
                sys.exit()

else:
    print("No")

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


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




for i in range(9):
    if 0 <= i <= 2:
        a1.append(A[i])
    elif 3 <= i <= 5:
        a2.append(A[i])
    else:
        a3.append(A[i])

x = 0
y = 0
z = 0
for i in range(3):
    if a1[i] == 0:
        x += 1
    if a2[i] == 0:
        y += 1
    if a3[i] == 0:
        z += 1

if x == 3 or y == 3 or z == 3:
    print('Yes')
    exit()

for i in range(3):
    if a1[i] == 0 and a2[i] == 0 and a3[i] == 0:
        print('Yes')
        exit()

if a2[1] == 0:
    if a1[0] == 0 and a3[2] == 0 or a1[2] == 0 and a3[0] == 0:
        print('Yes')
        exit()

print('No')

Solution (Python):
card = []
check = [[0, 0, 0] for i in range(3)]
for i in range(3):
    card.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 b == card[j][k]:
                check[j][k] = 1

flag = 0

for i in range(3):
    if check[i][0] == check[i][1] == check[i][2] == 1:
        flag = 1
        break
    elif check[0][i] == check[1][i] == check[2][i] == 1:
        flag = 1
        break
    elif check[0][0] == check[1][1] == check[2][2] == 1:
        flag = 1
        break
    elif check[0][2] == check[1][1] == check[2][0] == 1:
        flag = 1
        break

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

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

n=int(input())

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

for bingo in b:
    for gyou in range(3):
        for retu in range(3):
            if a[gyou][retu]==bingo:
                a[gyou][retu]=True

if a[0][0]==True and a[0][1]==True and a[0][2]==True:
    print("Yes")
    exit()
elif a[1][0]==True and a[1][1]==True and a[1][2]==True:
    print("Yes")
    exit()
elif a[2][0]==True and a[2][1]==True and a[2][2]==True:
    print("Yes")
    exit()
elif a[0][0]==True and a[1][0]==True and a[2][0]==True:
    print("Yes")
    exit()
elif a[0][1]==True and a[1][1]==True and a[2][1]==True:
    print("Yes")
    exit()
elif a[0][2]==True and a[1][2]==True and a[2][2]==True:
    print("Yes")
    exit()
elif a[0][0]==True and a[1][1]==True and a[2][2]==True:
    print("Yes")
    exit()
elif a[0][2]==True and a[1][1]==True and a[2][0]==True:
    print("Yes")
    exit()

print("No")

Solution (Python):
A=[list(map(int,input().split())) for _ in range(3)]
b=[i for i in [int(input()) for _ in range(int(input()))] for j in A if i in j]
A=[[1 if A[i][j] in b else 0 for j in range(len(A[i]))] for i in range(len(A))]
print('NYoe s'[any([all(i) for i in A]) or any([all(i) for i in list(zip(*A))]) or all([A[0][0],A[1][1],A[2][2]]) or all([A[0][2],A[1][1],A[2][0]])::2])

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

N = int(input())
B = set()
for _ in range(N):
    B.add(int(input()))

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

Q = [-1,-1,-1]
for i in range(3):
    if A[i] == Q:
        print("Yes")
        exit()
A = list(zip(*A))
Q = (-1,-1,-1)
for i in range(3):
    if A[i] == Q:
        print("Yes")
        exit()

if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    print("Yes")
    exit()

print("No")

Solution (Python):
A=[list(map(int,input().split())) for _ in range(3)]
b=[i for i in [int(input()) for _ in range(int(input()))] for j in A if i in j]
A=[[0 if A[i][j] in b else A[i][j] for j in range(len(A[i]))] for i in range(len(A))]
print('NYoe s'[any([1 if sum(i)==0 else 0 for i in A]) or any([1 if sum(i)==0 else 0 for i in list(zip(*A))]) or not A[0][0]+A[1][1]+A[2][2] or not A[0][2]+A[1][1]+A[2][0]::2])

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    bingo_num = []

    for i in range(3):
        N = LI()
        bingo_num.append(N)

    N = II()

    for i in range(N):
        b = II()
        for row_i in range(3):
            for col_j in range(3):
                if bingo_num[row_i][col_j] == b:
                    bingo_num[row_i][col_j] = 0

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

    for j in range(3):
        if bingo_num[0][j] + bingo_num[1][j] + bingo_num[2][j] == 0:
            print("Yes")
            exit()

    sum_naname = 0
    sum_naname_2 = 0
    for i in range(3):
        sum_naname += bingo_num[i][i]
        sum_naname_2 += bingo_num[i][2 - i]

    if sum_naname == 0 or sum_naname_2 == 0:
        print("Yes")
        exit()
    print("No")


main()

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

B = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N =int(input())
for _ in range(N):
  b = int(input())
  for k in range(3):
    for j in range(3):
      if A[k][j] == b:
        B[k][j] = 1

if sum(B[0]) == 3 or sum(B[1]) == 3 or sum(B[2]) == 3:
  print('Yes')
elif B[0][0] + B[1][0] + B[2][0] ==3:
  print('Yes')
elif B[0][1] + B[1][1] + B[2][1] ==3:
  print('Yes')
elif B[0][2] + B[1][2] + B[2][2] ==3:
  print('Yes')
elif B[0][0] + B[1][1] + B[2][2] ==3:
  print('Yes')
elif B[0][2] + B[1][1] + B[2][0] ==3:
  print('Yes')
else:
  print('No')

Solution (Python):
X=[list(map(int,input().split()))for i in range(3)]
b=[int(input())for i in range(int(input()))]
for i in range(3):
 X[i]=[1 if i in b else 0 for i in X[i]]
print("Yes" if 3<=max(*[sum(i)for i in X],*[sum([x[i] for x in X])for i in range(3)],X[0][0]+X[1][1]+X[2][2],X[0][2]+X[1][1]+X[2][0]) else "No")

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    bingo_num = []

    for i in range(3):
        N = LI()
        bingo_num.append(N)

    N = II()

    for i in range(N):
        b = II()
        for row_i in range(3):
            for col_j in range(3):
                if bingo_num[row_i][col_j] == b:
                    bingo_num[row_i][col_j] = 0

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

    for j in range(3):
        if bingo_num[0][j] + bingo_num[1][j] + bingo_num[2][j] == 0:
            print("Yes")
            exit()

    sum_naname = 0
    sum_naname_2 = 0
    for i in range(3):
        sum_naname += bingo_num[i][i]
        sum_naname_2 += bingo_num[i][2 - i]

    if sum_naname == 0 or sum_naname_2 == 0:
        print("Yes")
        exit()
    print("No")


main()

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

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

if a0[0] in b and a0[1] in b and a0[2] in b or a1[0] in b and a1[1] in b and a1[2] in b or a2[0] in b and a2[1] in b and a2[2] in b or  a0[0] in b and a1[0] in b and a2[0] in b or a0[1] in b and a1[1] in b and a2[1] in b or a0[2] in b and a1[2] in b and a2[2] in b or a0[0] in b and a1[1] in b and a2[2] in b or a0[2] in b and a1[1] in b and a2[0] in b:
    print('Yes')
else:
    print('No')

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)
 
def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
 
def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    
    
    Hit = [[False] * 3, [False] * 3, [False] * 3]
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if A[i][j]== B[k]:
                    Hit[i][j] = True
                    break
    
    ans = False
    for i in range(3):
            if (Hit[i][0] and Hit[i][1] and Hit[i][2]) or (Hit[0][i] and Hit[1][i] and Hit[2][i]):
              ans = True
              break  
    if (A[0][2] and Hit[1][1] and Hit[2][0]) or (Hit[0][0] and Hit[1][1] and Hit[2][2]):
        ans = True

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)
 
def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
 
def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    
    
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if A[i][j]== B[k]:
                    A[i][j] = 0
                    break
    
    ans = 'No'
    for i in range(3):
            if (A[i][0]==0 and A[i][1]==0 and A[i][2]==0) or (A[0][i]==0 and A[1][i]==0 and A[2][i]==0):
              ans = 'Yes'
              break  
    if (A[0][2]==0 and A[1][1]==0 and A[2][0]==0) or (A[0][0]==0 and A[1][1]==0 and A[2][2]==0):
        ans = 'Yes'
    print(ans)
main()

Solution (Python):
def judge(l):
    
    if sum(l[0]) == 3 or sum(l[1])==3 or sum(l[2])==3:
        return 1
    else:
        if l[0][0]+l[1][0]+l[2][0] == 3:
            return 1
        elif l[0][1]+l[1][1]+l[2][1] == 3:
            return 1
        elif l[0][2]+l[1][2]+l[2][2] == 3:
            return 1
        else:
            if l[0][0]+l[1][1]+l[2][2] == 3:
                return 1
            elif l[0][2]+l[1][1]+l[2][0] == 3:
                return 1
            else:
                return 0

A1 = [int(i) for i in input().split(' ')]
A2 = [int(i) for i in input().split(' ')]
A3 = [int(i) for i in input().split(' ')]
N = int(input())
bs = []
for n in range(N):
    bs.append(int(input()))

dic = {}
for i,a in enumerate(A1):
    dic[a] = (0,i)
for i,a in enumerate(A2):
    dic[a] = (1,i)
for i,a in enumerate(A3):
    dic[a] = (2,i)

l = [[0,0,0],[0,0,0],[0,0,0]]
for b in bs:
    if b in dic:
        index = dic[b]
        l[index[0]][index[1]] = 1

if judge(l) == 0:
    print('No')
else:
    print('Yes')

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

a_list = []
a = []
c = [False for i in range(9)]
for i in range(3):
    a_list = lr()
    for num in a_list:
        a.append(num)
n = int(input())
for i in range(n):
    num = ir()
    if num in a:
        index = a.index(num)
        c[index] = True

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

Solution (Python):
import sys
input = sys.stdin.readline

M=[list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ans = [[0]*3 for _ in range(3)]

b = set(b)
for i in range(3):
    for j in range(3):
        if M[i][j] in b:
            ans[i][j]=1
score = 0 
for i in range(3):
    if sum(ans[i])==3:
        score = 1

if ans[0][0]==1 and ans[1][1]==1 and ans[2][2]==1:
    score = 1
if ans[0][2]==1 and ans[1][1]==1 and ans[2][0]==1:
    score = 1

for i in range(3):
    x = 0
    for j in range(3):
        x+=ans[j][i]
    if x==3:
        score=1

print('Yes') if score==1 else print('No')

Solution (Python):
import sys

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

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


def bingo_judge(A, B):
    
    for i in range(3):
        flag = True
        for a in [A[0][i], A[1][i], A[2][i]]:
            if not (a in B):
                flag = False
        if flag:
            print("Yes")
            sys.exit()
    
    for i in range(3):
        flag = True
        for a in A[i]:
            if not (a in B):
                flag = False
        if(flag):
            print("Yes")
            sys.exit()
    
    flag = True
    for a in [A[0][0], A[1][1], A[2][2]]:
        if not (a in B):
            flag = False
    if flag:
        print("Yes")
        sys.exit()
    flag = True
    for a in [A[0][2], A[1][1], A[2][0]]:
        if not (a in B):
            flag = False
    if flag:
        print("Yes")
        sys.exit()
    print("No")


bingo_judge(A, B)

Solution (Python):
import numpy as np

l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
l = l1 + l2 + l3
n = int(input())

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

for i in range(len(l)):
    for j in bl:
        if l[i] == j:
            l[i] = 0
            
bingo = np.array(l).reshape(3,3)
print("Yes" if (min(bingo.sum(axis=1)) == 0) | (min(bingo.sum(axis=0)) == 0) | (min([np.diag(bingo).sum(), np.diag(np.fliplr(bingo)).sum()]) == 0) else "No")

Solution (Python):
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
l = l1 + l2 + l3
n = int(input())

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

for i in range(len(l)):
    for j in bl:
        if l[i] == j:
            l[i] = 0
rowwise = 1 if (sum(l[0:3]) == 0) | (sum(l[3:6]) == 0)  | (sum(l[6:]) == 0) else 0
colwise = 1 if (sum([l[0], l[3], l[6]]) == 0) | (sum([l[1], l[4], l[7]]) == 0)  | (sum([l[2], l[5], l[8]]) == 0) else 0
crosswise = 1 if (sum([l[0], l[4], l[8]]) == 0) | (sum([l[2], l[4], l[6]]) == 0) else 0

print("Yes" if sum([rowwise, colwise, crosswise]) else "No")

Solution (Python):
ARR = [
    [84, 97, 66],
    [79, 89, 11],
    [61, 59, 7],
]


N = 7
BRR = [
    89,
    7,
    87,
    79,
    24,
    84,
    30,
]


ARR = []

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

N = int(input())

BRR = []

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


def calculagte(arr, n, brr):
    status = [
        [False, False, False],
        [False, False, False],
        [False, False, False]
    ]

    for h in range(3):
        for w in range(3):
            for i in range(n):
                if arr[h][w] == brr[i]:
                    status[h][w] = True

    isOk = False

    if status[0][0] and status[0][1] and status[0][2]:
        isOk = True

    if status[1][0] and status[1][1] and status[1][2]:
        isOk = True

    if status[2][0] and status[2][1] and status[2][2]:
        isOk = True


    if status[0][0] and status[1][0] and status[2][0]:
        isOk = True

    if status[0][1] and status[1][1] and status[2][1]:
        isOk = True

    if status[0][2] and status[1][2] and status[2][2]:
        isOk = True

    if status[0][0] and status[1][1] and status[2][2]:
        isOk = True

    if status[2][0] and status[1][1] and status[0][2]:
        isOk  = True

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

calculagte(ARR, N, BRR)

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




for b in B:
    for i in range(3):
        if b in A[i]:
            
            A[i][A[i].index(b)] = 0
        


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

Solution (Python):
import numpy as np

line_1 = np.array(list(map(int, input().split())))
line_2 = np.array(list(map(int, input().split())))
line_3 = np.array(list(map(int, input().split())))
n = int(input())
lists = [int(input()) for i in range(n)]

line = np.concatenate([line_1, line_2, line_3])
for i in lists:
  index = np.where(line == i)
  line[index] = 0

line = np.reshape(line, (3,3))
condition_1 = line[0].sum() == 0
condition_2 = line[1].sum() == 0
condition_3 = line[2].sum() == 0
condition_4 = line[:,0].sum() == 0
condition_5 = line[:,1].sum() == 0
condition_6 = line[:,2].sum() == 0
condition_7 = line[0,0] + line[1,1] + line[2,2] == 0
condition_8 = line[2,0] + line[1,1] + line[0,2] == 0

if condition_1 or condition_2 or condition_3 or condition_4 or condition_5 or condition_6 or condition_7 or condition_8:
  print('Yes')
else:
  print('No')