Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

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

n = int(input())
for _ in range(n):
    val = int(input())
    for i in range(3):
        try:
            index = bingo[i].index(val)
        except ValueError:
            pass
        else:
            bingo[i][index] = None
if bingo[0][0] == bingo[1][1] == bingo[2][2] == None:
    print("Yes")
elif bingo[0][2] == bingo[1][1] == bingo[2][0] == None:
    print("Yes")
else:
    tmp = True
    for i in range(3):
        if bingo[0][i] == bingo[1][i] == bingo[2][i] == None:
            print("Yes")
            tmp = False
            break
        if bingo[i][0] == bingo[i][1] == bingo[i][2] == None:
            print("Yes")
            tmp = False
            break

    if tmp:
        print("No")

Solution (Python):

import sys


def inn(func=int):
    return list(map(func,input().split()))

def ins():
    return input().split()

a0 = inn()
a1 = inn()
a2 = inn()
a = a0+a1+a2
n = int(input())
ban = [0,0,0,0,0,0,0,0,0]
for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            ban[j] = 1


for i in [0,1,2]:
    t = ban[i]+ban[i+3]+ban[i+6]
    if t == 3:
        print("Yes")
        exit()
for i in [0,3,6]:
    t = ban[i]+ban[i+1]+ban[i+2]
    if t == 3:
        print("Yes")
        exit()
if (ban[0]+ban[4]+ban[8]) == 3 or (ban[2]+ban[4]+ban[6]) == 3:
    print("Yes")
    exit()
print("No")

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

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

dic = {}


for i in range(3):
    r = []
    for j in range(3):
        r.append(A[i][j])

    dic[(i, 'row')] = r

for j in range(3):
    r = []
    for i in range(3):
        r.append(A[i][j])

    dic[(j, 'col')] = r


r = [A[0][0], A[1][1], A[2][2]]
dic[(0, 'dic')] = r

r = [A[0][2], A[1][1], A[2][0]]
dic[(1, 'dic')] = r


B = set(B)

for k, v in dic.items():
    flag = True
    for ele in v:
        if ele in B:
            continue
        else:
            flag = False
            break

    if flag:
        print('Yes')
        exit()


print('No')

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

n = int(input())

hit = []
for j in range(n):
    hit.append(int(input()))


for k in hit:
    for l in a:
        if k in l:
          l[l.index(k)] = 0

for m in a:
    if m == [0,0,0]:
        flag = 1

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

if a[0][0] == a[1][1] == a[2][2] == 0:
    flag = 1

if a[0][2] == a[1][1] == a[2][0] == 0:
    flag = 1
    
if flag == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys




ly = []

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

lt = []

for i in range(3):
    l = []
    for j in range(3):
        l.append(ly[j][i])
    lt.append(l)

l = ly+lt + [[ly[0][0],ly[1][1],lt[2][2]]] + [[ly[0][2],ly[1][1],ly[2][0]]]

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

for i in l:
    t = [0,0,0]
    if i [0] in nm:
        t[0] = 1
    if i [1] in nm:
        t[1] = 1
    if i [2] in nm:
        t[2] = 1
    if sum(t) == 3:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):
a1,a2,a3=map(int,input().split())
a4,a5,a6=map(int,input().split())
a7,a8,a9=map(int,input().split())
a=[a1,a2,a3,a4,a5,a6,a7,a8,a9]
n=int(input())
s=[]

for i in range(n):
  s.append(int(input()))
for ss in s:
  if ss in a:
    a[a.index(ss)]=-1

if a[0]+a[1]+a[2]==-3 or a[3]+a[4]+a[5]==-3 or a[6]+a[7]+a[8]==-3 or a[0]+a[3]+a[6]==-3 or a[1]+a[4]+a[7]==-3 or a[2]+a[5]+a[8]==-3 or a[0]+a[4]+a[8]==-3 or a[2]+a[4]+a[6]==-3:
  print('Yes')
else:
  print('No')

Solution (Python):
a1 = map(int, input().split())
a2 = map(int, input().split())
a3 = map(int, input().split())
bingo = []
bingo += a1
bingo += a2
bingo += a3
n = int(input())
b = [0] * n
ans = [0] * 9
for i in range(n):
    b[i] = int(input())
