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

N = int(input())

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

atari_l = []
for b in b_l:
  if b in card:
    atari_l.append( card.index(b)) 
  else:
    continue


def warusan(n):
  return n%3
atari = list(map(warusan,atari_l))


if 0 in atari_l and 4 in atari_l and 8 in atari_l:
  print("Yes")
elif 2 in atari_l and 4 in atari_l and 6 in atari_l:
  print("Yes")


elif 0 in atari_l and 1 in atari_l and 2 in atari_l:
  print("Yes")
elif 3 in atari_l and 4 in atari_l and 5 in atari_l:
  print("Yes")
elif 6 in atari_l and 7 in atari_l and 8 in atari_l:
  print("Yes")  



elif atari.count(0) == 3:
  print("Yes")
elif atari.count(1) == 3:
  print("Yes")
elif atari.count(2) == 3:
  print("Yes")

else:
  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()))
a = np.array(a)
for i in range(n):
    a[np.where(a == b[i])] = bool(b[i] in a)
def check(i,j):
    if i >= 0 and i < 3 and j >= 0 and j < 3:
        if a[i][j] == 1:
            return True
    return False
for i in range(3):
    if ((a[i][0] == 1 and a[i][1] == 1 and a[i][2] == 1) or (a[0][i] == 1 and a[1][i] == 1 and a[2][i] == 1)):
        print('Yes')
        break
else:
    if ((a[0][0] == 1 and a[1][1] == 1 and a[2][2] == 1) or (a[0][2] == 1 and a[1][1] == 1 and a[2][0] == 1)):
        print('Yes')
    else:
        print('No')

Solution (Python):
import math
import numpy as np
from collections import deque
def main():
    a_1 = [int(t)for t in input().split()]
    a_2 = [int(t)for t in input().split()]
    a_3 = [int(t)for t in input().split()]

    a = [a_1,a_2,a_3]

    card = np.array(a)

    n = int(input())

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

    result = np.zeros((3,3),np.int)!=0

    for i in b:
        t = card==i
        result |= t

    rest = result.T
    c = result[0].all() or result[1].all() or result[2].all()
    r = rest[0].all() or rest[1].all() or rest[2].all()

    sl = result[0][0] and result[1][1] and result[2][2]
    bs = result[2][0] and result[1][1] and result[0][2]

    print("Yes" if c or r or sl or bs else "No")
    
if __name__ == "__main__":
    main()

Solution (Python):
a = []
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
    
