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

for i in range(N):
  for j in range(3):
    for k in range(3):
      if B[i] == A[j][k]:
        sheet[j][k] = 1
if sheet[0][0] == 1 and sheet[0][1] == 1 and sheet[0][2] == 1:
  print('Yes')
elif sheet[1][0] == 1 and sheet[1][1] == 1 and sheet[1][2] == 1:
  print('Yes')
elif sheet[2][0] == 1 and sheet[2][1] == 1 and sheet[2][2] == 1:
  print('Yes')
elif sheet[0][0] == 1 and sheet[1][0] == 1 and sheet[2][0] == 1:
  print('Yes')
elif sheet[0][1] == 1 and sheet[1][1] == 1 and sheet[2][1] == 1:
  print('Yes')
elif sheet[0][2] == 1 and sheet[1][2] == 1 and sheet[2][2] == 1:
  print('Yes')
elif sheet[0][0] == 1 and sheet[1][1] == 1 and sheet[2][2] == 1:
  print('Yes')
elif sheet[2][0] == 1 and sheet[1][1] == 1 and sheet[0][2] == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
def Judge(a):
  col=[]
  diag1=0
  diag2=0

  for i in range(3):
    if(a[i].count(0)==3):
      return 1
      break
    if(a[i][0]==0):
      col.append(0)
    if(a[i][1]==0):
      col.append(1)
    if(a[i][2]==0):
      col.append(2)
    if(a[i][i]==0):
      diag1+=1
    if(a[i][-(i+1)]==0):
      diag2+=1
  if(diag1==3 or diag2==3):
    return 1
  if(col.count(0)==3 or col.count(1)==3 or col.count(2)==3):
    return 1
  return 0


a=[]
for i in range(3):
  a.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if(b==a[j][k]):
        a[j][k]=0
judge=Judge(a)
if(judge==1):
  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)]
c = [[0]*3 for _ in range(3)]
for x in b:
  for i in range(3):
    for j in range(3):
      if A[i][j] == x:
        c[i][j] = 1

if c[0] == [1,1,1] or c[1] == [1,1,1] or c[2] == [1,1,1]:
  print("Yes")
elif [c[0][0], c[1][0], c[2][0]] == [1,1,1] or [c[0][1], c[1][1], c[2][1]] == [1,1,1] or [c[0][2], c[1][2], c[2][2]] == [1,1,1]:
  print("Yes")
elif [c[0][0], c[1][1], c[2][2]] == [1,1,1] or [c[2][0], c[1][1], c[0][2]] == [1,1,1]:
  print("Yes")
else:
  print("No")

Solution (Python):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j] = "o"
for i in range(3):
  if a[i][0] == a[i][1] == a[i][2]:
    print("Yes")
    exit()
  elif a[0][i] == a[1][i] == a[2][i]:
    print("Yes")
    exit()
  elif a[0][0] == a[1][1] == a[2][2]:
    print("Yes")
    exit()
  elif a[0][2] == a[1][1] == a[2][0]:
    print("Yes")
    exit()
  elif i == 2:
    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 i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j] = "o"
for i in range(3):
  if a[i][0] == a[i][1] == a[i][2]:
    print("Yes")
    exit()
  elif a[0][i] == a[1][i] == a[2][i]:
    print("Yes")
    exit()
  elif a[0][0] == a[1][1] == a[2][2]:
    print("Yes")
    exit()
  elif a[0][2] == a[1][1] == a[2][0]:
    print("Yes")
    exit()
  elif i == 2:
    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(N):
    for j in range(3):
        for k in range(3):
            if b[i] == A[j][k]:
                A[j][k] = 0
ans = 'No'
for i in range(3):
    if all(c == 0 for c in [A[i][0], A[i][1], A[i][2]]):
        ans = 'Yes'
for i in range(3):
    if all(c == 0 for c in [A[0][i], A[1][i], A[2][i]]):
        ans = 'Yes'
if all(c == 0 for c in [A[0][0], A[1][1], A[2][2]]):
    ans = 'Yes'
if all(c == 0 for c in [A[0][2], A[1][1], A[2][0]]):
    ans = 'Yes'
