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):
bg=[]
num=[]
t=0
for i in range(3):
    a=input().split()
    for m in range(3):
        bg.append(int(a[m]))
n=int(input())
for k in range(n):
    num.append(int(input()))
ns=[0,0,0,0,0,0,0,0,0]
for j in range(9):
    if bg[j] in num:
        ns[j]=1
nm=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for l in nm:
    if ns[l[0]]+ns[l[1]]+ns[l[2]]==3:
        t=1
        break
if t==0:
    print("No")
else:
    print("Yes")

Solution (Python):
a = []
for i in range(3):
    a.append([int(x) for x in input().split()])
bing = [[0]*3,[0]*3,[0]*3]

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

for b in bs:
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                bing[i][j]=1



def isbingo(board):
    for i in range(3):
        if sum(board[i])==3:
            return True
    for j in range(3):
        if sum([board[i][j] for i in range(3)])==3:
            return True
    if sum([board[0][0],board[1][1],board[2][2]])==3:
        return True
    if sum([board[0][2],board[1][1],board[2][0]])==3:
        return True
    return False
print('Yes'if isbingo(bing) else 'No')

Solution (Python):
a = []
for _ in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
card = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(3):
    for j in range(3):
        for x in b:
            if a[i][j] == x:
                card[i][j] = True
                break
l = [["00","01","02"],["10","11","12"],["20","21","22"],["00","10","20"],["01","11","21"],["02","12","22"],["00","11","22"],["02","11","20"]]
ans = False
for p in l:
    tmp = 0
    for q in p:
        i = int(q[0])
        j = int(q[1])
        if card[i][j]:
            tmp += 1
    if tmp == 3:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

list_ = set(a+b+c)
n = int(input())

a = np.array([a, b, c])

for _ in range(n):
  x = int(input())
  if x in list_:
    a = np.where(a==x,0,a)

if np.sum(a==0) < 3:
  print('No')
  quit()

for i in range(3):
  if sum(a[:,i]) == 0:
    print('Yes')
    quit()

for i in range(3):
  if sum(a[i,:]) == 0:
    print('Yes')
    quit()

if a[0,0]+a[1,1]+a[2,2] == 0 or a[0,2]+a[1,1]+a[2,0] == 0:
  print('Yes')
  quit()

print('No')

Solution (Python):
import sys
a = [0]*3
for i in range(3):
    a[i] = list(map(int,input().split()))
n = int(input())
b = [0 for _ in range(n)]
for k in range(n):
    b[k] = int(input())
flag = [[0 for u in range(3)]for r in range(3)]

for j in range(3):
    for l in range(3):
        for v in range(n):
            if(a[j][l] == b[v]):
                flag[j][l] = 1
                break

for h in range(3):
    if(sum(flag[h]) == 3):
      print("Yes")
      sys.exit()

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

if(flag[0][0] + flag[1][0] + flag[2][0] == 3 or flag[0][1] + flag[1][1] + flag[2][1] == 3 or flag[0][2] + flag[1][2] + flag[2][2] == 3):
    print("Yes")
    sys.exit()
print("No")

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