tf = [[False for i in range(3)] for j 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:
                tf[j][k] = True

bingo = 0
for i in range(3):
    if tf[i] == [True, True, True]:
        bingo += 1

for i in range(3):
    if tf[0][i] == True and tf[1][i] == True and tf[2][i] == True:
        bingo += 1

if tf[0][0] == True and tf[1][1] == True and tf[2][2] == True:
    bingo += 1
    
if tf[0][2] == True and tf[1][1] == True and tf[2][0] == True:
    bingo += 1

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

Solution (Python):
import collections as c
import sys
input = sys.stdin.readline
ip = lambda : map(int, input().split())
mod = 10**9+7

A = []
for i in range(3):
    A.append(list(ip()))
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 sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[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):
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
n=int(input())
a=[int(input()) for i in range (n)]
if l1[0] in a:
  l1[0]=0
if l1[1] in a:
  l1[1]=0   
if l1[2] in a:
  l1[2]=0 
if l2[0] in a:
  l2[0]=0 				
if l2[1] in a:
  l2[1]=0 
if l2[2] in a:
  l2[2]=0 
if l3[0] in a:
  l3[0]=0 
if l3[1] in a:
  l3[1]=0
if l3[2] in a:
  l3[2]=0 
ans="No"
if l1==[0,0,0]:
  ans="Yes"
if l2==[0,0,0]:
  ans="Yes"
if l3==[0,0,0]:
  ans="Yes"
if l1[0]==l2[0]==l3[0]==0:
  ans="Yes"
if l1[1]==l2[1]==l3[1]==0:
  ans="Yes"
if l1[2]==l2[2]==l3[2]==0:
  ans="Yes"
if l1[0]==l2[1]==l3[2]==0:
  ans="Yes"
if l1[2]==l2[1]==l3[0]==0:
   ans="Yes"
print(ans)

Solution (Python):
card_1 = [i for i in input().split()]
card_2 = [i for i in input().split()]
card_3 = [i for i in input().split()]
call_cnt = int(input())
call_num = [input() for i in range(call_cnt)]

cent_num = card_2[1]

tate_1 = [card_1[0], card_2[0], card_3[0]]
tate_2 = [card_1[1], card_2[1], card_3[1]]
tate_3 = [card_1[2], card_2[2], card_3[2]]

cross_l = [card_1[0], card_2[1], card_3[2]]
cross_r = [card_1[2], card_2[1], card_3[0]]

if cent_num in call_num:
    if len(set(call_num)&set(card_1)) == 3:
        print('Yes')
    elif len(set(call_num)&set(card_2)) == 3:
        print('Yes')
    elif len(set(call_num)&set(card_3)) == 3:
        print('Yes')
    elif len(set(call_num)&set(tate_1)) == 3:
        print('Yes')
    elif len(set(call_num)&set(tate_2)) == 3:
        print('Yes')
    elif len(set(call_num)&set(tate_3)) == 3:
        print('Yes')
    elif len(set(call_num)&set(cross_l)) == 3:
        print('Yes')
    elif len(set(call_num)&set(cross_r)) == 3:
        print('Yes')
    else:
        print('No')
else:
    if len(set(call_num)&set(card_1)) == 3:
        print('Yes')
    elif len(set(call_num)&set(card_3)) == 3:
        print('Yes')
    elif len(set(call_num)&set(tate_1)) == 3:
        print('Yes')
    elif len(set(call_num)&set(tate_3)) == 3:
        print('Yes')
    else:
        print('No')

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

sc = 1
DEB = False

def check_vertical(card):
    V = [sum(card[sc][i]) for i in range(3)]
    if DEB: print(V)
    return (3 in V)

def check_horizen(card):
    H = [sum([card[sc][j][i] for j in range(3)]) for i in range(3)]
    if DEB: print(H)
    return (3 in H)
def check_diag(card):
    D = [card[sc][0][0]+card[sc][1][1]+card[sc][2][2],
         card[sc][0][2]+card[sc][1][1]+card[sc][2][0]]
    if DEB: print(D)
    return(3 in D)

def check_card(card):
    return (check_diag(card) or check_horizen(card) or check_vertical(card))

for b in B:
    for i in range(3):
        for j in range(3):
            if card[0][i][j] == b: card[1][i][j] = 1
            tf = check_card(card)
            if tf:
                print('Yes')
                break
        else:
            continue
        break
    else:
        continue
    break
else:
    if tf is False:
        print('No')

Solution (Python):
import sys
a = []
for i in range(3):
    a.append(list(input().split()))    

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





ans = [["0","0","0"],["0","0","0"],["0","0","0"]]
for i in range(n):
    for j in range(3):
        if b[i] in a[j]:
            index = a[j].index(b[i])
            ans[j][index]  = "1"

for i in range(3):
    if "0" in ans[i]:
        pass
    else:
        print("Yes")
        sys.exit()

count = 0
for i in range(3):
    if "0" in ans[i][0]:
        pass
    else:
        count += 1
if count == 3:
    print("Yes")
    sys.exit()
count = 0
for i in range(3):
    if "0" in ans[i][1]:
        pass
    else:
        count += 1
if count == 3:
    print("Yes")
    sys.exit()
count = 0
for i in range(3):
    if "0" in ans[i][2]:
        pass
    else:
        count += 1
if count == 3:
    print("Yes")
    sys.exit()

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

count = 0
for i in range(3):
    if ans[i][-(i+1)] == "1":
        count += 1
    if count == 3:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):