print(ans)

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

n = int(input())

for _ in range(n):
  x = int(input())
  for d in lst:
    if d[0] == x:
      d[0] = -1
    elif d[1] == x:
      d[1] = -1
    elif d[2] == x:
      d[2] = -1

for d in lst:
  if d[0] == d[1] == d[2] == -1:
    print('Yes')
    exit()
for i in range(3):
  if lst[0][i] == lst[1][i] == lst[2][i] == -1:
    print('Yes')
    exit()
for i in range(3):
  if lst[i][0] == lst[i][1] == lst[i][2] == -1:
    print('Yes')
    exit()
if lst[0][0] == lst[1][1] == lst[2][2] == -1:
  print('Yes')
  exit()
if lst[0][2] == lst[1][1] == lst[2][0] == -1:
  print('Yes')
  exit()
print('No')

Solution (Python):
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    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')
        
if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
used=[[False]*3 for _ in range(3)]
for k in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j]==b[k]:
                used[i][j]=True

for i in range(3):
    if used[0][i] and used[1][i] and used[2][i]:
        print("Yes")
        exit()
        
for i in range(3):
    if used[i][0] and used[i][1] and used[i][2]:
        print("Yes")
        exit()

if used[0][0] and used[1][1] and used[2][2]:
        print("Yes")
        exit()

if used[0][2] and used[1][1] and used[2][0]:
        print("Yes")
        exit()                
print("No")

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


def check_bingo(A, B):
    for row in range(3):
        if A[row][0] and A[row][1] and A[row][2]:
            return True

    for col in range(3):
        if A[0][col] and A[1][col] and A[2][col]:
            return True

    if A[0][0] and A[1][1] and A[2][2]:
        return True
    if A[0][2] and A[1][1] and A[2][0]:
        return True
    return False


for row in range(3):
    for col in range(3):
        if A[row][col] in B:
            A[row][col] = True
        else:
            A[row][col] = False

print("Yes" if check_bingo(A, B) else "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))

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

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] or a[0][i] == a[1][i] == a[2][i] or a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]:
        print("Yes")
        break
else:
     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))

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

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] or a[0][i] == a[1][i] == a[2][i] or a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]:
        print("Yes")
        break
else:
     print("No")

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