for i in range(3):
    for j in range(3):
        for k in b:
            if a[j][i] == k:
                a[j][i] = 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[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    print("Yes")
    exit()
print("No")

Solution (Python):
A=[input().split() for i in range(3)]
N=int(input())
b=[0]*N
for i in range(N):
    b[i]=int(input())
    
for i in range(3):
    for j in range(3):
        for k in range(N):
            if int(A[i][j])-b[k]==0:
                A[i][j]=0

flag=0    
if A[0][0]==0 and A[0][1]==0 and A[0][2]==0:
    flag+=1
elif A[0][0]==0 and A[1][0]==0 and A[2][0]==0:
    flag+=1
elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    flag+=1
elif A[0][1]==0 and A[1][1]==0 and A[2][1]==0:
    flag+=1
elif A[0][2]==0 and A[1][2]==0 and A[2][2]==0:
    flag+=1
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    flag+=1
elif A[1][0]==0 and A[1][1]==0 and A[1][2]==0:
    flag+=1
elif A[2][0]==0 and A[2][1]==0 and A[2][2]==0:
    flag+=1

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

Solution (Python):
def func(x):
  for i in range(3):
    if len([x[i][j] for j in [0,1,2] if x[i][j]])==3:
      return True
    elif len([x[j][i] for j in [0,1,2] if x[j][i]])==3:
      return True
  if len([x[i][i] for i in [0,1,2] if x[i][i]])==3:
    return True
  elif len([x[i][j] for i,j in zip([0,1,2],[2,1,0]) if x[i][j]])==3:
    return True
  else:
    False
    
x = [[False]*3 for i in range(3)]
A = []
for _ in range(3): A += list(map(int, input().split()))
N = int(input())
for i in range(N):
  b = int(input())
  if b in A:
    i = A.index(b)
    j,k = i%3, i//3
    x[k][j] = True
  if func(x):
    print("Yes")
    break
else:
  print("No")

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

temp = False
temp = temp or (A[0] + A[1] + A[2]) == 0
temp = temp or (A[3] + A[4] + A[5]) == 0
temp = temp or (A[6] + A[7] + A[8]) == 0
temp = temp or (A[0] + A[3] + A[6]) == 0
temp = temp or (A[1] + A[4] + A[7]) == 0
temp = temp or (A[2] + A[5] + A[8]) == 0
temp = temp or (A[0] + A[4] + A[8]) == 0
temp = temp or (A[2] + A[4] + A[6]) == 0

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

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

for b in B:
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                A[row][col] = 0

cond = [
    A[0][0] == A[0][1] and A[0][1] == A[0][2],
    A[1][0] == A[1][1] and A[1][1] == A[1][2],
    A[2][0] == A[2][1] and A[2][1] == A[2][2],
    A[0][0] == A[1][0] and A[1][0] == A[2][0],
    A[0][1] == A[1][1] and A[1][1] == A[2][1],
    A[0][2] == A[1][2] and A[1][2] == A[2][2],
    A[0][0] == A[1][1] and A[1][1] == A[2][2],
    A[0][2] == A[1][1] and A[1][1] == A[2][0]
]
print('Yes' if any(cond) else 'No')

Solution (Python):
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
int_list=[int(input()) for i in range(n)]

check = [0]*9
tmp = 0

for j in range(3):
    for i in range(n):
        if(int_list[i] == a1[j]):
                check[tmp] = 1
    tmp += 1

for j in range(3):
    for i in range(n):
        if(int_list[i] == a2[j]):
                check[tmp] = 1
    tmp += 1

for j in range(3):
    for i in range(n):
        if(int_list[i] == a3[j]):
                check[tmp] = 1
    tmp += 1

test = 0

if(check[0] == 1 and check[1] == 1 and check[2] == 1):
        test = 1
if(check[3] == 1 and check[4] == 1 and check[5] == 1):
        test = 1
if(check[6] == 1 and check[7] == 1 and check[8] == 1):
        test = 1
if(check[0] == 1 and check[3] == 1 and check[6] == 1):
        test = 1
if(check[1] == 1 and check[4] == 1 and check[7] == 1):
        test = 1
if(check[2] == 1 and check[5] == 1 and check[8] == 1):
        test = 1
if(check[0] == 1 and check[4] == 1 and check[8] == 1):
        test = 1
if(check[2] == 1 and check[4] == 1 and check[6] == 1):
        test = 1


if(test == 1):
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
first = [int(item) for item in input().split()]
second = [int(item) for item in input().split()]
third = [int(item) for item in input().split()]

grid = np.array([first, second, third])


N = int(input())

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


flg_list = [0,0,0]

is_bingo = False

for i in range(3):
    flg_list = [0,0,0]
    for j in range(3):
        if grid[i,j] in num_list:
            flg_list[j] = 1

    if flg_list == [1,1,1]:
        is_bingo = True

for i in range(3):
    flg_list = [0,0,0]
    for j in range(3):
        if grid[j,i] in num_list:
            flg_list[j] = 1

    if flg_list == [1,1,1]:
        is_bingo = True


flg_list = [0,0,0]
for i in range(3):
    if grid[i,i] in num_list:
        flg_list[i] = 1

    if flg_list == [1,1,1]:
        is_bingo = True

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

    if grid[2-i,i] in num_list:
        flg_list[i] = 1

    if flg_list == [1,1,1]:
        is_bingo = True

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

Solution (Python):
l=[]
for i in range(3):
  a1,a2,a3=map(int,input().split())
  l.append(a1)
  l.append(a2)
  l.append(a3)
n=int(input())
for i in range(n):
  try:
    ind=l.index(int(input()))
    l[ind]=0
  except:
    pass
for i in range(0,9,3):
  if l[i+0]==l[i+1]==l[i+2]==0:
    print('Yes')
    exit(0)
for i in range(3):
  if l[i]==l[i+3]==l[i+6]==0:
    print('Yes')
    exit(0)
if l[0]==l[4]==l[8]==0:
  print('Yes')
  exit(0)
if l[2]==l[4]==l[6]==0:
  print('Yes')
  exit(0)
print('No')

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

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
S = [[False, False, False], [False, False, False], [False, False, False]]
N = int(input())
for _ in range(N):
    B = int(input())
    
    if B in A[0]:
        S[0][A[0].index(B)] = True
    elif B in A[1]:
        S[1][A[1].index(B)] = True
    elif B in A[2]:
        S[2][A[2].index(B)] = True

if S[0][0] and S[0][1] and S[0][2] or \
    S[1][0] and S[1][1] and S[1][2] or \
    S[2][0] and S[2][1] and S[2][2] or \
    S[0][0] and S[1][0] and S[2][0] or \
    S[0][1] and S[1][1] and S[2][1] or \
    S[0][2] and S[1][2] and S[2][2] or \
    S[0][0] and S[1][1] and S[2][2] or \
    S[0][2] and S[1][1] and S[0][2]:
    print('Yes')
else:
    print('No')

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [[0 for i in range(3)] for j in range(3)]
for i in range(N):
  a = int(input())
  for m in range(3):
    for n in range(3):
      if a == A[m][n]:
        B[m][n] = 1
p = 'No'
for i in range(3):
  cnt1 = 0
  cnt2 = 0
  for j in range(3):
    if B[i][j] == 1:
      cnt1 += 1
    if B[j][i] == 1:
      cnt2 += 1
  if cnt1 == 3 or cnt2 == 3:
    p = 'Yes'
    break
cnt3, cnt4 = 0, 0
for i in range(3):
  if B[i][i] == 1:
    cnt3 += 1
  if B[i][2-i] == 1:
    cnt4 += 1
if cnt3 == 3 or cnt4 == 3:
  p = 'Yes'
print(p)

Solution (Python):
ans = []
A = [int(i) for i  in input().split()] + [int(i) for i  in input().split()] + [int(i) for i  in input().split()]
A = {v:i for i, v in enumerate(A)}
N = int(input())
for i in range(N):
    b = int(input())
    if b in A.keys():
        ans.append(A[b])
        
if ((0 in ans) and (1 in ans) and (2 in ans)) or\
((3 in ans) and (4 in ans) and (5 in ans)) or\
((6 in ans) and (7 in ans) and (8 in ans)) or\
((0 in ans) and (3 in ans) and (6 in ans)) or\
((1 in ans) and (4 in ans) and (7 in ans)) or\
((2 in ans) and (5 in ans) and (8 in ans)) or\
((0 in ans) and (4 in ans) and (8 in ans)) or\
((2 in ans) and (4 in ans) and (6 in ans)):
    print('Yes')
else:
    print('No')

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


def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    a = [[False] * 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 A[i][j] == b:
                    a[i][j] = True
    for i in range(3):
        if all(a[i]):
            print("Yes")
            return
    for j in range(3):
        if all([a[0][j], a[1][j], a[2][j]]):
            print("Yes")
            return
    if a[0][0] and a[1][1] and a[2][2]:
        print("Yes")
        return
    if a[0][2] and a[1][1] and a[2][0]:
        print("Yes")
        return
    print("No")


if __name__ == "__main__":
    main()

Solution (Python):
ary = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
while n > 0:
    num = int(input())
    if num == a1[0]:
        ary[0][0] = 1
    if num == a1[1]:
        ary[0][1] = 1
    if num == a1[2]:
        ary[0][2] = 1
    if num == a2[0]:
        ary[1][0] = 1
    if num == a2[1]:
        ary[1][1] = 1
    if num == a2[2]:
        ary[1][2] = 1
    if num == a3[0]:
        ary[2][0] = 1
    if num == a3[1]:
        ary[2][1] = 1
    if num == a3[2]:
        ary[2][2] = 1
    n = n - 1
if (ary[0][0] == 1 and ary[0][1] == 1 and ary[0][2] == 1) or\
   (ary[1][0] == 1 and ary[1][1] == 1 and ary[1][2] == 1) or\
   (ary[2][0] == 1 and ary[2][1] == 1 and ary[2][2] == 1) or\
   (ary[0][0] == 1 and ary[1][0] == 1 and ary[2][0] == 1) or\
   (ary[0][1] == 1 and ary[1][1] == 1 and ary[2][1] == 1) or\
   (ary[0][2] == 1 and ary[1][2] == 1 and ary[2][2] == 1) or\
   (ary[0][0] == 1 and ary[1][1] == 1 and ary[2][2] == 1) or\
   (ary[0][2] == 1 and ary[1][1] == 1 and ary[2][0] == 1):
    print('Yes')
else:
    print('No')

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A = [list(map(int, input().split())) for _ in [0] * 3]
    N = int(input())
    B = [int(input()) for _ in [0] * N]

    for i, (a1, a2, a3) in enumerate(A):
        if a1 in B:
            A[i][0] = 0
        if a2 in B:
            A[i][1] = 0
        if a3 in B:
            A[i][2] = 0
    for a in A:
        if not sum(a):
            print('Yes')
            return
    for i in range(3):
        a = [A[0][i], A[1][i], A[2][i]]
        if not sum(a):
            print('Yes')
            return
    if any((A[0][0] == A[1][1] == A[2][2] == 0,
            A[0][2] == A[1][1] == A[2][0] == 0)):
            print('Yes')
            return
    print('No')


main()

Solution (Python):
import itertools

bingo = []

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

bingo = list(itertools.chain.from_iterable(bingo))

bingo_bi = [False for _ in range(9)]

n = int(input())

nums = []

for _ in range(n):
    num = int(input())
    if num in bingo:
        bingo_bi[bingo.index(num)] = True

correct = [True, True, True]

if bingo_bi[0:3] == correct or bingo_bi[3:6] == correct or bingo_bi[6:9] == correct:
    print('Yes')
elif bingo_bi[0::3] == correct or bingo_bi[1::3] == correct or bingo_bi[2::3] == correct:
    print('Yes')
elif bingo_bi[0] == True and bingo_bi[4] == True and bingo_bi[8] == True:
    print('Yes')
elif bingo_bi[2:8:2] == correct:
    print('Yes')
else:
    print('No')

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

ans = []
for i in range(3):
    a = [A1[i],A2[i],A3[i]]
    ans.append(a)
ans.append(A1)
ans.append(A2)
ans.append(A3)
ans.append([A1[0],A2[1],A3[2]])
ans.append([A3[0],A2[1],A1[2]])

for i in range(len(ans)):
    for j in range(N):
        if B[j] in ans[i]:
            ans[i].remove(B[j])


if [] in ans:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    A = [int(e) for e in input().split()]
    A.extend([int(e) for e in input().split()])
    A.extend([int(e) for e in input().split()])
    n = int(input())
    B = [int(input()) for i in range(n)]

    S = set()
    for ai, a in enumerate(A):
        if a in B:
          S.add(ai + 1)

    bingo = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7]]
    for bi in bingo:
        if S.issuperset(set(bi)):
            print('Yes')
            exit()

    print('No')