def abc157b(bingo, b):
    ans = False

    
    for i in range(0, 3):
        bCnt = 0
        for j in range(0, 3):
            if bingo[i][j] in b:
                bCnt += 1

        if bCnt == 3:
            ans = True

    
    for j in range(0, 3):
        bCnt = 0
        for i in range(0, 3):
            if bingo[i][j] in b:
                bCnt += 1

        if bCnt == 3:
            ans = True

    
    bCnt = 0
    for i in range(0, 3):
        if bingo[i][i] in b:
            bCnt += 1

    if bCnt == 3:
        ans = True

    bCnt = 0
    for i in range(0, 3):
        if bingo[i][2-i] in b:
            bCnt += 1

    if bCnt == 3:
        ans = True
    
    if ans:
        return("Yes")
    else:
        return("No")



if(__name__ == '__main__'):
    
    bingoArray = [[] for _ in range(3)]
    for i in range(0, 3):
        bingoArray[i] = list(map(int, input().split(" ")))
    n = int(input())
    b = [[] for _ in range(n)]
    for j in range(0, n):
        b[j] = int(input())
    
    accomplishment = abc157b(bingoArray, b)
    
    
    print(accomplishment)

Solution (Python):
a1 = input().split()
a2 = input().split()
a3 = input().split()

n = int(input())

bingo_sheet = a1 + a2 + a3

atari = []


for _ in range(n):
    num = input()
    try:
        atari_index = bingo_sheet.index(num)
        atari.append(str(atari_index + 1))
    except:
        continue


atari_true = False

if '1' in atari:
    if '2' in atari:
        if '3' in atari:
            atari_true = True
    if '4' in atari:
        if '7' in atari:
            atari_true = True
    if '5' in atari:
        if '9' in atari:
            atari_true = True

if '2' in atari:
    if '5' in atari:
        if '8' in atari:
            atari_true = True

if '3' in atari:
    if '6' in atari:
        if '9' in atari:
            atari_true = True
    if '5' in atari:
        if '7' in atari:
            atari_true = True

if '4' in atari:
    if '5' in atari:
        if '6' in atari:
            atari_true = True

if '7' in atari:
    if '8' in atari:
        if '9' in atari:
            atari_true = True
            
if atari_true:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

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

a = np.array(a)
b = np.array(b)

after = np.zeros((3,3))
for i in range(N):
    after += a == b[i]
    
bool1 = (np.sum(after, axis=0)==3).sum()
bool2 = (np.sum(after, axis=1)==3).sum()
bool3 = (after[0,0]+after[1,1]+after[2,2])==3
bool4 = (after[0,2]+after[1,1]+after[2,0])==3

if bool1+bool2+bool3+bool4>0:
    ans = 'Yes'
else:
    ans = 'No'
    
print(ans)

Solution (Python):
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
b = []
ans = "No"
for i in range(n):
    b.append(int(input()))

count = 0
for i in a1:
    if i in b:
        count += 1
if count == 3:
    ans = "Yes"

count2 = 0
for i in a2:
    if i in b:
        count2 += 1
if count2 == 3:
    ans = "Yes"

count3 = 0
for i in a3:
    if i in b:
        count3 += 1
if count3 == 3:
    ans = "Yes"

for i in range(3):
    if (a1[i] in b) and (a2[i] in b) and (a3[i] in b):
        ans = "Yes"


if (a1[0] in b) and (a2[1] in b) and (a3[2] in b):
    ans = "Yes"

if (a1[2] in b) and (a2[1] in b) and (a3[0] in b):
    ans = "Yes"
print(ans)

Solution (Python):
def bingocheck(ANS):
    if'A00' in ANS and 'A10' in ANS and 'A20' in ANS:
        return 1
    if'A01' in ANS and 'A11' in ANS and 'A21' in ANS:
        return 1
    if'A02' in ANS and 'A12' in ANS and 'A22' in ANS:
        return 1
    if'A00' in ANS and 'A01' in ANS and 'A02' in ANS:
        return 1
    if'A10' in ANS and 'A11' in ANS and 'A12' in ANS:
        return 1
    if'A20' in ANS and 'A21' in ANS and 'A22' in ANS:
        return 1
    if'A00' in ANS and 'A11' in ANS and 'A22' in ANS:
        return 1
    if'A02' in ANS and 'A11' in ANS and 'A20' in ANS:
        return 1
    return 0




