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


n = int(input())
for _ in range(n):
    x = int(input())
    if x in bingo:
        bingo[x] = 1


b = list(bingo.values())


flg = b[0] * b[1] * b[2]
flg += b[3] * b[4] * b[5]
flg += b[6] * b[7] * b[8]
flg += b[0] * b[3] * b[6]
flg += b[1] * b[4] * b[7]
flg += b[2] * b[5] * b[8]
flg += b[0] * b[4] * b[8]
flg += b[2] * b[4] * b[6]


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

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

def bingo(x):
  a=False
  for s in range(3):
    if sum(x[s])==3:a=True
  
  for h in range(3):
    if x[0][h]+x[1][h]+x[2][h]==3:a=True
      
  if x[0][0]+x[1][1]+x[2][2]==3:a=True
  
  if x[0][2]+x[1][1]+x[2][0]==3:a=True
  
  return a

seen=[[0,0,0] for _ in range(3)]

for _ in range(int(input())):
  a=int(input())
  
  for i in range(3):
    for j in range(3):
      if A[i][j]==a:seen[i][j]=1

ff=bingo(seen)

if ff==True:
  print('Yes')
else:
  print('No')

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

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

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

      if l[i][j] == q[k]:
        l[i][j] = 0
        
      if l[0][0] == 0 and l[0][1] == 0 and l[0][2] == 0:
        print('Yes')
        exit()
      elif l[1][0] == 0 and l[1][1] == 0 and l[1][2] == 0:
        print("Yes")
        exit()
      elif l[2][0] == 0 and l[2][1] == 0 and l[2][2] == 0:
        print("Yes")
        exit()
      elif l[0][0] == 0 and l[1][1] == 0 and l[2][2] == 0:
        print("Yes")
        exit()
      elif l[0][2] == 0 and l[1][1] == 0 and l[2][0] == 0:
        print("Yes")
        exit()
      elif l[0][0] == 0 and l[1][0] == 0 and l[2][0] == 0:
        print("Yes")
        exit()
      elif l[0][1] == 0 and l[1][1] == 0 and l[2][1] == 0:
        print("Yes")
        exit()
      elif l[0][2] == 0 and l[1][2] == 0 and l[2][2] == 0:
        print("Yes")
        exit()

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)]
for k in b:
    for i in a:
        for j in range(3):
            if i[j] == k:
                i[j] = 0
tf1 = sum(a[0])==0 or sum(a[1])==0 or sum(a[2])==0
tf2 = a[0][0] == a[1][0] == a[2][0] or a[0][1] == a[1][1] == a[2][1] or a[0][2] == a[1][2] == a[2][2]
tf3 = a[0][0] == a[1][1] == a[2][2] or a[0][2] == a[1][1] == a[2][0]
tf = tf1 or tf2 or tf3

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

Solution (Python):
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

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

for i in range(3):
    A[i][0],A[i][1],A[i][2] = MI()

N = I()
B = []
for i in range(N):
    B.append(I())

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = True


ans = "No"
for i in range(3):
    if A[0][i] is True and A[1][i] is True and A[2][i] is True:
        ans = "Yes"

    if A[i][0] is True and A[i][1] is True and A[i][2] is True:
        ans = "Yes"
    
if A[0][0] is True and A[1][1] is True and A[2][2] is True:
    ans = "Yes"

if A[2][0] is True and A[1][1] is True and A[0][2] is True:
    ans = "Yes"

print(ans)

Solution (Python):
A=[]
i=0
for l in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B = [int(input()) for i in range(N)]
for C in B:
    for a in range(3):
        for b in range(3):
            if C==A[a][b]:
                A[a][b]=-1

for a in range(3):
    for b in range(3):
        if A[0][b]==A[1][b]==A[2][b]==-1:
            print("Yes")
            i=1
            break
        elif A[a][0]==A[a][1]==A[a][2]==-1:
            print("Yes")
            i=1
            break
        elif A[1][1]==A[2][2]==A[0][0]==-1:
            print("Yes")
            i=1
            break
        elif A[0][2]==A[1][1]==A[2][0]==-1:
            print("Yes")
            i=1
            break
    if i==1:
        break
if i==0:
    print("No")

