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):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


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


def read_int():
    return int(input())


def read_str():
    return input()


def solve(A, N, b):
    l = [[(0, 0), (0, 1), (0, 2)], 
        [(1, 0), (1, 1), (1, 2)],
        [(2, 0), (2, 1), (2, 2)],
        [(0, 0), (1, 0), (2, 0)],
        [(0, 1), (1, 1), (2, 1)],
        [(0, 2), (1, 2), (2, 2)],
        [(0, 0), (1, 1), (2, 2)],
        [(0, 2), (1, 1), (2, 0)]]

    for k in l:
        if all(A[i][j] in b for i, j in k):
          return 'Yes'
    return 'No'


def main():
    A = [read_int_list() for i in range(3)]
    N = read_int()
    b = [read_int() for k in range(N)]
    
    res = solve(A, N, b)
    print(res)


main()

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

for i in range(3):
    for j in range(3):
        if a[i][j] in bl:
            a[i][j]=0
flag=False
for i in range(3):
    total=0
    if sum(a[i])==0:
        flag=True
        break
    for j in range(3):
        total+=a[j][i]
    if total==0:
        flag=True
        break
    if flag:
        break
if a[0][0]+a[1][1]+a[2][2]==0:
    flag=True
elif a[2][0]+a[1][1]+a[0][2]==0:
    flag=True
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):


def main():
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))
    A3 = list(map(int, input().split()))
    bingo = A1 + A2 + A3
    

    n = int(input())

    for i in range(n):
        b = int(input())
        if b in bingo:
            bingo[bingo.index(b)] = -1

    

    
    if bingo[0] == -1 and bingo[1] == -1 and bingo[2] == -1: return True
    if bingo[3] == -1 and bingo[4] == -1 and bingo[5] == -1: return True
    if bingo[6] == -1 and bingo[7] == -1 and bingo[8] == -1: return True

    
    if bingo[0] == -1 and bingo[3] == -1 and bingo[6] == -1: return True
    if bingo[1] == -1 and bingo[4] == -1 and bingo[7] == -1: return True
    if bingo[2] == -1 and bingo[5] == -1 and bingo[8] == -1: return True

    
    if bingo[0] == -1 and bingo[4] == -1 and bingo[8] == -1: return True
    if bingo[2] == -1 and bingo[4] == -1 and bingo[6] == -1: return True

if __name__ == "__main__":
    if main():
        print('Yes')
    else:
        print('No')

Solution (Python):
a_list = []
bingo_list = [0] * 9
for _ in range(3):
    a = list(map(int, input().split()))
    a_list = a_list + a
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(9):
        if a_list[i] == b:
            bingo_list[i] = 1
        else:
            continue
if sum(bingo_list[:3]) == 3 or sum(bingo_list[3:6]) == 3 or sum(bingo_list[6:]) == 3:
    print("Yes")
elif bingo_list[0] == bingo_list[3] == bingo_list[6] == 1:
    print("Yes")
elif bingo_list[1] == bingo_list[4] == bingo_list[7] == 1:
    print("Yes")
elif bingo_list[2] == bingo_list[5] == bingo_list[8] == 1:
    print("Yes")
elif bingo_list[0] == bingo_list[4] == bingo_list[8] == 1:
    print("Yes")
elif bingo_list[2] == bingo_list[4] == bingo_list[6] == 1:
    print("Yes")
else:
    print("No")

Solution (Python):

bingo = [ list(map(int, input().split())) for _ in range(3) ]
t_or_f = [ [False]*3 for _ in range(3) ]

nums = [ r[i]for i in range(3) for r in bingo ]

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

for x in range(3):
  for y in range(3):
    if bingo[x][y] in appear:
      t_or_f[x][y] = True

is_bingo = False
if t_or_f[0][0] and t_or_f[1][1] and t_or_f[2][2]:
  is_bingo = True
elif t_or_f[0][2] and t_or_f[1][1] and t_or_f[2][0]:
  is_bingo = True
else:
  for i in range(3):
    if t_or_f[i][0] and t_or_f[i][1] and t_or_f[i][2]: is_bingo = True
    if t_or_f[0][i] and t_or_f[1][i] and t_or_f[2][i]: is_bingo = True

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

Solution (Python):
a = []
for x in range(3):
    bingo = list(int(i) for i in input().split())
    a.append(bingo)