A0 = list(map(int,input().split()))
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
n = int(input())
ANS = []
for i in range(n):
    b = int(input())
    for i in range(3):
        if b == A1[i]:
            ANS.append('A1'+str(i))
    for i in range(3):
        if b == A2[i]:
            ANS.append('A2'+str(i))
    for i in range(3):
        if b == A0[i]:
            ANS.append('A0'+str(i))
    if bingocheck(ANS)==1:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
*a1, = map(int, input().split())
*a2, = map(int, input().split())
*a3, = map(int, input().split())
a = [a1, a2, a3]


n = int(input())
for _ in range(n):
    b = int(input())
    for i, row in enumerate(a):
        for j, x in enumerate(row):
            if x == b:
                a[i][j] = 0

is_bingo = False
for row in a:
    if sum(row) == 0:
        is_bingo = True

for col in zip(*a):
    if sum(col) == 0:
        is_bingo = True

if all(a[i][i] == 0 for i in range(3)):
    is_bingo = True

if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    is_bingo = True

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    import numpy as np
    A = [list(map(int,readline().split())) for _ in range(3)]
    N, *b = map(int, read().split())
    A = np.array(A)
    B = np.zeros(A.shape)
    for i in A.reshape(-1):
        if i in b:
            B[np.where(A == i)] = 1
    for i in range(3):
        if np.all(B[i, :] == 1):
            print('Yes')
            break
        if np.all(B[:, i] == 1):
            print('Yes')
            break
    else:
        if B[0,0]==B[1,1]==B[2,2]==1:
            print('Yes')
        elif B[0,2]==B[1,1]==B[2,0]==1:
            print('Yes')
        else:
            print('No')
    return
if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
        
A = []
A = np.zeros((3, 3))
for i in range(3):
    A[i] =[int(e) for e in input().split()]
N = int(input())    
B = []
for i in range(N):
    B.append(int(input()))
ans = []
for i in range(3):
    ans.append(A[i])
ans.append([A[0][0], A[1][1], A[2][2]])
ans.append([A[0][2], A[1][1], A[2][0]])
ans.append([A[0][0], A[1][0], A[2][0]])
ans.append([A[0][1], A[1][1], A[2][1]])
ans.append([A[0][2], A[1][2], A[2][2]])
ans = np.array(ans)
flg = 0
for i in ans:
    if i[0] in B and i [1] in B and i[2] in B:
        print('Yes')
        flg = 1
        break
if flg == 0:
    print('No')

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

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

Solution (Python):
BingoRow = 3
BingoList = [list(map(int,input().split())) for i in range(BingoRow)]
 
TargetRow = int(input())
TargetList = [int(input()) for i in range(TargetRow)]
 
ansList = []
x = 0
flg = False
for row in BingoList:
  for num in row:
    flg = False
    for target in TargetList:
      if num == target:
        ansList.append(1)
        flg = True
    if not flg:
      ansList.append(0)
 
if (ansList[0] + ansList[1] + ansList[2]) == 3:
  print('Yes')
elif (ansList[3] + ansList[4] + ansList[5]) == 3:
  print('Yes')
elif (ansList[6] + ansList[7] + ansList[8]) == 3:
  print('Yes')
elif (ansList[0] + ansList[3] + ansList[6]) == 3:
  print('Yes')
elif (ansList[1] + ansList[4] + ansList[7]) == 3:
  print('Yes')
elif (ansList[2] + ansList[5] + ansList[8]) == 3:
  print('Yes')
elif (ansList[0] + ansList[4] + ansList[8]) == 3:
  print('Yes')
elif (ansList[2] + ansList[4] + ansList[6]) == 3:
  print('Yes')
else:
  print('No')

Solution (Python):
A = list(input().split() for l in range(3))
N = int(input())
B = list(int(input()) for i in range(N))

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

def bingo(A):
    for i in range(3):
        if A[i][0] + A[i][1] + A[i][2] == "000" or A[0][i] + A[1][i] + A[2][i] == "000" or A[0][0] + A[1][1] + A[2][2] == "000" or A[0][2] + A[1][1] + A[2][0] == "000":
            return "Yes"
    return "No"

print(bingo(A))

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

marubatu = [[0,0,0],
[0,0,0],
[0,0,0]]