if __name__ == "__main__":
    main()

Solution (Python):
lis1 = list(map(str, input().split()))
lis2 = list(map(str, input().split()))
lis3 = list(map(str, input().split()))
n = int(input())
lisn = [input() for i in range(n)]
for i in lisn:
    if i in lis1:
        lis1[lis1.index(i)] = 1000
    if i in lis2:
        lis2[lis2.index(i)] = 1000
    if i in lis3:
        lis3[lis3.index(i)] = 1000
if lis1.count(1000)==3 or lis2.count(1000)==3 or lis3.count(1000)==3 or (lis1[0]==1000 and lis2[0]==1000 and lis3[0]==1000) or (lis1[1]==1000 and lis2[1]==1000 and lis3[1]==1000) or (lis1[2]==1000 and lis2[2]==1000 and lis3[2]==1000) or (lis1[0]==1000 and lis2[1]==1000 and lis3[2]==1000) or (lis1[2]==1000 and lis2[1]==1000 and lis3[0]==1000):
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

def check(A):
    for i in range(3):
        if A[i,0] == 0 and A[i,1] == 0 and A[i,2] == 0:
            return True
        if A[0,i] == 0 and A[1,i] == 0 and A[2,i] == 0:
            return True
    if A[0,0] == 0 and A[1,1] == 0 and A[2,2] == 0:
        return True
    if A[0,2] == 0 and A[1,1] == 0 and A[2,0] == 0:
        return True

    return False



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