Solution (Python):
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if  [1,1,1]  in [check_list[:3], check_list[3:6], check_list[6:], check_list[0:7:3], check_list[1:8:3],check_list[2:9:3],check_list[0:9:4],check_list[2:7:2]]:
    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)]

bingo = False


for i in range(3):
  cnt = 0
  for j in range(3):
    if A[i][j] in B:
      cnt += 1
  if cnt == 3:
    bingo = True


for j in range(3):
  Cnt = 0
  for i in range(3):
    if A[i][j] in B:
      Cnt +=  1
  if Cnt == 3:
    bingo = True


cnt = 0
for i in range(3):
  if A [i] [i] in B:
    cnt += 1
if cnt == 3:
  bingo = True
cnt = 0
for i in range(3):
  j = 2 -i
  if A[i][j] in B:
    cnt += 1
if cnt == 3:
  bingo = True
if bingo:
  print("Yes")
else:
  print("No")

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

for i in range(3):
  for j in range(3):
    if bingo[i][j] in num:
      bingo[i][j] = 0

for i in range(3):
  if bingo[i].count(0) == 3:
    print("Yes")
    exit()
  elif bingo[0][i] == 0 and bingo[1][i] == 0 and bingo[2][i] == 0:
    print("Yes")
    exit()
  else:
    pass

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

Solution (Python):
N=[list(map(int,input().split())) for j in range(3)]
M=int(input())
K=[int(input()) for v in range(M)]

for b in range(M):
  for t in range(3):
    for r in range(3):
      if N[t][r]==K[b]:
        N[t][r]=0
for i in range(3):
  if N[i][0]+N[i][1]+N[i][2]==0: 
    print("Yes")
    exit()
  elif N[0][i]+N[1][i]+N[2][i]==0:
    print("Yes")
    exit()
if N[0][0]+N[1][1]+N[2][2]==0:
  print("Yes")
  exit()
elif  N[0][2]+N[1][1]+N[2][0]==0:
  print("Yes")
  exit()
else:
  print("No")

Solution (Python):
import sys
bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
ban = [[False]*3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                ban[i][j] = True
na = []
nb = []
for i in range(3):
    if all(ban[i][j] for j in range(3)) or all(ban[k][i] for k in range(3)):
        print("Yes")
        sys.exit()
    na.append(ban[i][i])
    nb.append(ban[i][2-i])
if all(na) or all(nb):
    print("Yes")
else:
    print("No")

Solution (Python):
L=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for _ in range(N)]
for i in B:
  for j in range(3):
    for k in range(3):
      if i==L[j][k]:
        L[j][k]=0
T=False
for i in range(3):
  if L[i][0]==L[i][1]==L[i][2]:
    T=True
  elif L[0][i]==L[1][i]==L[2][i]:
    T=True
if L[0][0]==L[1][1]==L[2][2] or L[0][2]==L[1][1]==L[2][0]:
  T=True
if T==True:
  print("Yes")
else:
  print("No")

Solution (Python):
row_1 = list(map(int, input().split()))
row_2 = list(map(int, input().split()))
row_3 = list(map(int, input().split()))
N = int(input())
numbers_called = []
for i in range(N):
    b = int(input())
    numbers_called.append(b)

col_1 = [row_1[0], row_2[0], row_3[0]]
col_2 = [row_1[1], row_2[1], row_3[1]]
col_3 = [row_1[2], row_2[2], row_3[2]]
diagonal = [row_1[0], row_2[1], row_3[2]]
anti_diagonal = [row_3[0], row_2[1], row_1[2]]

winning_combinations = [row_1, row_2, row_3, col_1, col_2, col_3, diagonal, anti_diagonal]

is_bingo = False
for combination in winning_combinations:
    
    is_bingo = all([number in numbers_called for number in combination])
    
    if is_bingo:
        break


if is_bingo:
    print('Yes')