for b in B:
    for i,a1 in enumerate(A1):
        if b==a1:
            marubatu[0][i]=1
    for i,a2 in enumerate(A2):
        if b==a2:
            marubatu[1][i]=1
    for i,a3 in enumerate(A3):
        if b==a3:
            marubatu[2][i]=1

def tate():
    f = False
    for i in range(3):
        if (marubatu[i][0])and(marubatu[i][1])and(marubatu[i][2]==1):
            f=True
    return f

def yoko():
    f = False
    for i in range(3):
        if (marubatu[0][i])and(marubatu[1][i])and(marubatu[2][i]==1):
            f=True
    return f

def migisagari():
    f = False
    if (marubatu[0][0])and(marubatu[1][1])and(marubatu[2][2]==1):
        f=True
    return f

def hidarisagari():
    flag=False
    if (marubatu[0][2])and(marubatu[1][1])and(marubatu[2][0]==1):
        flag=True
    return flag



f1 = tate()
f2 = yoko()
f3 = migisagari()
f4 = hidarisagari()

if f1 or f2 or f3 or f4:
    print('Yes')
else:
    print('No')

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


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

  
for i in range(len(l)):
  if l[i] in l2:
    l[i]=0


y1=l[0]+l[1]+l[2]
y2=l[3]+l[4]+l[5]
y3=l[6]+l[7]+l[8]
t1=l[0]+l[3]+l[6]
t2=l[1]+l[4]+l[7]
t3=l[2]+l[5]+l[8]
n1=l[0]+l[4]+l[8]
n2=l[2]+l[4]+l[6]

if y1*y2*y3*t1*t2*t3*n1*n2==0:
  print("Yes")
else:
  print("No")

Solution (Python):
def output(A, b): 
    BW = [0,0,0]
    for i in range(len(A)):
        for j in range(len(b)):
            if(A[i] == b[j]):
                BW[i] = 1
                break
            else:
                continue
    return BW

A0 = list(map(int, input().split()))
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
N = int(input())
b = [0]*N
for i in range(N):
    b[i] = int(input())

x = output(A0, b)
y = output(A1, b)
z = output(A2, b)

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

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

Solution (Python):
A_1 = list(map(int, input().split()))
A_2 =list(map(int, input().split()))
A_3 =list(map(int, input().split()))
A = A_1 +A_2 +A_3
N = int(input())
b = [int(input()) for _ in range(N)]
for i in range(N):
    for j in range(9):
        if b[i] == A[j]:
            A[j] = 0
if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 or A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:          
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
for i in range(3):
    ai = list(map(int, input().split()))
    a += [ai]
bingo = [[False, False, False], [False, False, False], [False, False, False]]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            bingo[j][a[j].index(b)] = True
            break
e = []
d = []
c = []
r = []
l = []
count = 0
for i in range(3):
    if not (False in bingo[i]):
        print("Yes")
        exit()
    e.append(bingo[i][0])
    d.append(bingo[i][1])
    c.append(bingo[i][2])
    r.append(bingo[i][count])
    l.append(bingo[i][2 - count])
    count += 1
if not (False in e):
    print("Yes")
    exit()
elif not (False in d):
    print("Yes")
    exit()
elif not (False in c):
    print("Yes")
    exit()
elif not (False in r):
    print("Yes")
    exit()
elif not (False in l):
    print("Yes")
    exit()
print("No")

Solution (Python):
A = [[0]*3 for i in range(3)]
a = [[0]*3 for i in range(3)]

for i in range (3):
    X,Y,Z = map(int,input().split())
    a[i][0] = X
    a[i][1] = Y
    a[i][2] = Z

N = int(input())
b = [0]*N

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

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

if sum(A[0]) ==3 or sum(A[1]) ==3 or sum(A[2]) ==3 or A[0][0]+A[1][0]+A[2][0] ==3 or A[0][1]+A[1][1]+A[2][1] ==3 or A[0][2]+A[1][2]+A[2][2] ==3 or A[0][0]+A[1][1]+A[2][2] ==3 or A[0][2]+A[1][1]+A[2][0] ==3:
    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())