for i in range(n):
    for j in range(9):
        if b[i] == bingo[j]:
            ans[j] = 1

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

if ans[3] == 1 and ans[4] == 1 and ans[5] == 1:
    print('Yes')
    exit()

if ans[6] == 1 and ans[7] == 1 and ans[8] == 1:
    print('Yes')
    exit()

if ans[0] == 1 and ans[3] == 1 and ans[6] == 1:
    print('Yes')
    exit()

if ans[1] == 1 and ans[4] == 1 and ans[7] == 1:
    print('Yes')
    exit()

if ans[2] == 1 and ans[5] == 1 and ans[8] == 1:
    print('Yes')
    exit()

if ans[0] == 1 and ans[4] == 1 and ans[8] == 1:
    print('Yes')
    exit()

if ans[2] == 1 and ans[4] == 1 and ans[6] == 1:
    print('Yes')
    exit()

print('No')

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

def check():
  for y in range(R):
    f = True
    for x in range(R):
      if r[y][x] != 0:
        f = False
        break
    if f:
      return True
 
  for x in range(R):
    f = True
    for y in range(R):
      if r[y][x] != 0:
        f = False
        break
    if f:
      return True
 
  f = True
  for p in range(R):
    if r[p][p] != 0:
      f = False
      break
  if f:
    return True
 
  f = True
  for p in range(R):
    if r[R-1-p][p] != 0:
      f = False
      break
  return f
 
N = int(input())
for i in range(N):
  v = int(input())
  
  for y in range(R):
    for x in range(R):
      if r[y][x] == v:
        r[y][x] = 0
 
print('Yes' if check() else 'No')

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

for _b in b:
    for i, row in enumerate(bingo):
        for j, _n in enumerate(row):
            if _b == _n:
                bingo[i][j] = 0

for row in bingo:
    if row == [0, 0, 0]:
        print('Yes')
        break
else:
    for i in range(3):
        if bingo[0][i] == 0 and bingo[1][i] == 0 and bingo[2][i] == 0:
            print('Yes')
            break
    else:
        if bingo[0][0] == 0 and bingo[1][1] == 0 and bingo[2][2] == 0:
            print('Yes')
        elif bingo[0][2] == 0 and bingo[1][1] == 0 and bingo[2][0] == 0:
            print('Yes')
        else:
            print('No')

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

for i in range(N):
  t = int(input())
  
  for y in range(3):
    for x in range(3):
      if A[y][x] == t:
        B[y][x] = True
      
for y in range(3):
  if B[y][0] == B[y][1] == B[y][2] == True:
    ans = 'Yes'
  
for x in range(3):
  if B[0][x] == B[1][x] == B[2][x] == True:
    ans = 'Yes'
    
if B[0][0] == B[1][1] == B[2][2] == True:
  ans = 'Yes'
  
if B[0][2] == B[1][1] == B[2][0] == True:
  ans = 'Yes' 

print(ans)

Solution (Python):
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
b = []
for _ in range(int(input())):
    b.append(int(input()))
if (a[0][0] in b and a[0][1] in b and a[0][2] in b) or\
   (a[1][0] in b and a[1][1] in b and a[1][2] in b) or\
   (a[2][0] in b and a[2][1] in b and a[2][2] in b) or\
   (a[0][0] in b and a[1][0] in b and a[2][0] in b) or\
   (a[0][1] in b and a[1][1] in b and a[2][1] in b) or\
   (a[0][2] in b and a[1][2] in b and a[2][2] in b) or\
   (a[0][0] in b and a[1][1] in b and a[2][2] in b) or\
   (a[0][2] in b and a[1][1] in b and a[2][0] in b):
    print('Yes')
else:
    print('No')

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


for _ in range(n):
    b = int(input())
    for row in range(3):
        for col in range(3):
            if b == card[row][col]:
                card[row][col] = 0

result = "No"

for i in range(3):
    if card[i][0] == 0 and card[i][1] == 0 and card[i][2] == 0:
        result = "Yes"
        break
    if card[0][i] == 0 and card[1][i] == 0 and card[2][i] == 0:
        result = "Yes"
