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 = [[] for _ in range(3)]
for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
b_arr = [int(input()) for _ in range(n)] 
for b in b_arr:
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0
isB = False
for c in range(3):
    if a[0][c] + a[1][c] + a[2][c] == 0:
        isB = True
for r in range(3):
    if a[r][0] + a[r][1] + a[r][2] == 0:
        isB = True
if a[0][0] + a[1][1] + a[2][2] == 0:
    isB = True
if a[0][2] + a[1][1] + a[2][0] == 0:
    isB = True
print("Yes" if isB else "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):
        for m in range(n):
            if b[m] == a[i][j] :
                a[i][j]=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[0][2]==a[1][1]==a[2][0]:
    print("Yes")
else :
    print("No")

Solution (Python):
seat = [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 seat[j][k] == b:
                seat[j][k] = 0
for i in range(3):
    if seat[i].count(0) == 3:
        print('Yes')
        exit()
for i in range(3):
    for j in range(3):
        if seat[j][i] != 0:
            break
    else:
        print('Yes')
        exit()
if seat[0][0] == seat[1][1] == seat[2][2] == 0:
    print('Yes')
    exit()
if seat[0][2] == seat[1][1] == seat[2][0] == 0:
    print('Yes')
    exit()
print('No')

Solution (Python):

import numpy as np

def check(board):
    for i in range(3):
        if min(board[i]) == 1:
            return True
        if min(board[:, i]) == 1:
            return True
        if min(np.diag(board)) == 1:
            return True
        if board[0][2] == board[1][1] == board[2][0] == 1:
            return True
    return False


A = np.array([list(map(int, input().split())) for _ in range(3)])
N = int(input())
board = np.zeros((3, 3))
for i in range(N):
    B = int(input())
    board[np.where(A == B)] = 1
if check(board):
    print('Yes')
else:
    print('No')

Solution (Python):
A = []

for i in range(3):
    A.extend(input().split())

n = int(input())

for i in range(n):
    com = input()
    if com in A:
        A[A.index(com)] = '0'

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

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

n = int(input())
for _ in range(n):
    b = int(input())
    if b in A:
        i = A.index(b)
        A[i] = 0

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

Solution (Python):
AList = list(map(int, input().split()))
BList = list(map(int, input().split()))
CList = list(map(int, input().split()))
N = int(input())
DList = [int(input()) for i in range(N)]

def Bcheck(AList,BList,CList):
    if AList[0]=="x" and AList[1]=="x" and AList[2]=="x":
        return "bingo"
    elif BList[0]=="x" and BList[1]=="x" and BList[2]=="x":
        return "bingo"
    elif CList[0]=="x" and CList[1]=="x" and CList[2]=="x":
        return "bingo"
    elif AList[0]=="x" and BList[0]=="x" and CList[0]=="x":
        return "bingo"
    elif AList[1]=="x" and BList[1]=="x" and CList[1]=="x":
        return "bingo"
    elif AList[2]=="x" and BList[2]=="x" and CList[2]=="x":
        return "bingo"
    elif AList[0]=="x" and BList[1]=="x" and CList[2]=="x":
        return "bingo"
    elif AList[2]=="x" and BList[1]=="x" and CList[0]=="x":
        return "bingo"
    else:
        return 0

i=0
while i<N:
    if AList.count(DList[i])!=0:
        AList[(AList.index(DList[i]))]="x"
    elif BList.count(DList[i])!=0:
        BList[(BList.index(DList[i]))]="x"
    elif CList.count(DList[i])!=0:
        CList[(CList.index(DList[i]))]="x"
        
    if Bcheck(AList,BList,CList)=="bingo":
        print("Yes")
        quit()

    i+=1

print("No")

Solution (Python):
numbers = []
numbers.extend(list(map(int, input().split(' '))))
numbers.extend(list(map(int, input().split(' '))))
numbers.extend(list(map(int, input().split(' '))))
N = int(input())
answers = set()
for _ in range(N):
    answers.add(int(input()))

results = [False] * 9

for i in range(len(numbers)):
    if numbers[i] in answers:
        results[i] = True

if all(results[0:3]) or all(results[3:6]) or all(results[6:9]):
    print('Yes')
elif all(results[0::3]) or all(results[1::3]) or all(results[2::3]):
    print('Yes')
elif all((results[0], results[4], results[8])) or all((results[2], results[4], results[6])):
    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(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")
        exit()
    if (A[0][i] == A[1][i] == A[2][i] == 0):
        print("Yes")
        exit()
if (A[0][0] == A[1][1] == A[2][2] == 0):
    print("Yes")
    exit()
elif(A[0][2] == A[1][1] == A[2][0] == 0):
    print("Yes")
    exit()
print("No")

Solution (Python):

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


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

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

Solution (Python):
dic = {}
for i in range(3):
  arr = input().split()
  for j in range(3):
    dic[arr[j]] = (i,j)
    
n = int(input())
appear=[[False for _ in range(3)] for __ in range(3)]

for _ in range(n):
  b = input()
  if b in dic:
    i, j = dic[b]
    appear[i][j] = True

ans = 'No'
for i in range(3):
  if appear[i][0] and appear[i][1] and appear[i][2]:
    ans = 'Yes'
    break
  if appear[0][i] and appear[1][i] and appear[2][i]:
    ans = 'Yes'
    break
if appear[0][0] and appear[1][1] and appear[2][2]:
  ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
  ans = 'Yes'
print(ans)

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

con1 = A1[0] in B and A1[1] in B and A1[2] in B
con2 = A2[0] in B and A2[1] in B and A2[2] in B
con3 = A3[0] in B and A3[1] in B and A3[2] in B
con4 = A1[0] in B and A2[0] in B and A3[0] in B
con5 = A1[1] in B and A2[1] in B and A3[1] in B
con6 = A1[2] in B and A2[2] in B and A3[2] in B
con7 = A1[0] in B and A2[1] in B and A3[2] in B
con8 = A1[2] in B and A2[1] in B and A3[0] in B

if (con1 or con2 or con3 or con4 or con5 or con6 or con7 or con8):
    print("Yes")
else:
    print("No")

Solution (Python):
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
a = [] 
x = [[0] * 3 for i in range(3)]
for i in range(3):
    a.append([int(x) for x in input().split()])
n = iin()
b = [0] * n
for i in range(n):
    b[i] = iin()

for i in range(3):
    for j in range(3):
        for f in range(n):
            if a[i][j] == b[f]:
                x[i][j] = 1
for i in range(3):
    if sum(x[i]) == 3:
        neko = neko + 1
    nya = x[0][i] + x[1][i] + x[2][i]
    if nya == 3:
        neko = neko + 1
nya = x[0][0]+ x[1][1] + x[2][2]
if nya == 3:
    neko = neko + 1
nya = x[0][2]+ x[1][1] + x[2][0]
if nya == 3:
    neko = neko + 1
if neko > 0:
    py()
else:
    pn()

Solution (Python):
import sys

a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
n=int(input())
d=[int(input())for _ in range(n)]
lsa,lsb,lsc=[0]*3,[0]*3,[0]*3

for i in d:
  if i in a:
    lsa[a.index(i)]+=1
    
  elif i in b:
    lsb[b.index(i)]+=1
    
  elif i in c:
    lsc[c.index(i)]+=1
    
if all(i>=1 for i in lsa):
  print("Yes")
  sys.exit()
  
elif all(i>=1 for i in lsb):
  print("Yes")
  sys.exit()
  
elif all(i>=1 for i in lsc):
  print("Yes")
  sys.exit()
  
for i in range(3):
  if lsa[i]>=1 and lsb[i]>=1 and lsc[i]>=1:
    print("Yes")
    sys.exit()
    
if lsa[0]>=1 and lsb[1]>=1 and lsc[2]>=1 or lsa[2]>=1 and lsb[1]>=1 and lsc[0]>=1:
  print("Yes")
  sys.exit()
  
print("No")

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    a = [list(map(int, stdin.readline().split())) for _ in range(3)]
    n = int(stdin.readline())
    b = [int(stdin.readline()) for _ in range(n)]

    bg = []
    for i in range(3):
        bg.append(a[i])
        bg.append([a[0][i], a[1][i], a[2][i]])
    bg.append([a[i][i] for i in range(3)])
    bg.append([a[i][2 - i] for i in range(3)])

    for bgi in bg:
        if len(list(set(bgi) - set(b))) == 0:
            print('Yes')
            exit()

    print('No')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

flag = False
for i in range(3):
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        flag = True
        break
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        flag = True
        break
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    flag = True
    
print("Yes" if flag else "No")

Solution (Python):
import numpy as np

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

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

at = a.transpose()
flag = False
for i in range(3):
    if sum(a[:][i]) == 0 or sum(at[:][i]) == 0:
        flag = True
        break
diag = a[0][0] + a[1][1] + a[2][2]
diag2 = a[2][0] + a[1][1] + a[0][2]
if diag == 0 or diag2 == 0:
    flag = True

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

Solution (Python):
B = {}
for i in range(3):
    for j, e in enumerate(input().split()):
        B[e] = (i, j)

L = []
for i in range(8):
    L.append(0)
        
N = int(input())
for i in range(N):
    b = input()
    if b in B:
        L[B[b][0] % 3] += 1
        L[(B[b][0] * 3 + B[b][1]) % 3 + 3] += 1
        if B[b][0] == B[b][1]:
            L[6] += 1
            if B[b][0] == 1:
                L[7] += 1
        elif abs(B[b][0] - B[b][1]) == 2:
            L[7] += 1
            
if 3 in L:
    print('Yes')
else:
    print('No')

Solution (Python):
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
l3 = list(map(int,input().split()))
n = int(input())
A = [int(input()) for _ in range(n)]
l4 = []
l5 = []
l6 = []
l7 = []
l8 = []
l4 += [l1[0],l2[0],l3[0]]
l5 += [l1[1],l2[1],l3[1]]
l6 += [l1[2],l2[2],l3[2]]
l7 += [l1[0],l2[1],l3[2]]
l8 += [l1[2],l2[1],l3[0]]
l = []
l += [l1,l2,l3,l4,l5,l6,l7,l8]
for i in A:
    for k in l:
        if i in k:
            k.remove(i)

count=0
for j in l:
    if len(j)==0:
        count += 1
if count == 0:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys

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

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[i][j] in b:
            cnt += 1
    if cnt == 3:
        print("Yes")
        sys.exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[j][i] in b:
            cnt += 1
    if cnt == 3:
        print("Yes")
        sys.exit()
    
cnt = 0
for i in range(3):
    if a[i][i] in b:
        cnt += 1
if cnt == 3:
    print("Yes")
    sys.exit()

cnt = 0
for i in range(3):
    if a[i][2-i] in b:
        cnt += 1
if cnt == 3:
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
def my_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default


list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
list3 = list(map(int, input().split()))
N = int(input())
num_list = [int(input()) for _ in range(N)]

list1.extend(list2)
list1.extend(list3)
hit_list = [0] * 9

for num in num_list:
    res = my_index(list1, num)
    if res != -1:
        hit_list[res] += 1

if (hit_list[0] > 0 and hit_list[1] > 0 and hit_list[2] > 0) or (
        hit_list[3] > 0 and hit_list[4] > 0 and hit_list[5] > 0) or (
        hit_list[6] > 0 and hit_list[7] > 0 and hit_list[8] > 0):
    print('Yes')
elif (hit_list[0] > 0 and hit_list[3] > 0 and hit_list[6] > 0) or (
        hit_list[1] > 0 and hit_list[4] > 0 and hit_list[7] > 0) or (
        hit_list[2] > 0 and hit_list[5] > 0 and hit_list[8] > 0):
    print('Yes')
elif (hit_list[0] > 0 and hit_list[4] > 0 and hit_list[8] > 0) or (
        hit_list[2] > 0 and hit_list[4] > 0 and hit_list[6] > 0):
    print('Yes')
else:
    print('No')

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

for i in range(N):
    B = input()
    for k in range(3):
        for m in range(3):
            if A[k][m] == B:
                A[k][m] = '-1'


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

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

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

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

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

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

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

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


print('No')

Solution (Python):
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 a:
        if b in j:
            a[a.index(j)][j.index(b)] = 0

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

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

Solution (Python):
import collections

mat = [map(int,raw_input().split(' ')) for _ in range(3)]
d = {mat[i][j] : (i,j) for i in range(3) for j in range(3)} 
n = int(raw_input())

cols = collections.Counter()
rows = collections.Counter()
ac = collections.Counter()
cc = collections.Counter()
flag = False
for __ in range(n):
	h = d.get(int(raw_input()), None)
	if h is not None:
		i,j = h
		cols[j]+=1
		rows[i]+=1
		if i == j: cc[0]+=1
		if j == 2- i: ac[0]+=1
		
		if (cols[j] == 3) or (rows[i] == 3) or (cc[0] == 3) or (ac[0] == 3):
			flag = True
			break
print 'Yes' if flag else 'No'

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


def main():
    A = [list(map(int, input().split()))for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for bn in B:
        for i in range(len(A)):
            for j in range(len(A[i])):
                if bn == A[i][j]:
                    A[i][j] = 0
    for m in range(len(A)):
        if all(A[m][n] == 0 for n in range(len(A))):
            print("Yes")
            exit()
        if all(A[n][m] == 0 for n in range(len(A))):
            print("Yes")
            exit()
        if all(A[n][n] == 0 for n in range(len(A))):
            print("Yes")
            exit()
        if all(A[n][len(A)-n-1] == 0 for n in range(len(A))):
            print("Yes")
            exit()
    print("No")


if __name__ == '__main__':
    main()

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

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

candidates = []

for i in range(len(card)):
    candidates.append(card[i])

for i in range(len(card[0])):
    candidates.append([card[j][i] for j in range(len(card))])

candidates.append([card[0][0], card[1][1], card[2][2]])
candidates.append([card[0][2], card[1][1], card[2][0]])

if any([all([num in b for num in c]) for c in candidates]):
    print("Yes")
else:
    print("No")

Solution (Python):
A = sum([list(map(int, input().split())) for i in range(3)], [])
N = int(input())
b = [int(input()) for i in range(N)]
card = [False for j in range(9)]

def bingo_check(card):
    naname = (card[0] and card[4] and card[8]) \
                or (card[2] and card[4] and card[6])
    yoko = all(card[0:3]) or all(card[3:6]) or all(card[6:9])
    tate = all(card[0::3]) or all(card[1::3]) or all(card[2::3])
    return naname or yoko or tate

for i in range(N):
    if b[i] in A:
        index = A.index(b[i])
        card[index] = True

print('Yes' if bingo_check(card) else '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):
        for b in B:
            if A[i][j] == b:
                A[i][j] = 0
ans = 'No'
for i in range(3):
    if (A[i][0] + A[i][1] + A[i][2] == 0) or (A[0][i] + A[1][i] + A[2][i] == 0) or (A[0][0] + A[1][1] + A[2][2] == 0) or (A[0][2] + A[1][1] + A[2][0] == 0):
        ans = 'Yes'
print(ans)

Solution (Python):



import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])

for pn in pickup_number:
    a[a == pn] = -1

flag = False
if -3 in np.sum(a, axis=0) or -3 in np.sum(a, axis=1):
    flag = True
if np.sum(a.diagonal()) == -3 or a[0][2] + a[1][1] + a[2][0] == -3:
    flag = True

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

Solution (Python):
import sys
bingo = list(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 bingo[i][j] == b:
                bingo[i][j] = False
for i in range(3):
    for j in range(3):
        if bingo[i][j]:
            break
    else:
        print('Yes')
        exit()

for j in range(3):
    for i in range(3):
        if bingo[i][j]:
            break
    else:
        print('Yes')
        exit()

for i in range(3):
    if bingo[i][i]:
        break
else:
    print('Yes')
    exit()

for i in range(3):
    if bingo[i][2 - i]:
        break
else:
    print('Yes')
    exit()

print('No')

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

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

p1 = [False]*3
p2 = [False]*3
p3 = [False]*3

for i in b:
  if i in a1:
    p1[a1.index(i)] = True
  if i in a2:
    p2[a2.index(i)] = True
  if i in a3:
    p3[a3.index(i)] = True
    
if all(p1) or all(p2) or all(p3):
  print("Yes")
  exit()
  
for i in range(3):
  if all([p1[i],p2[i],p3[i]]):
    print("Yes")
    exit()
  
if all([p1[0],p2[1],p3[2]]):
  print("Yes")
  exit()
  
if all([p1[2],p2[1],p3[0]]):
  print("Yes")
  exit()
  
print("No")

Solution (Python):
Ai_j = []
for i in range(3):
    Ai_j.append(list(map(int,input().split())))
N = int(input())
number_list = []
for i in range(N):
    number_list.append(int(input()))
'''
print(Ai_j)
print(N)
print(number_list)
'''

for x in number_list:
    for i in range(3):
        for j in range(3):
           if  Ai_j[i][j] == x:
               Ai_j[i][j] = '○'


count = 0

if Ai_j[0][0] == Ai_j[0][2] == Ai_j[0][1] == '○': count+=1
if Ai_j[1][0] == Ai_j[1][2] == Ai_j[1][1] == '○': count+=1
if Ai_j[2][0] == Ai_j[2][2] == Ai_j[2][1] == '○': count+=1
if Ai_j[0][0] == Ai_j[1][0] == Ai_j[2][0] == '○': count+=1
if Ai_j[0][1] == Ai_j[1][1] == Ai_j[2][1] == '○': count+=1
if Ai_j[0][2] == Ai_j[1][2] == Ai_j[2][2] == '○': count+=1
if Ai_j[0][0] == Ai_j[1][1] == Ai_j[2][2] == '○': count+=1
if Ai_j[0][2] == Ai_j[1][1] == Ai_j[2][0] == '○': count+=1

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

Solution (Python):
a1 = list(input().split())
a2 = list(input().split())
a3 = list(input().split())
n = int(input())
b = [input() for _ in range(n)]
x = []
x.append(a1)
x.append(a2)
x.append(a3)
y = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if x[i][j] == b[k]:
                y[i][j] = 1
if y[0] == [1, 1, 1] or y[1] == [1, 1, 1] or y[2] == [1, 1, 1]:
    print('Yes')
elif y[0][0] == 1 and y[1][0] == 1 and y[2][0] == 1:
    print('Yes')
elif y[0][1] == 1 and y[1][1] == 1 and y[2][1] == 1:
    print('Yes')
elif y[0][2] == 1 and y[1][2] == 1 and y[2][2] == 1:
    print('Yes')
elif y[0][0] == 1 and y[1][1] == 1 and y[2][2] == 1:
    print('Yes')
elif y[0][2] == 1 and y[1][1] == 1 and y[2][0] == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
import sys
a_list = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
 
for _ in range(n):
    b = int(input())
    
    for a in a_list:
        for idx, aa in enumerate(a):
            if aa == b:
                a[idx] = 0


for i in range(3):
    if list(a_list[i, :]) == [0, 0, 0] or list(a_list[:, i]) == [0, 0, 0]:
        print("Yes")
        sys.exit()
    


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

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 = [0]*3

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

n = int(n)
b_ = [0]*n
for i in range(0,n):
  b_[i] = input()
 
b = [int(i) for i in b_]

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

if(sum(a[0])==30000 or sum(a[1])==30000 or sum(a[2])==30000):
  print("Yes")
  exit()
elif(a[0][0] + a[1][1] + a[2][2] ==30000 or a[0][2] + a[1][1] + a[0][2]== 30000):
  print("Yes")
  exit()
elif(a[0][0] + a[1][0] + a[2][0] == 30000 or a[0][1] + a[1][1] + a[2][1] == 30000 or a[0][2] + a[1][2] + a[2][2] == 30000):
  print("Yes")
  exit()
else:
  print("No")

Solution (Python):
card = [list(map(int,input().split())) for c in range(3)]
N = int(input())
nums = [int(input()) for n in range(N)]
ans =0
ind = [[False,False,False],[False,False,False],[False,False,False]]

for index,c in enumerate(card):
	for index2,c2 in enumerate(c):
		for n in nums:
			if n == c2:
				ind[index][index2] = True

if (ind[0][0] == True and ind[1][1] == True and ind[2][2] == True) or \
	(ind[0][2] == True and ind[1][1] == True and ind[2][0] == True)  or \
	(ind[0][0] == True and ind[1][0] == True and ind[2][0] == True)  or \
	(ind[0][1] == True and ind[1][1] == True and ind[2][2] == True)  or \
	(ind[0][2] == True and ind[1][2] == True and ind[2][2] == True)  or \
	(ind[0][0] == True and ind[0][1] == True and ind[0][2] == True)  or \
	(ind[1][0] == True and ind[1][1] == True and ind[1][2] == True)  or \
	(ind[2][0] == True and ind[2][1] == True and ind[2][2] == True):
  	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())
b = [int(input()) for i in range(n)]
c = [[0 for i in range(3)] for j in range(3)]
f = False

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

for i in range(3):
	if c[i][0] + c[i][1] + c[i][2] == 3:
		f = True
		break
	elif c[0][i] + c[1][i] + c[2][i] == 3:
		f = True
		break
	elif c[2][0] + c[1][1] + c[0][2] == 3 or c[0][0] + c[1][1] + c[2][2] == 3:
		f = True
		break
if f:
	print('Yes')
else:
	print('No')

Solution (Python):

"""
Created on Thu May  7 14:17:13 2020

@author: shinba
"""
import sys

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

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

print("No")

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
Am = [A1[0], A2[1], A3[2]]
Al = [A1[2], A2[1], A3[0]]
n = int(input())
B = []
for k in range(n):
    b = int(input())
    B.append(b)

for i in range(3):
    chk1 = A1[i]
    chk2 = A2[i]
    chk3 = A3[i]
    if chk1 in B:
        if chk2 in B:
            if chk3 in B:
                print('Yes')
                exit()

cnt = 0
for j in A1:
    if j in B:
        cnt += 1
if cnt == 3:
    print('Yes')
    exit()

cnt = 0
for j in A2:
    if j in B:
        cnt += 1
if cnt == 3:
    print('Yes')
    exit()

cnt = 0
for j in A3:
    if j in B:
        cnt += 1
if cnt == 3:
    print('Yes')
    exit()

cnt = 0
for j in Am:
    if j in B:
        cnt += 1
if cnt == 3:
    print('Yes')
    exit()

cnt = 0
for j in Al:
    if j in B:
        cnt += 1
if cnt == 3:
    print('Yes')
    exit()

print('No')

Solution (Python):
def isbingo(ls:list) -> bool:
    for x in ls:
        if set(x)=={0}:return 0
    for x in range(3):
        if ls[0][x] == ls[1][x] == ls[2][x]:return 0
    if ls[0][0] == ls[1][1] == ls[2][2]:return 0
    if ls[0][2] == ls[1][1] == ls[2][0]:return 0
    return 1
a,b,c=(list(map(int,input().split()))for _ in'___')
p=list(map(int,(input()for _ in [0]*int(input()))));a = [a,b,c]
for x in range(3):
    for y in range(3):
        if a[x][y] in p:a[x][y] = 0
print("YNeos"[isbingo(a)::2])

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]=0
ans='No'
for i in range(3):
    if A[i].count(0)==3:
        ans='Yes'
for i in range(3):
    temp=[A[0][i],A[1][i],A[2][i]]
    if temp.count(0)==3:
        ans='Yes'
if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    ans='Yes'
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    ans='Yes'
print(ans)

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

N = int(input())

for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
        called_row = exist_list.index(True)
        A[called_row] = [0 if x==called_num else x for x in A[called_row]]
        
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] 

if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: 
    print('Yes')
else:
    print('No')

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
s = list(map(int, [input() for i in range(n)]))
l = [
  [0, 0, 0]
  , [0, 0, 0]
  , [0, 0, 0]
]
for i in range(0, 3):
  for j in range(0, n):
    if a1[i] == s[j]:
      l[0][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a2[i] == s[j]:
      l[1][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a3[i] == s[j]:
      l[2][i] = i+1
n = []
for i in l:
  for j in i:
    if j != 0:
      n.append(j)
count = 0
for i in range(0, 3):
  if l[i][0] and l[i][1] and l[i][2]:
    count += 1
if (l[0][0] and l[1][1] and l[2][2]) or (l[2][0] and l[1][1] and l[0][2]):
  count += 1
else:
  for i in range(1, 4):
    if n.count(i) == 3:
      count += 1
print('Yes' if count >= 1 else 'No')