list=[int(input()) for _ in range(n)]
for i in range(n):
    for j in range(3):
        if list[i]==a1[j]:
            a1[j]=101
        elif list[i]==a2[j]:
            a2[j]=101
        elif list[i]==a3[j] :
            a3[j]=101

if a1[0]==a2[0]==a3[0]==101:
    print("Yes")
elif a1[1]==a2[1]==a3[1]==101:
    print("Yes")
elif a1[2]==a2[2]==a3[2]==101:
    print("Yes")
elif a1[0]==a1[1]==a1[2]==101:
    print("Yes")
elif a2[0]==a2[1]==a2[2]==101:
    print("Yes")
elif a3[0]==a3[1]==a3[2]==101:
    print("Yes")
elif a1[0]==a2[1]==a3[2]==101:
    print("Yes")
elif a1[2]==a2[1]==a3[0]==101:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import numpy as np



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

n = int(input())

num = []
for ii in range(n):
    num.append(int(input()))

bi = np.full(9, False)

bingo_np = np.array(bingo).reshape(-1)

for number in num:
    for i in range(9):
        if bingo_np[i] == number:
            bi[i] = True
if (np.all(bi[:3])):
    print("Yes")
elif (np.all(bi[3:6])):
    print("Yes")
elif (np.all(bi[6:9])):
    print("Yes")
elif (np.all([bi[0], bi[3], bi[6]])):
    print("Yes")
elif (np.all([bi[1], bi[4], bi[7]])):
    print("Yes")
elif (np.all([bi[2], bi[5], bi[8]])):
    print("Yes")
elif (np.all([bi[0], bi[4], bi[8]])):
    print("Yes")
elif (np.all([bi[2], bi[4], bi[6]])):
    print("Yes")
else:
    print("No")

Solution (Python):
bingo=[]
for i in range(3):
  num=list(map(int,input().split()))
  bingo.append(num)
N=int(input())
atari=[0,0,0,0,0,0,0,0,0]
for i in range(N):
  num=int(input())
  for j in range(9):
    if bingo[j//3][j%3]==num:
      atari[j]=1

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

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

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


for i in range(3):
  for k in range(3):
    for f in range(len(b)):
        if b[f] == a[i][k]:
            ac[i][k]= 1
 
bingo =0

if ac[0][0]+ac[0][1]+ac[0][2] ==3:
  bingo +=1
if ac[1][0]+ac[1][1]+ac[1][2] ==3:
  bingo +=1
if ac[2][0]+ac[2][1]+ac[2][2] ==3:
  bingo +=1

if ac[0][0]+ac[1][0]+ac[2][0] ==3:
  bingo +=1
if ac[0][1]+ac[1][1]+ac[1][1] ==3:
  bingo +=1
if ac[0][2]+ac[1][2]+ac[2][2] ==3:
  bingo +=1
  
if ac[0][0]+ac[1][1]+ac[2][2] ==3:
  bingo +=1
if ac[2][0]+ac[1][1]+ac[0][2] ==3:
  bingo +=1
  
if bingo >0: print("Yes")
else: 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())
ans =[[0,0,0],
      [0,0,0],
      [0,0,0]]


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

for i in d:
  for j in range(len(a)):
    if a[j] == i:
      ans[0][j] = 1
  for j in range(len(b)):
    if b[j] == i:
      ans[1][j] = 1
  for j in range(len(c)):
    if c[j] == i:
      ans[2][j] = 1

answer = "No"

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


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


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

print(answer)

Solution (Python):
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = [int(input()) for _ in range(n)]
for i in range(len(a)):
    for o in range(len(a[1])):
        if a[i][o] in b:
            a[i][o] = 0
for i in a:
    if i == [0,0,0]:
        print("Yes")
        quit()
for i in range(3):
    if a[0][i] == 0 and a[1][i] ==0 and a[2][i] ==0:
        print("Yes")
        quit()
if a[0][0] == 0 and a[2][2] ==0 and a[1][1] == 0:
    print("Yes")
    quit()
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] ==0:
    print("Yes")
    quit()
print("No")

Solution (Python):
def checkbingo(bingo,bs):
  for b in bingo:
    cnt = 0
    for n in bs:
      if n in b:
        cnt +=1
    if cnt == len(b):
      return True
  return False