for i in range(N):
    for m in range(3):
        for n in range(3):
            if b[i] == A[m,n]:
                A[m,n] = 0

if check(A):
    print("Yes")
else:
    print("No")

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

for i in range(n):
  a = int(input())
  if a in m:
    m[m.index(a)] = 0
    
if ((m[0] + m[1] + m[2]) == 0) or ((m[3] + m[4] + m[5]) == 0) or ((m[6] + m[7] + m[8]) == 0) or ((m[0] + m[3] + m[6]) == 0) or ((m[1] + m[4] + m[7]) == 0) or ((m[2] + m[5] + m[8]) == 0) or ((m[0] + m[4] + m[8]) == 0) or ((m[2] + m[4] + m[6]) == 0):
  print("Yes")
else:
  print("No")

Solution (Python):
bingo_list=[list(map(int,input().split())) for i in range(3)]
n = int(input())
number_li=[int(input()) for i in range(n)]
ans = "No"

for i in range(len(bingo_list)):
    for j in number_li:
        if j in bingo_list[i]:
            bingo_list[i][bingo_list[i].index(j)] = "x"

for k in range(len(bingo_list)):
    if bingo_list[0][k] == bingo_list[1][k] == bingo_list[2][k]:
        ans = "Yes"
for l in bingo_list:
    if l[0] == l[1] == l[2]:
        ans = "Yes"