else:
    print('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()))

result = []
for i in b:
  for j in range(0, 3):
    for k in range(0, 3):
      if A[j][k] == i:
        A[j][k] = "z"

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

for i in range(0, 3):
  if A[0][i] == z and A[1][i] == z and A[2][i] == z:
    print("Yes")
    exit()
  if A[i][0] == z and A[i][1] == z and A[i][2] == z:
    print("Yes")
    exit()
  
print("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()))

result = []
for i in b:
  for j in range(0, 3):
    for k in range(0, 3):
      if A[j][k] == i:
        A[j][k] = "z"

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

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

Solution (Python):
a = []
for i in range(3):
  d, b, c = map(int, input().split())
  a.append(d)
  a.append(b)
  a.append(c)
for _ in range(int(input())):
  n = int(input())
  if(n in a):
    a[a.index(n)] = 0
retsu = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
frag = False
for i in range(8):
  frag1 = True
  for s in range(3):
    if(a[retsu[i][s]] > 0):
      frag1 = False
  frag = frag1 or frag
if(frag):
  print("Yes")
else:
  print("No")

Solution (Python):
import itertools
import sys

def f_row(L):
  for i in range(3):
    for j in range(3):
      if L[i][j] == False:
        break
      elif j == 2:
        return True
      else:
        continue
  return False

def f_col(L):
  for i in range(3):
    for j in range(3):
      if L[j][i] == False:
        break
      elif j == 2:
        return True
      else:
        continue
  return False
        
def f_rcross(L):
  for i in range(3):
    if L[i][i] == False:
      break
    elif i == 2:
      return True
    else:
      continue
  return False
      
def f_lcross(L):
  for i in range(3):
    if L[i][2-i] == False:
      break
    elif i == 2:
      return True
    else:
      continue
  return False

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

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

for b in B:
  for i, j in itertools.product(range(3), repeat=2):
    if b == A[i][j]:
      L[i][j] = True
      if f_row(L) or f_col(L) or f_rcross(L) or f_lcross(L):
        print('Yes')
        sys.exit()
      break
print('No')

Solution (Python):
import sys

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

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

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

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

print('No')

Solution (Python):
a = [list(map(int, input().split())) 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] = 0

lines = [[a[0][0], a[0][1], a[0][2]],
         [a[1][0], a[1][1], a[1][2]],
         [a[2][0], a[2][1], a[2][2]],
         [a[0][0], a[1][0], a[2][0]],
         [a[0][1], a[1][1], a[2][1]],
         [a[0][2], a[1][2], a[2][2]],
         [a[0][0], a[1][1], a[2][2]],
         [a[0][2], a[1][1], a[2][0]]]

for line in lines:
    if not any(line):
        print('Yes')
        exit()

print('No')

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = [il() for _ in range(3)]
    B = []
    for _ in range(3):
        B.append([False, False, False])

    N = ii()
    for n in range(N):
        b = ii()
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    B[i][j] = True

    for i in range(3):
        if B[i][0] and B[i][1] and B[i][2]:
            print('Yes')
            exit()
    for j in range(3):
        if B[0][j] and B[1][j] and B[2][j]:
            print('Yes')
            exit()
    if (B[0][0] and B[1][1] and B[2][2]) or (B[0][2] and B[1][1] and B[2][0]):
        print('Yes')
        exit()

    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
A = [list(map(int, input().split())) for _ in range(3)]
c = np.zeros_like(A, dtype=bool)
N = int(input())
for _ in range(N):
    b = int(input())
    for i, line in enumerate(A):
        for j, a in enumerate(line):
            if a == b:
                c[i][j] = True
ans = False
for i in range(3):
    if np.all(c[i]):
        ans = True
    elif np.all(c[:,i]):
        ans = True
for k in range(3):
    if not c[k, k]:
        break
else:
    ans = True
for k in range(3):
    if not c[k, 2 -k]:
        break
else:
    ans = True
print('Yes' if ans else 'No')

Solution (Python):
def main():

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

    calls = list(int(input()) for _ in range(n))

    cmap = { }
    for r in range(3):
        for c in range(3):
            cmap[board[r][c]] = (r, c)

    for call in calls:
        if call in cmap:
            r, c = cmap[call]
            board[r][c] = -1

    if (any(all(board[r][c] == -1 for r in range(3)) for c in range(3)) or
        any(all(board[r][c] == -1 for c in range(3)) for r in range(3)) or
        all(board[i][i] == -1 for i in range(3)) or
        all(board[i][2-i] == -1 for i in range(3))):
        print('Yes')
    else:
        print('No')
          
main()

Solution (Python):
if __name__ == '__main__':
	
	
	B = []
	w1 = list(map(int,input().split()))
	w2 = list(map(int,input().split()))
	w3 = list(map(int,input().split()))
	n = int(input())
	A = []
	for i in range(n):
		cmd = int(input())
		A.append(cmd)
	B.append(w1)
	B.append(w2)
	B.append(w3)

	
	h1 = []
	h2 = []
	h3 = []
	h1.append(w1[0])
	h1.append(w2[0])
	h1.append(w3[0])
	h2.append(w1[1])
	h2.append(w2[1])
	h2.append(w3[1])
	h3.append(w1[2])
	h3.append(w2[2])
	h3.append(w3[2])

	B.append(h1)
	B.append(h2)
	B.append(h3)

	
	s1 = []
	s2 = []
	s1.append(w1[0])
	s1.append(w2[1])
	s1.append(w3[2])
	s2.append(w1[2])
	s2.append(w2[1])
	s2.append(w3[0])

	B.append(s1)
	B.append(s2)
	
	setA = set(A)
	cnt = 0
	for k in B:
		setB = set(k)
		
		s_int = setA & setB
		if len(s_int) == 3:
			cnt = 1
			break
	if cnt == 1:
		print("Yes")
	else:
		print("No")

Solution (Python):
import sys

an = []
for i in range(3):
  a = [int(num) for num in input().split()]
  an.append(a)

n = int(input())  

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

for b in number:
  for i in range(3):
    for j in range(3):
      if b == an[i][j]:
        an[i][j] = 0

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

for j in range(3):
  if an[0][j] == an[1][j] and an[0][j] == an[2][j]:
    print("Yes")
    sys.exit()    

if an[0][0] == an[1][1] and an[0][0] == an[2][2]:
  print("Yes")
  sys.exit() 

if an[0][2] == an[1][1] and an[0][2] == an[2][0]:
  print("Yes")
  sys.exit() 
    
print("No")

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

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


if __name__ == '__main__':
    main()

Solution (Python):
al = [list(map(int, input().split())) for i in range(3)]
al = sum(al, [])
n = int(input())
bl = [int(input()) for i in range(n)]
check = [0 for i in range(9)]
 
for b in bl:
    if b in al:
        check[al.index(b)] = 1
 
if [1,1,1] in [check[:3], check[3:6], check[6:], check[0:7:3], check[1:8:3], check[2:9:3], check[0:9:4], check[2:8:2]]:
    print("Yes")
else:
    print("No")

Solution (Python):
A = {}
for i in range(1, 4):
    for j, a in enumerate(map(int, input().split()), 1):
        A[a] = (i,j)

memo = set()

N = int(input())
for _ in range(N):
    b = int(input())
    if b in A:
        memo.add(A[b])

bingo = [
    set([(1,1),(1,2),(1,3)]),
    set([(2,1),(2,2),(2,3)]),
    set([(3,1),(3,2),(3,3)]),
    set([(1,1),(2,1),(3,1)]),
    set([(1,2),(2,2),(3,2)]),
    set([(1,3),(2,3),(3,3)]),
    set([(1,1),(2,2),(3,3)]),
    set([(3,1),(2,2),(1,3)])
]

for b in bingo:
    if len(b.intersection(memo)) == 3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
import sys
card = list(list(map(int,input().split())) for i in range(3))
n = int(input())
for i in range(n):
  x = int(input())
  for j in range(3):
    if x in card[j]:
      card[j]=list(True if s == x else s for s in card[j])
      
for i in range(3):
  if card[i] == [True,True,True]:
    print("Yes")
    sys.exit()
    break
  elif card[0][i]==True and card[1][i]==True and card[2][i] == True:
    print("Yes")
    sys.exit()
    break
if card[0][0]== True and card[1][1]==True and card[2][2]==True:
  print("Yes")
elif card[0][2]==True and card[1][1]== True and  card[2][0] ==True:
  print("Yes")
else:
  print("No")

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

if (a[0][0] in b) and (a[0][1] in b) and (a[0][2] in b):
    print('Yes')
elif (a[1][0] in b) and (a[1][1] in b) and (a[1][2] in b):
    print('Yes')
elif (a[2][0] in b) and (a[2][1] in b) and (a[2][2] in b):
    print('Yes')
elif (a[0][0] in b) and (a[1][0] in b) and (a[2][0] in b):
    print('Yes')
elif (a[0][1] in b) and (a[1][1] in b) and (a[2][1] in b):
    print('Yes')
elif (a[0][2] in b) and (a[1][2] in b) and (a[2][2] in b):
    print('Yes')
elif (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):
a = [list(map(int,input().split())) for A in range(3)]
n = int(input())
for i in range(n) :
    b = int(input())
    for j in range(3) :
        if b in a[j] :
            a[j][a[j].index(b)] = 0
if a[0][0] == a[0][1] == a[0][2] :
    print("Yes")
elif a[1][0] == a[1][1] == a[1][2] :
    print("Yes")
elif a[2][0] == a[2][1] == a[2][2] :
    print("Yes")
elif a[0][0] == a[1][0] == a[2][0] :
    print("Yes")
elif a[0][1] == a[1][1] == a[2][1] :
    print("Yes")
elif a[0][2] == a[1][2] == a[2][2] :
    print("Yes")
elif a[0][0] == a[1][1] == a[2][2] :
    print("Yes")
elif a[2][0] == a[1][1] == a[0][2] :
    print("Yes")
else :
    print("No")

Solution (Python):
A=[[0 for i in range(3)] for j in range(3)]
for i in range(3):
  A[i] = list(map(int,input().split()))
N=int(input())
for i in range(N):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        A[j][k] = 0
bingo=0
sum1=0
sum2=0
sum3=0
sum4=0
sum5=0
for i in range(3):
  if sum(A[i]) == 0:bingo=1
  sum1 += A[i][0]
  sum2 += A[i][1]
  sum3 += A[i][2]
  sum4 += A[i][i]
  sum5 += A[i][2-i]
if 0 in [sum1,sum2,sum3,sum4,sum5]:bingo=1
print(['No','Yes'][bingo])

Solution (Python):
a=[list(map(int,input().split())) for A 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 b==a[j][k]:
        a[j][k]=0

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

Solution (Python):

import numpy
import sys

a = [list(map(int, input().split())) 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] = 0

if sum(a[0]) == 0:
    print("Yes")
    sys.exit()
elif sum(a[1]) == 0:
    print("Yes")
    sys.exit()
elif sum(a[2]) == 0:
    print("Yes")
    sys.exit()
else:
    a_t = numpy.array(a).T
    if sum(a_t[0]) == 0:
        print("Yes")
        sys.exit()
    elif sum(a_t[1]) == 0:
        print("Yes")
        sys.exit()
    elif sum(a_t[2]) == 0:
        print("Yes")
        sys.exit()
    else:
        if a[0][0] + a[1][1] + a[2][2] == 0:
            print("Yes")
            sys.exit()
        elif a[0][2] + a[1][1] + a[2][0] == 0:
            print("Yes")
            sys.exit()
print("No")

Solution (Python):
A = [ [int(x) for x in input().split()] for _ in range(3) ]
N = int(input())
B = set([ int(input()) for _ in range(N) ])
res = "No"
for i in range(3):
    c1 = 0
    c2 = 0
    for j in range(3):
        c1 += 1 if A[i][j] in B else 0
        c2 += 1 if A[j][i] in B else 0
    if c1==3 or c2==3:
        res = "Yes"
if sum([ 1 if A[j][j] in B else 0 for j in range(3) ]) == 3:
    res = "Yes"
if sum([ 1 if A[j][2-j] in B else 0 for j in range(3) ]) == 3:
    res = "Yes"
print(res)

Solution (Python):
a = []

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

for b1 in b:
  for a1 in a:
    if b1 in a1:
      a1[a1.index(b1)] = 0
aa = [[a[0][0],a[1][0],a[2][0]],[a[0][1],a[1][1],a[2][1]],[a[0][2],a[1][2],a[2][2]]]

if a[0].count(0) == 3 or a[1].count(0) == 3 or a[2].count(0) == 3 or aa[0].count(0) == 3 or aa[1].count(0) == 3 or aa[2].count(0) == 3 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):

def list_check(list1, list2):
    return set(list1).issubset(list2)

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

lists = []

bingo = []
N = int(input())
for _ in range(N):
    b = int(input())
    if b in a:
        idx = a.index(b)
        bingo.append(idx)
        

for i in [0,1,2]:
    l = [i,i+3, i+6]
    lists.append(l)

for i in [0,3,6]:
    l = [i,i+1, i+2]
    lists.append(l)

lists.append([0,4,8])
lists.append([2,4,6])


for li in lists:    
    if list_check(li, bingo):
        print('Yes')
        exit()

print('No')

Solution (Python):
def check(A,a,b,c):
  if A[a] == 0:
    if A[b] == 0:
      if A[c] == 0:
        return 1
  return 0

A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
A = A1+A2+A3
for i in range(N):
  b = int(input())
  if b in A:
    A[A.index(b)] = 0
ans = "No"
anslist = []

anslist.append(check(A,0,1,2))
anslist.append(check(A,3,4,5))
anslist.append(check(A,6,7,8))
anslist.append(check(A,0,3,6))
anslist.append(check(A,1,4,7))
anslist.append(check(A,2,5,8))
anslist.append(check(A,0,4,8))
anslist.append(check(A,2,4,6))

if 1 in anslist:
  ans = "Yes"
print(ans)

Solution (Python):


a = list(map(int,input().split()))
b  = list(map(int,input().split()))
c  = list(map(int,input().split()))
box = [a,b,c]

N = int(input())
for i in range(N):
    s = int(input())
    for j in range(3):
        if s == a[j]:
            a[j] = 0
        if s == b[j]:        
            b[j] = 0
        if s == c[j]:        
            c[j] = 0

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

print("No")

Solution (Python):
A = []
a = [1]*9
for i in range(3):
    A += input().split()
n = int(input())
for i in range(n):
    b = input()
    if b in A:
        a[A.index(b)] = 0

for i in range(3):
    if a[3*i] + a[3*i+1] + a[3*i+2] == 0 or a[i] + a[i+3] + a[i+6] == 0:
        print('Yes')
        break
else:
    if a[0] + a[4] + a[8] == 0 or a[2] + a[4] + a[6] ==0:
        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)]