list1 = input('').split(' ')
list2 = input('').split(' ')
list3 = input('').split(' ')
bingo = [list1,list2,list3]
bingo.append([list1[0],list2[0],list3[0]])
bingo.append([list1[1],list2[1],list3[1]])
bingo.append([list1[2],list2[2],list3[2]])
bingo.append([list1[0],list2[1],list3[2]])
bingo.append([list1[2],list2[1],list3[0]])
max_n = int(input(''))
bs = []
result = False
for n in range(0,max_n):
  bs.append(input(''))

if checkbingo(bingo,bs):
    print("Yes")
else:
    print("No")

Solution (Python):
mat = [list(map(int,input().split())) for i in range(3)]
mat = mat[0]+mat[1]+mat[2]

n = int(input())
for _ in range(n):
  m = int(input())
  for i in range(9):
    if mat[i] == m:
      mat[i] = 1000

if sum(mat[:3])>=3000:
  print("Yes")
elif sum(mat[3:6])>=3000:
  print("Yes")
elif sum(mat[6:])>=3000:
  print("Yes")
elif sum(mat[::3])>=3000:
  print("Yes")
elif sum(mat[1::3])>=3000:
  print("Yes")
elif sum(mat[2::3])>=3000:
  print("Yes")
elif sum(mat[::4])>=3000:
  print("Yes")
elif sum(mat[2:7:2])>=3000:
  print("Yes")
else:
  print("No")

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

ans = []
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1 :
        a1[a1.index(b)] = 101
    if b in a2 :
        a2[a2.index(b)] = 101
    if b in a3 :
        a3[a3.index(b)] = 101

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

if a1.count(101) == 3 or a2.count(101) == 3 or a3.count(101) == 3 :
    print('Yes')
    sys.exit()

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

if a1[2] == 101 and a2[1] == 101 and a3[0] == 101 :
    print('Yes')
    sys.exit()
print('No')

Solution (Python):


i=0
A = []
while i < 3: 
    m = map(int, input().split())
    A.append(list(m))
    i+=1

n=int(input())

i=0
lst = []
while i < n: 
    b = int(input())
    lst.append(b)
    i+=1

a= {}
for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in lst:
            a[str(i)+str(j)] = 1
        else:
            a[str(i)+str(j)] = 0


if a["00"] + a["01"]+ a["02"] == 3 \
    or a["10"] + a["11"] + a["12"] == 3 \
    or a["20"] + a["21"] + a["22"] == 3 \
    or a["00"] + a["10"] + a["20"] == 3 \
    or a["01"] + a["11"] + a["21"] == 3 \
    or a["02"] + a["12"] + a["22"] == 3 \
    or a["00"] + a["11"] + a["22"] == 3  \
    or a["02"] + a["11"] + a["20"] == 3:
    print("Yes")
else:
    print("No")

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

N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            idx = A[j].index(b)
            bingo[j][idx] = True


migiue = True
migisita = True
okFlg = False
for i in range(3):
    tate = True
    yoko = True
    for j in range(3):
        if bingo[i][j] == False:
            yoko = False
        if bingo[j][i] == False:
            tate = False
    if tate or yoko:
        okFlg = True
        break
    if bingo[i][i] == False:
        migisita = False
    if bingo[i][-i - 1] == False:
        migiue = False

if migiue or migisita:
    if okFlg == False:
        okFlg = True
print('YNeos'[not okFlg::2])

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

for i in range(len(b_lst)):
    if b_lst[i] in a_lst:
        a_lst[a_lst.index(b_lst[i])] = 0

ans = 0

for i in range(3):
    if a_lst[i] == a_lst[i+3] == a_lst[i+6] == 0:
        print("Yes")
        ans = 1
        break
    elif a_lst[3*i] == a_lst[3*i+1] == a_lst[3*i+2] == 0:
        print("Yes")
        ans = 1
        break
    elif a_lst[2] == a_lst[4] == a_lst[6] == 0 or a_lst[0] == a_lst[4] == a_lst[8] == 0:
        print("Yes")
        ans = 1
        break

if ans == 0:
    print("No")