N = int(input())
bingolist=[]
for x in range(N):
    c = int(input())
    bingolist.append(c)
b = [[0]*3 for i in range(3)]

for x in bingolist:
    for y in range(3):
        for z in range(3):
            if a[y][z] == x:
                b[y][z] = 1

bingo_tate =0
bingo_naname = 0
bingo_yoko =0
bingo_kakutei =0

for y in range(3):
    if sum(b[y]) == 3:
        bingo_kakutei=1
alist =[]
for x in range(3):
    a_l = [b[0][x],b[1][x],b[2][x]]
    alist.append(a_l)
for x in range(3):
    if sum(alist[x]) == 3:
        bingo_kakutei=1
        
naname = b[0][0]+b[1][1]+b[2][2]
naname2 = b[0][2]+b[1][1]+b[2][0]
if naname==3 or naname2 ==3:
    bingo_kakutei =1
    
if bingo_kakutei ==1:
    print("Yes")
else:
    print("No")

Solution (Python):
bingo = [1,1,1,1,1,1,1,1,1]
bingo[0] , bingo[1] , bingo[2] = map(int, input().split())
bingo[3] , bingo[4], bingo[5] = map(int, input().split())
bingo[6], bingo[7], bingo[8] = map(int, input().split())
n = int(input())
ls = []
counter = 0
for i in range(n):
  ls.append(int(input()))
 
for i in range(len(bingo)):
  for j in range(len(ls)):
    if ls[j] == bingo[i]:
      bingo[i] = 0
      break
for i in range(len(bingo)):
  if i == 0:
    if bingo[i] + bingo[i+1] + bingo[i+2] == 0:
      counter += 1
      break
    elif bingo[i] + bingo[i+3] + bingo[i+6] == 0:
      counter += 1
      break
    elif bingo[i] + bingo[i+4] + bingo[i+8] == 0:
      counter += 1
      break
  elif i == 1:
    if bingo[i] + bingo[i+3] + bingo[i+6] == 0:
      counter += 1
      break
  elif i == 2:
    if bingo[i] + bingo[i+3] + bingo[i+6] == 0:
      counter += 1
      break
    elif bingo[i] + bingo[i+2] + bingo[i+4] == 0:
      counter += 1
      break
  elif i == 3:
    if bingo[i] + bingo[i+1] + bingo[i+2] == 0:
      counter += 1
      break
  elif i == 6:
    if bingo[i] + bingo[i+1] + bingo[i+2] == 0:
      counter += 1
      break
if counter > 0:
  print("Yes")
else: 
  print("No")

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]
 
num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
ans = 'No'        
for i in range(3):
  if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
    ans = 'Yes'
  if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0):
    ans = 'Yes'
    
if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
  ans = 'Yes'