if result == "No":
    if card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0:
        result = "Yes"
    elif card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0:
        result = "Yes"

print(result)

Solution (Python):

def b(al , n , nl):

    ans = "No"

    n = [[False]*3 for i in range(3)]

    for i in range(3):
        for w in range(3):
            if al[i][w] in nl:
                n[i][w] = True
    
    for i in range(3):
        if n[i][0] == True and n[i][1] == True and n[i][2] == True:
            ans = "Yes"
    
    for i in range(3):
        if n[0][i] == True and n[1][i] == True and n[2][i] == True:
            ans = "Yes"
    
    if n[0][0] == True and n[1][1] == True and n[2][2] == True:
        ans = "Yes"
    if n[0][2] == True and n[1][1] == True and n[2][0] == True:
        ans = "Yes"

    return ans

def main():
    al = [list(map(int , input().split())) for i in range(3)]
    n = int(input())
    nl = [int(input()) for i in range(n)]
    print(b(al , n , nl))

if __name__ == '__main__':
    main()

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

L = []
for i in range(3):
    L.append(A[i])
for j in range(3):
    L.append([])
    for i in range(3):
        L[-1].append(A[i][j])

if [0, 0, 0] in L:
    ans = "Yes"
elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    ans = "Yes"
elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    ans = "Yes"
else:
    ans = "No"
print(ans)

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



N = int(input())
ans = [[0] * 3 for i in range(3)]

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

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

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

if A[0][0] in b and A[0][1] in b and A[0][2] in b:
    ok = True
elif A[1][0] in b and A[1][1] in b and A[1][2] in b:
    ok = True
elif A[2][0] in b and A[2][1] in b and A[2][2] in b:
    ok = True
elif A[0][0] in b and A[1][0] in b and A[2][0] in b:
    ok = True
elif A[0][1] in b and A[1][1] in b and A[2][1] in b:
    ok = True
elif A[0][2] in b and A[1][2] in b and A[2][2] in b:
    ok = True
elif A[0][0] in b and A[1][1] in b and A[2][2] in b:
    ok = True
elif A[0][2] in b and A[1][1] in b and A[2][0] in b:
    ok = True
    
if ok:
    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)]
for i in range(3):
    bng = 1
    for j in range(3):
        if A[i][j] in B:
            continue
        else:
            bng = 0
            break
    if bng ==1:break
if bng==1:
    print("Yes")
else:
    for j in range(3):
        bng = 1
        for i in range(3):
            if A[i][j] in B:
                continue
            else:
                bng = 0
                break
        if bng==1:break
    if bng==1:
        print("Yes")
    else:
        if A[0][0] in B and A[1][1] in B and A[2][2] in B:
            print("Yes")
        elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
            print("Yes")
        else:
            print("No")

Solution (Python):
Row = [[int(i) for i in input().split()] for j in range(3)]
Hole = [[False,False,False] for i in range(3)]

N=int(input())
B = [int(input()) for n in range(N)]
for b in B:
    for r,row in enumerate(Row):
        for c,num in enumerate(row):
            if num==b:
                Hole[r][c] = True


Column = [[Hole[x][y] for x in range(3)] for y in range(3)]
Naname = [[Hole[x][x] for x in range(3)],[Hole[y][2-y] for y in range(3)]]
for c in Column:
    if all(c):print("Yes");exit()
for c in Hole:
    if all(c):print("Yes");exit()
for c in Naname:
    if all(c):print("Yes");exit()
print("No")

Solution (Python):


import sys

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

c = [[False for x in range(3)] for y in range(3)]

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

for s in b:
    for i, line in enumerate(a):
        for j, num in enumerate(line):
            if num == s:
                c[i][j] = True

for line in c:
    if all(line):
        print("Yes")
        sys.exit()

for i in range(3):
    if all([c[0][i], c[1][i], c[2][i]]):
        print("Yes")
        sys.exit()

if all([c[0][0], c[1][1], c[2][2]]):
    print("Yes")
    sys.exit()

if all([c[0][2], c[1][1], c[2][0]]):
    print("Yes")
    sys.exit()

print("No")

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

ans_list = [0 for _ in range(9)]

import itertools

a_list_flat = list(itertools.chain.from_iterable(a_list))