flag=[[0,0,0] for i in range(3)]
for i in range(3):
    for j in range(3):
        flag[i][j]=False
        for k in range(n):
            if a[i][j]==b[k]:
                flag[i][j]=True
for i in range(3):
    if flag[i][0] and flag[i][1] and flag[i][2]:
        print('Yes')
        break
    if flag[0][i] and flag[1][i] and flag[2][i]:
        print('Yes')
        break
    if flag[0][0] and flag[1][1] and flag[2][2]:
        print('Yes')
        break
    if flag[0][2] and flag[1][1] and flag[2][0]:
        print('Yes')
        break
    if i==2:
        print('No')

Solution (Python):
import numpy as np

A = np.asarray([list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))])
n = int(input())
B = []
for _ in range(n):
    B.append(int(input()))

ans = np.zeros((3, 3))


def is_bingo(card) -> bool:
    if card[0, 0] == card[0, 1] == card[0, 2] == 1:
        return True
    if card[1, 0] == card[1, 1] == card[1, 2] == 1:
        return True
    if card[2, 0] == card[2, 1] == card[2, 2] == 1:
        return True
    if card[2, 0] == card[2, 1] == card[2, 2] == 1:
        return True
    if card[0, 0] == card[1, 0] == card[2, 0] == 1:
        return True
    if card[0, 1] == card[1, 1] == card[2, 1] == 1:
        return True
    if card[0, 2] == card[1, 2] == card[2, 2] == 1:
        return True
    if card[0, 0] == card[1, 1] == card[2, 2] == 1:
        return True
    if card[0, 2] == card[1, 1] == card[2, 0] == 1:
        return True
    return False


for b in B:
    if b in A:
        index = np.where(A == b)
        ans[index] = 1
    if is_bingo(ans):
        print('Yes')
        exit()
print('No')

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

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

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

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

val = 0
flag = False

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

val = 0
for i in range(3):
    val += A[i][i]
if val == 0:
    flag = True

val = A[0][2] + A[1][1] + A[2][0]
if val == 0:
    flag = True

for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    
    val = 0
    for j in range(3):
        val += A[j][i]
    if val == 0:
        flag = True

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