if(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
  ans = 'Yes'

print(ans)

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

V = [[False,False,False],[False,False,False],[False,False,False]]

for bb in b:
    for i in range(len(A)):
        for j in range(len(A[i])):
            if(A[i][j] == bb):
                V[i][j] = True


def judge(V):
    for i in range(3):
        if(V[i][0] and V[i][1] and V[i][2]):
            return True
        if(V[0][i] and V[1][i] and V[2][i]):
            return True

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



if(judge(V)):
    print("Yes")
else:
    print("No")

Solution (Python):
bingo = []
checks = {}
for i in range(3):
    a, b, c = map(int,input().split())
    bingo.append(a)
    bingo.append(b)
    bingo.append(c)
    
n = int(input())
numbers = [int(input()) for i in range(n)]

for number in numbers:
    if number in bingo:
        l = bingo.index(number)
        bingo[l] = 0
        
result = "No"

for i in range(3):
    if sum(bingo[i*3:i*3 + 3])==0:
        result = "Yes"

for i in range(3):     
    if sum(bingo[i::3])==0:
        result = "Yes"

if sum(bingo[2:7:2]) == 0 :
    result = "Yes"
    
if sum(bingo[0::4]) == 0:
    result = "Yes"
    
print(result)

Solution (Python):
import numpy as np

def check(a,b,c):
  return a==b==c==0


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

for i in a:
  for x in range(3):
    for y in range(3):
      if t[x][y] == i :
        t[x][y] = 0

ans = check(t[0][0],t[0][1],t[0][2]) or \
check(t[1][0],t[1][1],t[1][2]) or \
check(t[2][0],t[2][1],t[2][2]) or \
check(t[0][0],t[1][0],t[2][0]) or \
check(t[0][1],t[1][1],t[2][1]) or \
check(t[0][2],t[1][2],t[2][2]) or \
check(t[0][0],t[1][1],t[2][2]) or \
check(t[0][2],t[1][1],t[2][0]) 

print(["No","Yes"][ans])

Solution (Python):
data = [int(x) for x in input().split()]
data.extend([int(x) for x in input().split()])
data.extend([int(x) for x in input().split()])
H = int(input())

class Bingo:
  sheet = []
  def __init__(self, data):
    self.sheet = [{x: False} for x in data]
   
  def addNumber(self, num):
    for i in self.sheet:
      if num in i:
        i[num] = True
    
  def printBingoVal(self):
    print(self.sheet)

  def isBingo(self):
    hitList = [list(x.values())[0] for x in self.sheet]
    if hitList[0] and hitList[1] and hitList[2]:
      return 'Yes'
    if hitList[3] and hitList[4] and hitList[5]:
      return 'Yes'
    if hitList[6] and hitList[7] and hitList[8]:
      return 'Yes'
    if hitList[0] and hitList[3] and hitList[6]:
      return 'Yes'
    if hitList[1] and hitList[4] and hitList[7]:
      return 'Yes'
    if hitList[2] and hitList[5] and hitList[8]:
      return 'Yes'
    if hitList[0] and hitList[4] and hitList[8]:
      return 'Yes'
    if hitList[2] and hitList[4] and hitList[6]:
      return 'Yes'
    return 'No'
  
bingo = Bingo(data)
for i in range(H):
    j = int(input())
    bingo.addNumber(j)

print(bingo.isBingo())

Solution (Python):
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
N = int(input())
b = [int(input()) for _ in range(N)]

cnt11=0
cnt12=0
cnt13=0
cnt21=0
cnt22=0
cnt23=0
cnt31=0
cnt32=0
cnt33=0

for i in range(N):
    if b[i]==A11:
        cnt11+=1
    elif b[i]==A12:
        cnt12+=1
    elif b[i]==A13:
        cnt13+=1
    elif b[i]==A21:
        cnt21+=1
    elif b[i]==A22:
        cnt22+=1
    elif b[i]==A23:
        cnt23+=1
    elif b[i]==A31:
        cnt31+=1
    elif b[i]==A32:
        cnt32+=1
    elif b[i]==A33:
        cnt33+=1
    else:
        pass

bingo=0
if  (cnt11>0 and cnt12>0 and cnt13>0)or(cnt11>0 and cnt21>0 and cnt31>0)or(cnt11>0 and cnt22>0 and cnt33>0)or(cnt12>0 and cnt22>0 and cnt32>0)or(cnt13>0 and cnt22>0 and cnt31>0)or(cnt13>0 and cnt23>0 and cnt33>0)or(cnt21>0 and cnt22>0 and cnt23>0)or(cnt31>0 and cnt32>0 and cnt33>0):
    bingo+=1
if bingo>0:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    li = []
    for i in range(3):
        x,y,z = map(int,input().split())
        li.append(x)
        li.append(y)
        li.append(z)
    n = int(input())
    bingo_li = []
    for i in range(n):
        bingo_li.append(int(input()))
    ans_li = [0,0,0,0,0,0,0,0,0]
    for i in bingo_li:
        for j in range(9):
            if li[j] == i:
                ans_li[j] = 1
    if (ans_li[0] + ans_li[1] + ans_li[2] == 3):
        ans = "Yes"
    elif(ans_li[3] + ans_li[4] + ans_li[5] == 3):
        ans = "Yes"
    elif(ans_li[6] + ans_li[7] + ans_li[8] == 3):
        ans = "Yes"
    elif(ans_li[0] + ans_li[3] + ans_li[6] == 3):
        ans = "Yes"
    elif(ans_li[1] + ans_li[4] + ans_li[7] == 3):
        ans = "Yes"
    elif(ans_li[2] + ans_li[5] + ans_li[8] == 3):
        ans = "Yes"
    elif(ans_li[0] + ans_li[4] + ans_li[8] == 3):
        ans = "Yes"
    elif(ans_li[2] + ans_li[4] + ans_li[6] == 3):
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

if __name__ == '__main__':
  main()

Solution (Python):

def main():
    a = []
    for _ in range(3):
        x, y, z = map(int, input().split())
        a.append((x, y, z))
    n = int(input())
    b = [int(input()) for _ in range(n)]
    g =[[0 for _ in range(3)] for _ in range(3)]
    for i in range(3):
        for j in range(3):
            for k in range(n):
                if b[k] == a[i][j]:
                    g[i][j] = 1

    bingo = False
    
    for i in range(3):
        s = 0
        for j in range(3):
            s += g[j][i]
        if s == 3:
            bingo = True
    
    for i in range(3):
        s = 0
        for j in range(3):
            s += g[i][j]
        if s == 3:
            bingo = True
    
    
    s1 = 0
    for i in range(3):
        s1 += g[i][i]
    if s1 == 3:
        bingo = True
    
    s2 = 0
    for i in range(3):
        s2 += g[i][2-i]
    if s2 == 3:
        bingo = True 
    
    if bingo:
        print('Yes')
    else:
        print('No')
main()

Solution (Python):
import numpy as np


flag = False
arr = [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):
        if b in arr[j]:
            idx = arr[j].index(b)
            arr[j][idx] = 0

arr = np.array(arr)
for s in arr:
    if sum(s) == 0:
        flag = True
arr = np.rot90(arr)
for s in arr:
    if sum(s) == 0:
        flag = True
if arr[0][0] + arr[1][1] + arr[2][2] ==0:
    flag = True
if arr[2][0] + arr[1][1] + arr[0][2] == 0:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

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

import numpy as np
A = np.array(A)

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

ans = [[False] * 3 for _ in range(3)]
ans = np.array(ans)

for b in B:
    temp = (A == b)

    ans = np.logical_or(ans, temp)


if ans[0, :].all() or ans[1, :].all() or ans[2, :].all():
    print("Yes")

elif ans[:, 0].all() or ans[:, 1].all() or ans[:, 2].all():
    print("Yes")

elif ans[0, 0] and ans[1, 1] and ans[2, 2]:
    print("Yes")
elif ans[0, 2] and ans[1, 1] and ans[2, 0]:
    print("Yes")
else:
    print("No")

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

import numpy as np
A = np.array(A)

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

ans = [[False] * 3 for _ in range(3)]
ans = np.array(ans)

for b in B:
    temp = (A == b)

    ans = np.logical_or(ans, temp)


if ans[0, :].all() or ans[1, :].all() or ans[2, :].all():
    print("Yes")

elif ans[:, 0].all() or ans[:, 1].all() or ans[:, 2].all():
    print("Yes")

elif ans[0, 0] and ans[1, 1] and ans[2, 2]:
    print("Yes")
elif ans[0, 2] and ans[1, 1] and ans[2, 0]:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
import sys

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

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


s_row = np.sum(A, axis=1)
for i in range(3):
    if s_row[i] == 0:
        print('Yes')
        sys.exit()


s_col = np.sum(A, axis=0)
for i in range(3):
    if s_col[i] == 0:
        print('Yes')
        sys.exit()

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

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

print('No')

Solution (Python):
a1j=list(map(int,input().split()))
a2j=list(map(int,input().split()))
a3j=list(map(int,input().split()))
n = int(input())

for i in range(n):
    b = int(input())
    if b in a1j:
        a1j[a1j.index(b)] = 0
    if b in a2j:
        a2j[a2j.index(b)] = 0
    if b in a3j:
        a3j[a3j.index(b)] = 0

ans = "No"

if a1j[0] == 0:
    if a1j[1] == 0 and a1j[2] == 0:
        ans = "Yes"
    if a2j[1] == 0 and a3j[2] == 0:
        ans = "Yes"
    if a2j[0] == 0 and a3j[0] == 0:
        ans = "Yes"
if a1j[1] == 0:
    if a2j[1] == 0 and a3j[1] == 0:
        ans = "Yes"
if a1j[2] == 0:
    if a2j[2] == 0 and a3j[2] == 0:
        ans = "Yes"
    if a2j[1] == 0 and a3j[0] == 0:
        ans = "Yes"
if a2j[0] == 0:
    if a2j[1] == 0 and a2j[2] == 0:
        ans = "Yes"
if a3j[0] == 0:
    if a3j[1] == 0 and a3j[2] == 0:
        ans = "Yes"

print(ans)

Solution (Python):
import numpy as np
import sys
 
A = []
for i in range(3):
    array = list(map(int, input().split()))
    A.append(array)
N = int(input())
b = []
for i in range(N):
    k = int(input())
    b.append(k)
for k in range(N):
    for i in range(3):
        for j in range(3):
            if b[k] == A[i][j]:
                A[i][j] = 0
 
 
row = np.sum(A, axis=1)
for i in range(3):
    if row[i] == 0:
        print('Yes')
        sys.exit()
 
 
col = np.sum(A, axis=0)
for i in range(3):
    if col[i] == 0:
        print('Yes')
        sys.exit()
 
c = 0
for i in range(3):
    c += A[i][i]
if c == 0:
    print('Yes')
    sys.exit()
 
c = 0
for i in range(3):
    c += A[3-i-1][i]
if c == 0:
    print('Yes')
    sys.exit()
 
print('No')

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    A=[list(map(int,input().split())) for _ in range(3)]
    for _ in range(int(input())):
        b = int(input())
        for i,j in product(range(3),repeat=2):
            if A[i][j]==b:
                A[i][j] = 0

    flag = 0
    flag |= any(all(A[i][j]==0 for i in range(3)) for j in range(3))
    flag |= any(all(A[i][j]==0 for j in range(3)) for i in range(3))
    flag |= all(A[i][i]==0 for i in range(3))
    flag |= all(A[i][2-i]==0 for i in range(3))
    print("Yes" if flag else "No")
resolve()

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

import numpy as np
A = np.array(A)

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

ans = [[False] * 3 for _ in range(3)]
ans = np.array(ans)

for b in B:
    temp = (A == b)

    ans = np.logical_or(ans, temp)


if ans[0, :].all() or ans[1, :].all() or ans[2, :].all():
    print("Yes")

elif ans[:, 0].all() or ans[:, 1].all() or ans[:, 2].all():
    print("Yes")

elif ans[0, 0] and ans[1, 1] and ans[2, 2]:
    print("Yes")
elif ans[0, 2] and ans[1, 1] and ans[2, 0]:
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
for i in range(3):
    ai = list(map(int, input().split()))
    a.append(ai)
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

ans = "No"
if sum(a[0]) == 0:
    ans = "Yes"
elif sum(a[1]) == 0:
    ans = "Yes"
elif sum(a[2]) == 0:
    ans = "Yes"
elif a[0][0] + a[1][0] + a[2][0] == 0:
    ans = "Yes"
elif a[0][1] + a[1][1] + a[2][1] == 0:
    ans = "Yes"
elif a[0][2] + a[1][2] + a[2][2] == 0:
    ans = "Yes"
elif a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
elif a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)