if bingo_list[0][0] == bingo_list[1][1] == bingo_list[2][2]:
    ans = "Yes"
if bingo_list[0][2] == bingo_list[1][1] == bingo_list[2][0]:
    ans = "Yes"
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())
for i in range(N):
    ii=int(input())
    if ii in A1:
        A1[A1.index(ii)]=0
    if ii in A2:
        A2[A2.index(ii)]=0
    if ii in A3:
        A3[A3.index(ii)]=0
ans="No"
l=[0,0,0]
if A1[0]==0 and A2[1]==0 and A3[2]==0:
    ans="Yes"
elif A1[2]==0 and A2[1]==0 and A3[0]==0:
    ans="Yes"
elif A1==l or A2==l or A3==l:
    ans="Yes"
elif A1[0]==0 and A2[0]==0 and A3[0]==0:
    ans="Yes"
elif A1[1]==0 and A2[1]==0 and A3[1]==0:
    ans="Yes"
elif A1[2]==0 and A2[2]==0 and A3[2]==0:
    ans="Yes"
print(ans)

Solution (Python):
R1 = list(map(int, input().split(" ")))
R2 = list(map(int, input().split(" ")))
R3 = list(map(int, input().split(" ")))
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        if R1[j] == b:
            R1[j] = 0
        if R2[j] == b:
            R2[j] = 0
        if R3[j] == b:
            R3[j] = 0
C1 = [R1[0], R2[0], R3[0]]
C2 = [R1[1], R2[1], R3[1]]
C3 = [R1[2], R2[2], R3[2]]
D1 = [R1[0], R2[1], R3[2]]
D2 = [R1[2], R2[1], R3[0]]

judge = "No"
if R1[0] == 0 and R1[1] == 0 and R1[2] == 0:
    judge = "Yes"
if R2[0] == 0 and R2[1] == 0 and R2[2] == 0:
    judge = "Yes"