for i in range(9):
    for j in range(n):
        if a_list_flat[i] == b_list[j]:
            ans_list[i] = 1

count = 0
if ans_list[0] + ans_list[1] + ans_list[2] == 3:
    count += 1
elif ans_list[3] + ans_list[4] + ans_list[5] == 3:
    count += 1
elif ans_list[6] + ans_list[7] + ans_list[8] == 3:
    count += 1
elif ans_list[0] + ans_list[3] + ans_list[6] == 3:
    count += 1
elif ans_list[1] + ans_list[4] + ans_list[7] == 3:
    count += 1
elif ans_list[2] + ans_list[5] + ans_list[8] == 3:
    count += 1
elif ans_list[0] + ans_list[4] + ans_list[8] == 3:
    count += 1
elif ans_list[2] + ans_list[4] + ans_list[6] == 3:
    count += 1

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

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a = []
a.append(li())
a.append(li())
a.append(li())

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

n = ii()
b = []
for i in range(n):
    b = ii()

    for j in range(3):
        for k in range(3):
            if(a[j][k] == b):
                c[j][k] = 1
                break

clr_flg = 0
for j in range(3):
    if(sum(c[j]) == 3):
        clr_flg = 1


for j in range(3):
    if((c[0][j]+c[1][j]+c[2][j]) == 3):
        clr_flg = 1


if((c[0][0]+c[1][1]+c[2][2]) == 3):
    clr_flg = 1
if((c[2][0]+c[1][1]+c[0][2]) == 3):
    clr_flg = 1

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

Solution (Python):
import sys
A=[]

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

ans=[[0,0,0] for i in range(3)]


for n,a in enumerate(A):
    for i in b:
        if(a[0]==i):
            ans[n][0]=1
        if(a[1]==i):
            ans[n][1]=1
        if(a[2]==i):
            ans[n][2]=1

ans1=ans[0]
ans2=ans[1]
ans3=ans[2]

for a in ans:
    if(a[0]==1 and a[1]==1 and a[2]==1):
        print('Yes')
        sys.exit()

for i in range(3):
    if(ans1[i]==1 and ans2[i]==1 and ans3[i]==1):
        print('Yes')
        sys.exit()

if(ans1[0]==1 and ans2[1]==1 and ans3[2]==1):
    print('Yes')
    sys.exit()
if(ans1[2]==1 and ans2[1]==1 and ans3[0]==1):
    print('Yes')
    sys.exit()

print('No')

Solution (Python):

import sys

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

N = int(input())

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

for b in B:
    for i in range(len(A)):
        for j in range(len(A[i])):
            if A[i][j][0] == b:
                A[i][j][1] = True
                break


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


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


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

print('No')

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

for n in NUMS:
    for i in range(3):
        for j in range(3):
            if BINGO[i][j] == n:
                BINGO[i][j] = 0
    
res = 1000000
for i in range(3):
    res = min(res, sum(BINGO[i]))

for j in range(3):
    col = 0
    for i in range(3):
        col += BINGO[i][j] 
    res = min(res, col)

res = min(res, BINGO[0][0]+ BINGO[1][1]+ BINGO[2][2])
res = min(res, BINGO[0][2]+BINGO[1][1]+BINGO[2][0])

print("Yes" if res == 0 else "No")

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

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

A = [False, False, False]
B = [False, False, False]
C = [False, False, False]

N = int(input())



for i in range(N):
    t = int(input())
    for j in range(3):
        if t == a[j]:
            A[j] = True
        if t == b[j]:
            B[j] = True
        if t == c[j]:
            C[j] = True

if (A[0] and A[1] and A[2]) or (B[0] and B[1] and B[2]) or (C[0] and C[1] and C[2]) or (A[0] and B[0] and C[0]) or (A[1] and B[1] and C[1]) or (A[2] and B[2] and C[2]) or (A[0] and B[1] and C[2]) or (A[2] and B[1] and C[0]):
    print('Yes')
else:
    print('No')

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
C = A.copy()
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                C[i][j] = -1
flag = False

for i in range(3):
    if C[i][0] == C[i][1] == C[i][2] == -1:
        flag = True