Solution (Python):
def hasTri(arrs):
    k = [arrs[0][0], arrs[1][1], arrs[2][2]]
    l = [arrs[0][2], arrs[1][1], arrs[2][0]]
    if not False in k:
        return True
    if not False in l:
        return True
    return False
def hascol(arrs):
    for i in range(3):
        k = [arrs[0][i], arrs[1][i], arrs[2][i]]
        if not False in k:
            return True
    return False
def hasrow(arrs):
    for i in arrs:
        arr = [x for x in i if x != False]
        if len(arr)==3:
            return True
    return False
A = [[0,0,0],[0,0,0],[0,0,0]]
B = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(3):
    A[i][0],A[i][1],A[i][2] = map(int, input().split())
N = int(input())
Al = [i for x in A for i in x]
have = []
for _ in range(N):
    a = int(input())
    if a in Al:
        have.append(a)
indexs = [[]]
for k in have:
    index = [[ix,iy] for ix, row in enumerate(A) for iy, j in enumerate(row) if j == k]
    if len(index[0]) == 2:
        indexs = indexs + index
        B[index[0][0]][index[0][1]] = k
if hasTri(B) or hasrow(B ) or hascol(B):
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
import sys
Field = []
for i in range(3):
    a, b, c = map(int, input().split(" "))
    local = [a,b,c]
    Field.append(local)