for b in B:
    tmp=[i for i,x in enumerate(A) if x==b]
    for t in tmp:
        table[t//3][t%3]=1

flag=False
n1,n2=0,0
for i in range(3):
    if sum(table[i])==3: flag=True
    if sum([table[j][i] for j in range(3)])==3: flag=True
    n1+=table[i][i]
    n2+=table[i][2-i]
if n1==3 or n2==3: flag=True
if flag: print('Yes')
else: print('No')

Solution (Python):
a=[input().split() for _ in range(3)]
n=int(input())
b=[input() for _ in range(n)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]='0'
ans="No"
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        ans="Yes"
    if a[0][i]==a[1][i]==a[2][i]:
        ans="Yes"
if a[0][0]==a[1][1]==a[2][2]:
    ans="Yes"
if a[0][2]==a[1][1]==a[2][0]:
    ans="Yes"
print(ans)

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

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

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

state = False
for i in range(3):
    num = 0
    for j in range(3):
        num += ans[i][j]
    
    if num == 3:
        state = True

for i in range(3):
    num = 0
    for j in range(3):
        num += ans[j][i]
    
    if num == 3:
        state = True

if ans[0][0] + ans[1][1] + ans[2][2] == 3:
    state = True

if ans[0][2] + ans[1][1] + ans[2][0] == 3:
    state = True

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

Solution (Python):
def main():
    A_checked = [ [False] * 3 for i in range(3) ]
    A_map = {}

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

    N = int(input())
    for i in range(N):
        b = int(input())
        if b in A_map:
            v = A_map[b]
            A_checked[v[0]][v[1]] = True

    if A_checked[0][0] and A_checked[0][1] and A_checked[0][2]:
        print("Yes")
        return
    if A_checked[1][0] and A_checked[1][1] and A_checked[1][2]:
        print("Yes")
        return
    if A_checked[2][0] and A_checked[2][1] and A_checked[2][2]:
        print("Yes")
        return

    if A_checked[0][0] and A_checked[1][0] and A_checked[2][0]:
        print("Yes")
        return
    if A_checked[0][1] and A_checked[1][1] and A_checked[2][1]:
        print("Yes")
        return
    if A_checked[0][2] and A_checked[1][2] and A_checked[2][2]:
        print("Yes")
        return

    if A_checked[0][0] and A_checked[1][1] and A_checked[2][2]:
        print("Yes")
        return
    if A_checked[0][2] and A_checked[1][1] and A_checked[2][0]:
        print("Yes")
        return

    print("No")

main()

Solution (Python):
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

a = LIR(3)
n = I()
b = IR(n)


def check(A, B):
   S = set(b)
 
   
   for r in range(3):
      cnt = 0
      for c in range(3):
         if A[r][c] in S:
            cnt += 1
      if cnt == 3:
         return True
 
   
   for c in range(3):
      cnt = 0
      for r in range(3):
         if A[r][c] in S:
            cnt += 1
      if cnt == 3:
         return True
 
   
   cnt = 0
   for i in range(3):
      if A[i][i] in S:
         cnt += 1
   if cnt == 3:
      return True
 
   
   cnt = 0
   for i in range(3):
      if A[i][2-i] in S:
         cnt += 1
   if cnt == 3:
      return True
 
   return False
 
 
print('Yes' if check(a, b) else 'No')

Solution (Python):
a=[input().split() for _ in range(3)]
n=int(input())
b=[input() for _ in range(n)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]='0'
ans="No"
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        ans="Yes"
    if a[0][i]==a[1][i]==a[2][i]:
        ans="Yes"
if a[0][0]==a[1][1]==a[2][2]:
    ans="Yes"
if a[0][2]==a[1][1]==a[2][0]:
    ans="Yes"
print(ans)

Solution (Python):
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

ar=[]
for i in range(3):
    ar.append(lis())
mark=[[0]*3 for _ in range(3)]
n=int(input())
for _ in range(n):
    k=int(input())
    for i in range(3):
        for j  in range(3):
            if ar[i][j]==k:
                mark[i][j]=1

for i in range(3):
    if mark[i][1]==mark[i][2]==mark[i][0]==1:
        print("Yes")
        quit()
for i in range(3):
    if mark[1][i]==mark[2][i]==mark[0][i]==1:
        print("Yes")
        quit()
if mark[0][0]==mark[1][1]==mark[2][2]==1:
    print("Yes")
    quit()
if mark[0][2]==mark[1][1]==mark[2][0]==1:
    print("Yes")
    quit()
print("No")

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

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

Solution (Python):
a=[]
for i in range(3):
  da=list(map(int,input().split()))
  for j in da:
    a.append(j)
n=int(input())
for i in range (n):
  b=int(input())
  for j in range(len(a)):
    if a[j] == b:
      a[j]=0

for i in range (3):
  if a[i] == a[i+3] and a[i+3]==a[i+6]:
    print('Yes')
    exit()
for i in range(3):
  if a[3*i]==a[3*i+1] and a[3*i]==a[3*i+2]:
    print('Yes')
    exit() 
if a[0]==a[4] and a[0]==a[8]:
  print('Yes')
  exit()

if a[2]==a[4] and a[2]==a[6]:
  print('Yes')
  exit()
print('No')

Solution (Python):
array = [ list(map(int,input().split())) for _ in range(3) ]
number = []
N = int(input())
for _ in range(N):
  number += [ int(input()) ]
for i in range(3):
  for t in range(3):
    if array[i][t] in number:
      array[i][t] = 0
for i in range(1):
  if array[i][0] == array[i+1][0] == array[i+2][0]:
    print('Yes')
    exit()
  elif array[i][1] == array[i+1][1] == array[i+2][1]:
    print('Yes')
    exit()
  elif array[i][2] == array[i+1][2] == array[i+2][2]:
    print('Yes')
    exit()
  elif array[i][0] == array[i][1] == array[i][2]: 
    print('Yes')
    exit()
  elif array[i+1][0] == array[i+1][1] == array[i+1][2]:
    print('Yes')
    exit()
  elif array[i+2][0] == array[i+2][1] == array[i+2][2]:
    print('Yes')
    exit()
    
if array[0][0] == array[1][1] == array[2][2] or array[0][2] == array[1][1] == array[2][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)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if A[i][j]==b[k]:
                A[i][j]=-1
if A[0][0]==-1 and A[1][1]==-1 and A[2][2]==-1:
    print("Yes")
    exit()
elif A[0][2]==-1 and A[1][1]==-1 and A[2][0]==-1:
    print("Yes")
    exit()
for i in range(3):
    total=0
    if A[i].count(-1)==3:
        print("Yes")
        exit()
    for j in range(3):
        if A[j][i]==-1:
            total+=1
    if total==3:
        print("Yes")
        exit()
print("No")

Solution (Python):
def resolve():
	a = []
	bingo = [(0,3,6),(1,4,7),(2,5,8),(0,1,2),(3,4,5)
			 ,(6,7,8),(0,4,8),(2,4,6)]
	for _ in range(3):
		a += list(map(int,input().split()))
	for i in range(int(input())):
		r = int(input())
		if r in a:
			a[a.index(r)]=0
	ans = 'No'
	for i in bingo:
		if a[i[0]] == 0 and a[i[1]]==0 and a[i[2]]==0:
			ans ='Yes'
	print(ans)
resolve()

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):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    if b in a2:
        a2[a2.index(b)] = 0
    if b in a3:
        a3[a3.index(b)] = 0