if R3[0] == 0 and R3[1] == 0 and R3[2] == 0:
    judge = "Yes"
if C1[0] == 0 and C1[1] == 0 and C1[2] == 0:
    judge = "Yes"
if C2[0] == 0 and C2[1] == 0 and C2[2] == 0:
    judge = "Yes"
if C3[0] == 0 and C3[1] == 0 and C3[2] == 0:
    judge = "Yes"
if D1[0] == 0 and D1[1] == 0 and D1[2] == 0:
    judge = "Yes"
if D2[0] == 0 and D2[1] == 0 and D2[2] == 0:
    judge = "Yes"
print(judge)

Solution (Python):
a=[[] for i in range(3)]
a[0]=list(map(int,input().split()))
a[1]=list(map(int,input().split()))
a[2]=list(map(int,input().split()))
dic={}
for i in range(3):
    for j in range(3):
        dic[a[i][j]]=0
n=int(input())
for i in range(n):
    b=int(input())
    if b in dic:
        dic[b]=1

def ans():
    for i in range(3):
        y=0
        t=0
        for j in range(3):
            if dic[a[i][j]]:
                y+=1
                
            if dic[a[j][i]]:
                t+=1
        if y==3 or t==3:
            print("Yes")
            return
    if dic[a[0][0]]+dic[a[1][1]]+dic[a[2][2]]==3 or dic[a[0][2]]+dic[a[1][1]]+dic[a[2][0]]==3:
        print("Yes")
        return
    print("No")
    
ans()

Solution (Python):
l1 = input().split()
l2 = input().split()
l3 = input().split()
n = int(input())
b = [input() for _ in range(n)]
if l1[0] in b and l1[1] in b and l1[2] in b:
    print('Yes')
elif l2[0] in b and l2[1] in b and l2[2] in b:
    print('Yes')
elif l3[0] in b and l3[1] in b and l3[2] in b:
    print('Yes')
elif l1[0] in b and l2[0] in b and l3[0] in b:
    print('Yes')
elif l1[1] in b and l2[1] in b and l3[1] in b:
    print('Yes')
elif l1[2] in b and l2[2] in b and l3[2] in b:
    print('Yes')
elif l1[0] in b and l2[1] in b and l3[2] in b:
    print('Yes')
elif l1[2] in b and l2[1] in b and l3[0] in b:
    print('Yes')
else:
    print('No')

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

ans = "No"
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j] = "x"
      
if (a[0][0]==a[1][1]==a[2][2]=="x") or (a[2][0]==a[1][1]==a[0][2]=="x"):
  print("Yes")
  exit()
  
if (a[0][0]==a[1][0]==a[2][0]=="x")or(a[0][1]==a[1][1]==a[2][1]=="x")or(a[0][2]==a[1][2]==a[2][2]=="x"):
  print("Yes")
  exit()
  
if (a[0][0]==a[0][1]==a[0][2]=="x")or(a[1][0]==a[1][1]==a[1][2]=="x")or(a[2][0]==a[2][1]==a[2][2]=="x"):
  print("Yes")
  exit()
  
  
print(ans)

Solution (Python):
import numpy as np
a = []
for _ in range(3):
  a_ = list(map(int, input().split()))
  a=a+a_
c = [0]*9
n = int(input())
for _ in range(n):
  b = int(input())
  if b in a:
    c[a.index(b)]=1
c = np.reshape(c, [3,3])
if 3 in np.sum(c, axis=0):
  print("Yes")
elif 3 in np.sum(c, axis=1):
  print("Yes")
elif c[0][0]+c[1][1]+c[2][2]==3 or c[0][2]+c[1][1]+c[2][0]==3:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]




import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]




arr=[]
for i in range(3):
    mm=limii()
    arr.append(mm)

n=ii()

b=lin(n)

for i in range(3):
    for j in range(3):
        if arr[i][j] in b:
            arr[i][j]=0
chk=False

for i in range(3):
    if arr[0][i]==0 and arr[1][i]==0 and arr[2][i]==0:
        chk=True
    elif arr[i][0]==0 and arr[i][1]==0 and arr[i][2]==0:
        chk=True