N = int(input())
for i in range(N):
    target = int(input())
    for i in Field:
        if target in i:
            k = i.index(target)
            i[k] = -1
        else:
            pass
if Field[0][0] == -1 and Field[1][1] == -1 and Field[2][2] == -1:
    print("Yes")
    sys.exit()
if Field[0][2] == -1 and Field[1][1] == -1 and Field[2][0] == -1:
    print("Yes")
    sys.exit()

for i in range(3):
    if Field[0][i] == -1 and Field[1][i] == -1 and Field[2][i] == -1:
        print("Yes")
        sys.exit()
    elif sum(Field[i]) == -3:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):
import numpy as np

a = []
ans = 'No'

a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))

n = int(input())

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

if a[0][0] == a[1][0] == a[2][0] == 0:
  ans = 'Yes'
elif a[0][1] == a[1][1] == a[2][1] == 0:
  ans = 'Yes'
elif a[0][2] == a[1][2] == a[2][2] == 0:
  ans = 'Yes'
elif a[0][0] == a[0][1] == a[0][2] == 0:
  ans = 'Yes'
elif a[1][0] == a[1][1] == a[1][2] == 0:
  ans = 'Yes'
elif a[2][0] == a[2][1] == a[2][2] == 0:
  ans = 'Yes'
elif a[0][0] == a[1][1] == a[2][2] == 0:
  ans = 'Yes'