if (sum(a1) != 0) and (sum(a2) != 0) and (sum(a3) != 0) and (a1[0] + a2[0] + a3[0] != 0) and (a1[1] + a2[1] + a3[1] != 0) and (a1[2] + a2[2] + a3[2] != 0) and a1[0] + a2[1] + a3[2] != 0 and a1[2] + a2[1] + a3[0] != 0:
    print('No')
else:
    print('Yes')

Solution (Python):
a = input()
a = a.split()
b = input()
b = b.split()
c = input()
c = c.split()
d = [a[0],b[0],c[0]]
e = [a[1],b[1],c[1]]
f = [a[2],b[2],c[2]]
g = [a[0],b[1],c[2]]
h = [a[2],b[1],c[0]]
n = int(input())
for i in range(n):
    j = int(input())
    for k in range(3):
        if int(a[k])==j:
            a.pop(k)
            a.insert(k,0)
        if int(b[k])==j:
            b.pop(k)
            b.insert(k,0)
        if int(c[k])==j:
            c.pop(k)
            c.insert(k,0)
        if int(d[k])==j:
            d.pop(k)
            d.insert(k,0)
        if int(e[k])==j:
            e.pop(k)
            e.insert(k,0)
        if int(f[k])==j:
            f.pop(k)
            f.insert(k,0)
        if int(g[k])==j:
            g.pop(k)
            g.insert(k,0)
        if int(h[k])==j:
            h.pop(k)
            h.insert(k,0)
if a == [0,0,0] or b == [0,0,0] or c == [0,0,0] or d == [0,0,0] or e == [0,0,0] or f == [0,0,0] or g == [0,0,0] or h == [0,0,0]:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

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

for i in range(n):
    b = int(input())

    for j in range(3):
        if b in a[j]:
            idx = a[j].index(b)
            a[j][idx] = 0

np_a = np.array(a)
np_t = np_a.T
d = 0
u = 0

for i in range(3):
    r = np_a[i]
    c = np_t[i]
    d += r[i]
    u += r[2-i]

    if r.sum() and c.sum():
        continue

    print("Yes")
    exit()


if d and u:
    print("No")
else:
    print("Yes")

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 i in b:
    for j in range(0,3):
        for k in range(0,3):
            if i == a[j][k]:
                a[j][k] = 0


if a[0][0]==0 and a[0][1]==0 and a[0][2]==0:
    print("Yes")
elif a[1][0]==0 and a[1][1]==0 and a[1][2]==0:
    print("Yes")
elif a[2][0]==0 and a[2][1]==0 and a[2][2]==0:
    print("Yes")