for i in range(3):
    if C[0][i] == C[1][i] == C[2][i] == -1:
        flag = True


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

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

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

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

n = int(input())
checker = [0]*9
for i in range(n):
    bingo = int(input())
    try:
        checker[lst.index(bingo)] = 1
    except:
        pass

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

Solution (Python):

import numpy as np
def main():
  A=[]
  for i in range(3):
    A.append(list(map(int, input().split())))
  N=int(input().split()[0])
  B=[]
  for i in range(N):
    B.append(int(input().split()[0]))

  A= np.array(A)
  A_clear = np.zeros_like(A)
  for b in B:
    A_clear += 1* (A==b)


  bingo_c(A_clear)
  
def bingo_c(arr):
  if (np.sum(arr, axis=0)==3).any():
    print('Yes')
  elif (np.sum(arr, axis=1)==3).any():
    print('Yes')
  elif arr[0,0]+arr[1,1]+arr[2,2]==3:
    print('Yes')
  elif arr[0,2]+arr[1,1]+arr[2,0]==3:
    print('Yes')
  else:
    print('No')
  
if __name__=="__main__":
  main()

Solution (Python):
def check():
    if X[0][0] == X[1][1] == X[2][2] == 'x':
        return 1
    if X[0][2] == X[1][1] == X[2][0] == 'x':
        return 1
    for e in X:
        if len(set(e)) == 1 and e[0] == 'x':
            return 1
    for e in list(zip(*X)):
        if len(set(e)) == 1 and e[0] == 'x':
            return 1
    return 0

A = [list(map(int, input().split())) for _ in range(3)]
X = [['o' for _ in range(3)] for _ in range(3)]
N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                X[i][j] = 'x'
print(["No", "Yes"][check()])

Solution (Python):
A = []
for _ in range(3):
    A.append([int(i) for i in input().split()])
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))
matrix = [[0,0,0],[0,0,0],[0,0,0]]
def check(m):
    for i in range(3):
        if sum(m[i])==3:
            return True
    for ii in range(3):
        if m[0][ii]+m[1][ii]+m[2][ii]==3:
            return True
    if m[0][0] + m[1][1] + m[2][2] == 3:
        return True
    if m[2][0] + m[1][1] + m[0][2] == 3:
        return True
    return False
for b in B:
    for i in range(3):
        for ii in range(3):
            if A[i][ii] == b:
                matrix[i][ii] = 1
print("Yes") if check(matrix) else print("No")

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()])
N=int(input())
b=[int(input()) for _ in range(N)]

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

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    ans = A[0][0] in b and A[1][0] in b and A[2][0] in b
    ans = ans or A[0][1] in b and A[1][1] in b and A[2][1] in b
    ans = ans or A[0][2] in b and A[1][2] in b and A[2][2] in b

    ans = ans or A[0][0] in b and A[0][1] in b and A[0][2] in b
    ans = ans or A[1][0] in b and A[1][1] in b and A[1][2] in b
    ans = ans or A[2][0] in b and A[2][1] in b and A[2][2] in b

    ans = ans or A[0][0] in b and A[1][1] in b and A[2][2] in b
    ans = ans or A[2][0] in b and A[1][1] in b and A[0][2] in b

    if ans:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)


if __name__ == '__main__':
    main()

Solution (Python):
card = [[int(i) for i in input().strip().split()] for _ in range(3)]
n = int(input())
flag = [[False, False, False], [False, False, False], [False, False, False]]

for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == b:
                flag[i][j] = True

is_bingo = any([
    any(all(flag[i][j] for i in range(3)) for j in range(3)),
    any(all(flag[i][j] for j in range(3)) for i in range(3)),
    flag[0][0] and flag[1][1] and flag[2][2],
    flag[2][0] and flag[1][1] and flag[0][2],
])

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

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

for i in range(N):
    b = int(input())
    for x in bingo:
        if x[0] == b:
            x[0] = True
        elif x[1] == b:
            x[1] = True
        elif x[2] == b:
            x[2] = True

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

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

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

print("No")

Solution (Python):