elif a[2][0] == a[1][1] == a[0][2] == 0:
  ans = 'Yes'

print(ans)

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

Solution (Python):
bingo = []
for i in range(3):
    a,b,c = map(int, input().split())
    bingo.append([a,b,c])
N = int(input())
b = [int(input()) for i in range(N)]
for n in range(N):
    for i in range(3):
        for j in range(3):
            if b[n]==bingo[i][j]:
                bingo[i][j] = 0
if(bingo[0][0] == bingo[0][1] == bingo[0][2] or
   bingo[1][0] == bingo[1][1] == bingo[1][2] or
   bingo[2][0] == bingo[2][1] == bingo[2][2] or
   bingo[0][0] == bingo[1][0] == bingo[2][0] or
   bingo[0][1] == bingo[1][1] == bingo[2][1] or
   bingo[0][2] == bingo[1][2] == bingo[2][2] or
   bingo[0][0] == bingo[1][1] == bingo[2][2] or
   bingo[0][2] == bingo[1][1] == bingo[2][0]):
    print('Yes')
else:
    print('No')

Solution (Python):
bingo=[list(map(int,input().split())) for i in range(3)]
n=int(input())
ans="No"
tmp1=0
tmp2=0
tmp3=0
tmp4=0
tmp5=0
for i in range(n):
    tmp1=int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k]==tmp1:
                bingo[j][k]=0
for l in range(3):
    for m in range(3):
        tmp2+=bingo[l][m]
    if tmp2==0:
        ans="Yes"
    tmp2=0
for n in range(3):
    for o in range(3):
        tmp3+=bingo[o][n]
    if tmp3==0:
        ans="Yes"
    tmp3=0
for p in range(3):
    tmp4+=bingo[p][p]
if tmp4==0:
    ans="Yes"
tmp5=bingo[0][2]+bingo[1][1]+bingo[2][0]
if tmp5==0:
    ans="Yes"
print(ans)

Solution (Python):
bingo = [input().split() for _ in range(3)]

n = int(input())

nums = [input() for _ in range(n)]

check = [[] for _ in range(3)]

for i in range(3):
    for j in range(3):
        if bingo[i][j] in nums:
            check[i].append(True)
        else:
            check[i].append(False)

ANS = "No"

for i in range(3):
    if (check[i][0]) and (check[i][1]) and (check[i][2]):
        ANS = "Yes"
for i in range(3):
    if (check[0][i]) and (check[1][i]) and (check[2][i]):
        ANS = "Yes"
if (check[0][0]) and (check[1][1]) and (check[2][2]):
    ANS = "Yes"
if (check[0][2]) and (check[1][1]) and (check[2][0]):
    ANS = "Yes"

print(ANS)

Solution (Python):
a = [input().split() for a in range(3)]
n = int(input())
b = [input() for i in range(n)]
c = [a[0][0],a[1][1],a[2][2]]
d = [a[0][2],a[1][1],a[2][0]]
tate1 = len(set(a[0]) & set(b))
tate2 = len(set(a[1]) & set(b))
tate3 = len(set(a[2]) & set(b))
yoko1 = len(set([x[0] for x in a]) & set(b))
yoko2 = len(set([x[1] for x in a]) & set(b))
yoko3 = len(set([x[2] for x in a]) & set(b))
naname1 = len(set(c) & set(b))
naname2 = len(set(d) & set(b))
bingo = [tate1,tate2,tate3,yoko1,yoko2,yoko3,naname1,naname2]
if 3 in bingo:
    print("Yes")