elif a[0][0]==0 and a[1][0]==0 and a[2][0]==0:
    print("Yes")
elif a[0][1]==0 and a[1][1]==0 and a[2][1]==0:
    print("Yes")
elif a[0][2]==0 and a[1][2]==0 and a[2][2]==0:
    print("Yes")
elif a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==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)]

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


if a[0][0]==0 and a[0][1]==0 and a[0][2]==0:
    print("Yes")
elif a[1][0]==0 and a[1][1]==0 and a[1][2]==0:
    print("Yes")
elif a[2][0]==0 and a[2][1]==0 and a[2][2]==0:
    print("Yes")
elif a[0][0]==0 and a[1][0]==0 and a[2][0]==0:
    print("Yes")
elif a[0][1]==0 and a[1][1]==0 and a[2][1]==0:
    print("Yes")
elif a[0][2]==0 and a[1][2]==0 and a[2][2]==0:
    print("Yes")
elif a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==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)]

bingo = []
for i in range(3):
    x = a[i]
    for j in range(3):
        bingo.append(x[j])

for i in b:
    for j in range(0,9):
        if i == bingo[j]:
            bingo[j] = 0

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

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

N=int(input())

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

list2=[]
i=0
while i<=2:
    j=0
    while j<=2:
        list2.append(num_list[i][j])
        j=j+1
    i=i+1

s=0
for k in list2:
    if list1.count(k)==1:
        list2[s]=101
        s=s+1
    else:
        s=s+1
        continue

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

Solution (Python):
A11,A12,A13 = map(int,input().split())
A21,A22,A23 = map(int,input().split())
A31,A32,A33 = map(int,input().split())

Alist = []
Alist.append(A11)
Alist.append(A12)
Alist.append(A13)
Alist.append(A21)
Alist.append(A22)
Alist.append(A23)
Alist.append(A31)
Alist.append(A32)
Alist.append(A33)
bingolist =[0]*9

N = int(input())

for i in range(N):
  b = int(input())
  
  for j in range(len(bingolist)):
    if b ==Alist[j]:
      bingolist[j] = 1

if sum(bingolist[0:3])==3 or sum(bingolist[3:6])==3 or sum(bingolist[6:9])==3 or (bingolist[0]+bingolist[3]+bingolist[6])==3 or (bingolist[1]+bingolist[4]+bingolist[7])==3 or (bingolist[2]+bingolist[5]+bingolist[8])==3 or (bingolist[0]+bingolist[4]+bingolist[8])==3 or (bingolist[2]+bingolist[4]+bingolist[6])==3:
  print ("Yes")
else :
  print ("No")

Solution (Python):


import numpy as np

def check(A, b):
    A = np.where(A == b, -1, A)
    return A

def bingo(A):
    for a in A:
        if a[0] == a[1] == a[2] == -1:
            return True
    for a in A.T:
        if a[0] == a[1] == a[2] == -1:
            return True
    if A[0][0] == A[1][1] == A[2][2] == -1:
        return True
    if A[0][2] == A[1][1] == A[2][0] == -1:
        return True
    return False



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






if bingo(A):
    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(8)]
for i in range(N):
    b = int(input())
    if b == A[0][0] or b == A[1][0] or b == A[2][0]:
        B[0] += 1
    if b == A[0][1] or b == A[1][1] or b == A[2][1]:
        B[1] += 1
    if b == A[0][2] or b == A[1][2] or b == A[2][2]:
        B[2] += 1
    if b == A[0][0] or b == A[0][1] or b == A[0][2]:
        B[3] += 1
    if b == A[1][0] or b == A[1][1] or b == A[1][2]:
        B[4] += 1
    if b == A[2][0] or b == A[2][1] or b == A[2][2]:
        B[5] += 1
    if b == A[0][0] or b == A[1][1] or b == A[2][2]:
        B[6] += 1
    if b == A[0][2] or b == A[1][1] or b == A[2][0]:
        B[7] += 1