def solv(A, N, B):
    flgs = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    for b in B:
        for i in range(3):
            for j in range(3):
                if b == A[i][j]:
                    flgs[i][j] = 1
    for i in range(3):
        if sum(flgs[i]) == 3:
            return "Yes"
    for j in range(3):
        if flgs[0][j] + flgs[1][j] + flgs[2][j] == 3:
            return "Yes"
    if flgs[0][0] + flgs[1][1] + flgs[2][2] == 3:
        return "Yes"
    if flgs[0][2] + flgs[1][1] + flgs[2][0] == 3:
        return "Yes"
    return "No"


if __name__ == "__main__":

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

    ans = solv(A, N, B)

    print(ans)

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

N = int(input())

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

for i in range(3):
    for j in range(3):

        if A[i][j] in B:
            A[i][j] = -1
Bingo = [
    [[0, 0], [0, 1], [0, 2]],
    [[1, 0], [1, 1], [1, 2]],
    [[2, 0], [2, 1], [2, 2]],
    [[0, 0], [1, 0], [2, 0]],
    [[0, 1], [1, 1], [2, 1]],
    [[0, 2], [1, 2], [2, 2]],
    [[0, 0], [1, 1], [2, 2]],
    [[0, 2], [1, 1], [2, 0]],
]

result = False
for bingo in Bingo:
    count = 0
    for i, j in bingo:
        if A[i][j] == -1:
            count += 1

    if count == 3:
        result = True

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

Solution (Python):
import numpy as np
 
bingo = list()
for i in range(3):
    bingo.append(list(map(int,input().split())))
N = int(input())
number = list()
for i in range(N):
    number.append(int(input()))
   
bingo_array = np.array(bingo)
check_array = np.zeros([3,3])
for i in range(N):
    check_array[bingo_array==number[i]] = 1
 
row = np.count_nonzero(np.any(check_array.sum(axis=0)==3))
column = np.count_nonzero(np.any(check_array.sum(axis=1)==3))
r_naname = 0
l_naname = 0
for i in range(3):
    r_naname += check_array[i, 2-i]
    l_naname += check_array[i, i]
 
if row != 0 or column != 0 or r_naname == 3 or l_naname == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
import itertools

a1, b1, c1 = map(int, input().split())
a2, b2, c2 = map(int, input().split())
a3, b3, c3 = map(int, input().split())

checker = [
(a1,b1,c1),
(a2,b2,c2),
(a3,b3,c3),
(a1,a2,a3),
(b1,b2,b3),
(c1,c2,c3),
(a1,b2,c3),
(c1,b2,a3)
]

N = int(input())

numbers = []
for i in range(N):
  numbers.append(int(input()))
ans="No"
tuples = itertools.permutations(numbers,3)
for i in tuples:
  if i in checker:
    ans = "Yes"
    break
print(ans)

Solution (Python):
def isBingo(card):
    for i in range(3):
        if card[i][0] == card[i][1] and card[i][0] == card[i][2]:
            return True

    for i in range(3):
        if card[0][i] == card[1][i] and card[0][i] == card[2][i]:
            return True

    if(card[1][1] == card[0][0] and card[1][1] == card[2][2]):
        return True
    
    if(card[1][1] == card[0][2] and card[1][1] == card[2][0]):
        return True
    
    return False

bingo_nums = [[0 for i in range(3)] for j in range(3)]

for i in range(3):
    a,b,c = map(int,input().split())
    bingo_nums[i][0] = a
    bingo_nums[i][1] = b
    bingo_nums[i][2] = c


N = int(input())
for i in range(N):
    num = int(input())
    
    for i in range(3):
        for j in range(3):
            if bingo_nums[i][j] == num:
                bingo_nums[i][j] = 0
                break
            
if isBingo(bingo_nums):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

AList = []
BingoList = [[0, 0, 0],
             [0, 0, 0],
             [0, 0, 0]]

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

N = int(input())

tmp = -1
for i in range(N):
    tmp = int(input())
    for p in range(3):
        for q in range(3):
            if AList[p][q] == tmp:
                BingoList[p][q] = 1

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

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

if BingoList[0][0] == 1 and BingoList[1][1] == 1 and BingoList[2][2] == 1:
    print('Yes')
elif BingoList[2][0] == 1 and BingoList[1][1] == 1 and BingoList[0][2] == 1:
    print('Yes')
else:
    print('No')