else:
    print("No")

Solution (Python):
a=[list(map(int,input().split())) for i 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]=-1
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==-1:
    print('Yes')
    exit()
  if a[0][i]==a[1][i]==a[2][i]==-1:
    print('Yes')
    exit()
if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
  print('Yes')
  exit()
print('No')

Solution (Python):
a = [input().split() for a in range(3)]
a1 = [a[0][0],a[0][1],a[0][2]]
a2 = [a[1][0],a[1][1],a[1][2]]
a3 = [a[2][0],a[2][1],a[2][2]]
a4 = [a[0][0],a[1][1],a[2][2]]
a5 = [a[0][2],a[1][1],a[2][0]]
a6 = [a[0][0],a[1][0],a[2][0]]
a7 = [a[0][1],a[1][1],a[2][1]]
a8 = [a[0][2],a[1][2],a[2][2]]
n = int(input())
B = [input() for i in range(n)]
if set(a1) <= set(B) or set(a2) <= set(B) or set(a3) <= set(B) or set(a4) <= set(B) or set(a5) <= set(B) or set(a6) <= set(B) or set(a7) <= set(B) or set(a8) <= set(B):
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
A = np.array([list(map(int,input().split())) for i in range(3)])
N = int(input())
b = [int(input()) for i in range(N)]
B = np.array([[0]*3 for i in range(3)])
for _ in b:
    for t in range(3):
        for y in range(3):
            if A[t][y] == _:
                B[t][y] = 1
ans = "No"
for i in range(3):
    if all(B[i] == [1,1,1]):
        ans ="Yes"
    if all(B[:,i] == [1,1,1]):
        ans ="Yes"
if B[0,0] == 1 and B[1,1] == 1 and B[2,2] == 1:
    ans ="Yes"
if B[2,0] == 1 and B[1,1] == 1 and B[0,2] == 1:
    ans ="Yes"
print(ans)

Solution (Python):
import sys
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):
    if b in A[j]:
      for k in range(3):
        if A[j][k]==b:
          A[j][k]=0
if A[0][0] == 0 and A[1][1] ==0 and A[2][2]==0:
  print("Yes")
  sys.exit(0)
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  sys.exit(0)
for i in range(3):
  for j in range(3):
    if A[i][j]==0:
      if j!=2:
        continue
      else:
        print("Yes")
        sys.exit(0)
    else:
      break
for i in range(3):
  for j in range(3):
    if A[j][i]==0:
      if j!=2:
        continue
      else:
        print("Yes")
        sys.exit(0)
    else:
      break
print("No")

Solution (Python):
list=[input()for i in range(4)]

list1=list[0].split()
list2=list[1].split()
list3=list[2].split()
list1=[int(i) for i in list1]
list2=[int(i) for i in list2]
list3=[int(i) for i in list3]
c=int(list[3])
b=[input()for i in range(c)]
b=[int(i) for i in b]

for i in b:
    for x in range(3):
        if i==list1[x]:
            list1[x]=0
        elif i==list2[x]:
            list2[x]=0
        elif i==list3[x]:
            list3[x]=0

list4=[list1[0],list2[0],list3[0]]
list5=[list1[1],list2[1],list3[1]]
list6=[list1[2],list2[2],list3[2]]
list7=[list1[0],list2[1],list3[2]]
list8=[list1[2],list2[1],list3[0]]
if sum(list1)==0 or sum(list2)==0 or sum(list3)==0 or sum(list4)==0 or sum(list5)==0 or sum(list6)==0 or sum(list7)==0 or sum(list8)==0:
    an="Yes"
else:
    an="No"
print(an)

Solution (Python):
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
a4 = set()
a5 = set()
a6 = set()
a7 = set()
a8 = set()
a4.update({a1[0],a2[1],a3[2]})
a5.update({a1[2],a2[1],a3[0]})
a6.update({a1[0],a2[0],a3[0]})
a7.update({a1[1],a2[1],a3[1]})
a8.update({a1[2],a2[2],a3[2]})
n = int(input())
B =set()
for i in range(n):
    b = int(input())
    B.add(b)
if set(a1) <= B or set(a2) <= B or set(a3) <= B or a4 <= B or a5 <= B or a6 <= B or a7 <= B or a8 <= B:
    print('Yes')
else:
    print('No')