if arr[0][0] ==0 and arr[1][1]==0 and arr[2][2]==0:
    chk=True
if arr[2][0] ==0 and arr[1][1]==0 and arr[0][2]==0:
    chk=True

if chk==True:
    print("Yes")
else:
    print("No")

Solution (Python):
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
for _ in range(N):
  b = int(input())
  for i in range(3):
    if A1[i] == b:
      A1[i] = 0
  for j in range(3):
    if A2[j] == b:
      A2[j] = 0
  for k in range(3):
    if A3[k] == b:
      A3[k] = 0

if A1[0] == 0:
  if (A1[1]==0 and A1[2]==0) or (A2[0]==0 and A3[0]==0) or (A2[1]==0 and A3[2]==0):
    print('Yes')
    exit()
if A2[0] == 0:
  if (A2[1]==0 and A2[2]==0):
    print('Yes')
    exit()
if A3[0] == 0:
  if (A3[1]==0 and A3[2]==0) or (A2[1]==0 and A1[2]==0):
    print('Yes')
    exit()
if A1[1] == 0:
  if (A2[1]==0 and A3[1]==0):
    print('Yes')
    exit()
if A1[2] == 0:
  if (A2[2]==0 and A3[2]==0):
    print('Yes')
    exit()
print('No')

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

A_all = A1
A_all.extend(A2)
A_all.extend(A3)


N = int(input())


def get_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default
        
for i in range(N):
    b = int(input())
    suffix = get_index(A_all, b)
    if suffix >= 0:
        A_all[suffix] = 0

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

Solution (Python):
a=[]
m=0
for i in range(3):
  b=list(map(int,input().split()))
  a.append(b)
n=int(input())
for i in range(n):
  k=int(input())
  for q in range(3):
    for p in range(3):
      if a[q][p]==k:
        a[q][p]=0
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    print("Yes")
    m+=1
    break
  if a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    print("Yes")
    m+=1
    break
  if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    print("Yes")
    m+=1
    break
  if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
    m+=1
    break
if m==0:
  print("No")

Solution (Python):
a_list = []
for i  in range(3):
  a_list.append(list(map(int,input().split())))
n = int(input())
b_list = []
result_list = [[0,0,0] for i in range(3)]
for i in range(n):
  b_list.append(int(input()))
for s in range(3):
  for m in range(3):
    if a_list[s][m] in b_list:
      result_list[s][m] = 1
check = False
if result_list[0][0] == result_list[1][1] and result_list[0][0] == result_list[1][1] and result_list[1][1] ==1:
  check = True
elif result_list[0][2] == result_list[1][1] and result_list[2][0] == result_list[1][1] and result_list[1][1] ==1:
    check = True
elif result_list[0][1] == result_list[0][2] and result_list[0][2] == result_list[0][0] and result_list[0][0] ==1:
    check = True
elif result_list[1][1] == result_list[1][2] and result_list[1][2] == result_list[1][0] and result_list[1][0] ==1:
    check = True 
elif result_list[2][1] == result_list[2][2] and result_list[2][2] == result_list[2][0] and result_list[2][0] ==1:
    check = True
elif result_list[0][0] == result_list[1][0] and result_list[1][0] == result_list[2][0] and result_list[2][0] ==1:
    check = True
elif result_list[0][1] == result_list[1][1] and result_list[1][1] == result_list[2][1] and result_list[2][1] ==1:
    check = True
elif result_list[0][2] == result_list[1][2] and result_list[1][2] == result_list[2][2] and result_list[2][2] ==1:
    check = True
if check == True:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

N = int(input())

card = np.zeros((3, 3))
for i in range(N):
    t = int(input())
    if t in A1:
        card[0][A1.index(t)] = 1
    if t in A2:
        card[1][A2.index(t)] = 1
    if t in A3:
        card[2][A3.index(t)] = 1
f = False
s = np.sum(card, axis=0)
if s[0] == 3 or s[1] == 3 or s[2] == 3:
    f = True

if card[0][0] + card[1][1] + card[2][2] == 3 or card[0][2] + card[1][1] + card[2][0] == 3:
    f = True
s = np.sum(card, axis=1)
if s[0] == 3 or s[1] == 3 or s[2] == 3:
    f = True

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