if 3 in B:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

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

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

    if A[0][0]==0 and A[0][1]==0 and A[0][2]==0:
        return 'Yes'
    elif A[1][0]==0 and A[1][1]==0 and A[1][2]==0:
        return 'Yes'
    elif A[2][0]==0 and A[2][1]==0 and A[2][2]==0:
        return 'Yes'
    elif A[0][0]==0 and A[1][0]==0 and A[2][0]==0:
        return 'Yes'
    elif A[0][1]==0 and A[1][1]==0 and A[2][1]==0:
        return 'Yes'
    elif A[0][2]==0 and A[1][2]==0 and A[2][2]==0:
        return 'Yes'
    elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
        return 'Yes'
    elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
        return 'Yes'

    return ('No')

print(main())

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

l=[lnii() for i in range(3)]

n=int(input())
for i in range(n):
  b=int(input())
  for h in range(3):
    for w in range(3):
      if l[h][w]==b:
        l[h][w]=-1

if l[0][0]==l[1][1]==l[2][2]==-1 or l[0][2]==l[1][1]==l[2][0]==-1:
  print('Yes')
  exit()
for i in range(3):
  if l[i].count(-1)==3:
    print('Yes')
    exit()
l2=list(zip(*l))
for i in range(3):
  if l2[i].count(-1)==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)]

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

for i in range(3):
    ans1, ans2 = 0, 0
    for j in range(3):
        if A[i][j] == -1:
            ans1 += 1
        if A[j][i] == -1:
            ans2 += 1
    if ans1 == 3 or ans2 == 3:
        print("Yes")
        exit()

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

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  


A = [LI() for _ in range(3)]
N = I()
flag = [[0]*3 for _ in range(3)]

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

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

if flag[0][0] == flag[1][1] == flag[2][2] == 1 or flag[0][2] == flag[1][1] == flag[2][0] == 1:
    print('Yes')
    exit()

print('No')

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

bingo = [list(mapint()) for _ in range(3)]
N = int(input())
card = [[0]*3 for _ in range(3)]
for _ in range(N):
    n = int(input())
    for i in range(3):
        for j in range(3):
            if n==bingo[i][j]:
                card[i][j] = 1

for i in range(3):
    if sum(card[i])==3:
        print('Yes')
        exit()

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

if card[0][0]+card[1][1]+card[2][2]==3 or card[2][0]+card[1][1]+card[0][2]==3:
    print('Yes')
    exit()
print('No')

Solution (Python):
import sys

input = sys.stdin.readline

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

N = int(input())
nums = []
for _ in range(N):
    nums.append(int(input()))

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

for i in range(3):
    if sum(bingo[i]) == -3:
        print("Yes")
        sys.exit()
    tmp = 0
    for j in range(3):
        tmp += bingo[j][i]
    if tmp == -3:
        print("Yes")
        sys.exit()
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
    print("Yes")
    sys.exit()
if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[0][2] == -1:
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


def LIH(h):
    return [int(input()) for _ in range(h)]


card = LIHW(3)
N = int(input())
num = LIH(N)
bingo = [[0, 0, 0] for _ in range(3)]
for i in num:
    for a in range(3):
        for b in range(3):
            if i == card[a][b]:
                bingo[a][b] = 1
                break
ans = "No"
for i in range(3):
    if bingo[i][0] == 1 and bingo[i][1] == 1 and bingo[i][2] == 1:
        ans = "Yes"
for i in range(3):
    if bingo[0][i] == 1 and bingo[1][i] == 1 and bingo[2][i] == 1:
        ans = "Yes"
if bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
    ans = "Yes"
if bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
    ans = "Yes"
print(ans)

Solution (Python):
import numpy as np

arr = np.array([list(map(int, input().split())) for _ in range(3)])


n = int(input())

for _ in range(n):
    b = int(input())
    arr[np.where(arr == b)] = 0

ans1 = (np.sum(arr, axis=0) == 0).sum() >= 1
ans2 = (np.sum(arr, axis=1) == 0).sum() >= 1
ans3 = (np.diag(arr) == 0).sum() == 3
ans4 = (np.diag(np.rot90(arr)) == 0).sum() == 3

print("Yes" if ans1 or ans2 or ans3 or ans4 else "No")