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 _ in range(3)]
n = int(input())
b = list([int(input()) for _ in range(n)])
ans = "No"


for bi in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == bi:
                a[i][j] = "hole"


for j in range(3):
    if a[0][j] == "hole":
        if a[1][j] == "hole" and a[2][j] == "hole":
            ans = "Yes"


for i in range(3):
    if a[i][0] == "hole":
        if a[i][1] == "hole" and a[i][2] == "hole":
            ans = "Yes"


if a[0][0] == "hole" and a[1][1] == "hole" and a[2][2] == "hole":
    ans = "Yes"
if a[0][2] == "hole" and a[1][1] == "hole" and a[2][0] == "hole":
    ans = "Yes"

print(ans)

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

N = int(input())

for n in range(N):
    b = int(input())
    flag = False
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1
                flag = True
                break
        if flag:
            break

C = [0]*8
for i in range(3):
    for j in range(3):
        if i == j:
            C[6] += B[i][j]
        if i+j==2:
            C[7] += B[i][j]
        C[i] += B[i][j]
        C[j+3] += B[i][j]

for i in range(8):
    if C[i]==3:
        print('Yes')
        break
    if i == 7:
        print('No')

Solution (Python):
A = list(input().split() for i in range(3))
n = int(input())
r1 = set(A[0])
r2 = set(A[1])
r3 = set(A[2])
c1 = {A[0][0], A[1][0], A[2][0]}
c2 = {A[0][1], A[1][1], A[2][1]}
c3 = {A[0][2], A[1][2], A[2][2]}
d1 = {A[0][0], A[1][1], A[2][2]}
d2 = {A[0][2], A[1][1], A[2][0]}
b = set(input() for i in range(n))
if r1.issubset(b) or r2.issubset(b) or r3.issubset(b) or c1.issubset(b) or c2.issubset(b) or c3.issubset(b) or d1.issubset(b) or d2.issubset(b):
    print('Yes')
else:
    print('No')

Solution (Python):
a1,a2,a3,_,*b = [i.split() for i in open(0)]
bingo = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [2, 5, 8], [0, 3, 6], [1, 4, 7], [0, 4, 8], [2, 4, 6]]
s = ["" if i in sum(b,[]) else i for i in a1 + a2 + a3]
for i,j,k in bingo:
    if {s[i],s[j],s[k]} ==  {''}:
        print('Yes')
        exit()
print('No')

Solution (Python):
A = [input().split() for l in range(3)]
N = int(input())
B = [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] = 1
		else: A[i][j] = 0

def bingo(A):
	for i in range(3):
		tmp = 0 
		for j in range(3):
			tmp += A[i][j]
		if tmp == 3:
			return True

	for i in range(3):
		tmp = 0 
		for j in range(3):
			tmp += A[j][i]
		if tmp == 3:
			return True

	if A[0][2] + A[1][1] + A[2][0] == 3 or A[0][0] + A[1][1] + A[2][2] == 3:
		return True

	else:
		return False


if bingo(A):
	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)]

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

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

for h in result:
    if 0 not in h:
        print("Yes")
        exit()

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

if result[0][0] == result[1][1] == result[2][2] == 1:
    print("Yes")
    exit()

if result[0][2] == result[1][1] == result [2][0] == 1:
    print("Yes")
    exit()

print("No")

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

for _ in range(n):
    b = int(input())
    for i, row in enumerate(a):
        for j, col in enumerate(row):
            if a[i][j]==b:
                bingo[i][j]=True

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

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

print('No')

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def isBingoYoko(ans):
    for bool_i_list in ans:
        for bj in bool_i_list:
            if bj==False:
                break
            else:
                pass
        else:
            print("Yes")
            exit(0)

def isBingoNaname(ans):
    if (ans[0][0] and ans[1][1] and ans[2][2]) or ((ans[0][2] and ans[1][1] and ans[2][0])):
        print("Yes")
        exit(0)
    else:
        pass

def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    ans = [[False for _ in range(3)] for _ in range(3)]
    for b in B:
        for i in range(len(A)):
            if b in A[i]:
                j = A[i].index(b)
                ans[i][j] = True

    isBingoYoko(ans)
    isBingoYoko(list(numpy.array(ans).T))
    isBingoNaname(ans)
    print("No")

main()

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def isBingoYoko(ans):
    for bool_i_list in ans:
        for bj in bool_i_list:
            
            if bj==False:
                break
            else:
                pass
        else:
            print("Yes")
            exit(0)

def isBingoNaname(ans):
    if (ans[0][0] and ans[1][1] and ans[2][2]) or ((ans[0][2] and ans[1][1] and ans[2][0])):
        print("Yes")
        exit(0)
    else:
        pass

def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    ans = [[False for _ in range(3)] for _ in range(3)]
    for b in B:
        for i in range(len(A)):
            if b in A[i]:
                j = A[i].index(b)
                ans[i][j] = True

    isBingoYoko(ans)
    isBingoYoko(list(numpy.array(ans).T))
    isBingoNaname(ans)
    print("No")

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

Solution (Python):
al = []
ans = 'No'
for i in range(3):
    al.append(list(map(int, input().split())))
n = int(input())
bl = [int(input()) for i in range(n)]
for i in bl:
    for a in al:
        if i in a:
            a[a.index(i)]=0           
t1 = al[0][0]+al[1][1]+al[2][2]
t2 = al[0][2]+al[1][1]+al[2][0]
if t1 ==0 or t2==0:
    ans = 'Yes'
else:
    for a in al:
        if sum(a)==0:
            ans = 'Yes'
            break
        else:
            for va in zip(*al):
                if sum(va)==0:
                    ans = 'Yes'
                    break
print(ans)

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

ans=[[0,0,0],[0,0,0],[0,0,0]]

flag=True

for j in range(N):
    for row in range(3):
        for col in range(3):
            if bingolist[j]==List[row][col]:
                ans[row][col]=1
for i in range(3):
    if ans[i][0]*ans[i][1]*ans[i][2]==1:
        print('Yes')
        flag=False
        break
    elif ans[0][i]*ans[1][i]*ans[2][i]:
        print('Yes')
        flag=False
        break
    elif ans[0][0]*ans[1][1]*ans[2][2]==1:
        print('Yes')
        flag=False
        break
    elif ans[0][2]*ans[1][1]*ans[2][0]==1:
        print('Yes')
        flag=False
        break
if flag:
    print('No')

Solution (Python):






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





cnddt = []
for i in range(len(A)):
    cnddt.append(A[i])
for i in range(len(A)):
    cnddt.append([x[i] for x in A])
cnddt.append([A[0][0],A[1][1],A[2][2]])
cnddt.append([A[0][2],A[1][1],A[2][0]])

for i,cnddt_i in enumerate(cnddt):
    mylist = [x for x in cnddt_i if x not in b]

    if len(mylist) == 0:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
def B():
    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 all(a[i][i] == 1 for i in range(3)) or (a[0][2] == a[1][1] == a[2][0] == 1):
        print("Yes")
        return
    else:
        for i in range(3):
            if all(a[i][j] == 1 for j in range(3)) or all(a[j][i] == 1 for j in range(3)):
                print("Yes")
                return

    print("No")

B()

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

xx = sum(x, [])

tate1 = xx[0:9:3]
tate2 = xx[1:9:3]
tate3 = xx[2:9:3]
yoko1 = xx[0:3]
yoko2 = xx[3:6]
yoko3 = xx[6:9]
nana1 = xx[0:9:4]
nana2 = xx[2:7:2]

if rows >= 3 and (set(tate1) <= set(y) or set(tate2) <= set(y) or set(tate3) <= set(y) or set(yoko1) <= set(y) or set(yoko2) <= set(y) or set(yoko3) <= set(y) or set(nana1) <= set(y) or set(nana2) <= set(y)):
    print("Yes")
else:
    print("No")

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

for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                ls[i][j] = 1

for i in range(3):
    if sum(ls[i]) == 3:
        print('Yes')
        exit()
    if ls[0][i]*ls[1][i]*ls[2][i] == 1:
        print('Yes')
        exit()

if ls[0][0]*ls[1][1]*ls[2][2] == 1:
    print('Yes')
    exit()

if ls[0][2]*ls[1][1]*ls[2][0] == 1:
    print('Yes')
    exit()

print('No')

Solution (Python):
import numpy as np

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

A = np.array(A)
flag = False
for a in A:
    if a.sum() == 0:
        flag = True
for a in A.T:
    if a.sum() == 0:
        flag = True

if np.diag(A).sum()==0:
    flag = True
if np.diag(np.fliplr(A)).sum()==0:
    flag = True

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

Solution (Python):

import math
ls=[]
for i in range(3):
    ls.append(list(map(int,input().split())))
ans=[[0,0,0],[0,0,0],[0,0,0]]
n=int(input())
for i in range(n):
    a=int(input())
    for j in range(3):
        for k in range(3):
            if a==ls[j][k]:
                ans[j][k]=1
res=[]
for i in range(3):
    total=0
    for j in range(3):
        total+=ans[i][j]
    res.append(total)
var=0
while var<3:
    total=0
    for i in range(3):
        total+=ans[i][var]
    var+=1
    res.append(total)
res.append(ans[0][0]+ans[1][1]+ans[2][2])
res.append(ans[0][2]+ans[1][1]+ans[2][0])
res.sort()


if res[len(res)-1]==3:
    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 = set(b)

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

ck = 0
for i in range(3):
  if a[i] == [0,0,0]:
    ck = 1
    break
  if ( a[0][i],a[1][i],a[2][i] ) == (0,0,0):
    ck = 1
    break

if ( a[0][0],a[1][1],a[2][2] ) == (0,0,0):
  ck = 1
if ( a[2][0],a[1][1],a[0][2] ) == (0,0,0):
  ck = 1

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

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
	x = int(input())
	for h in range(3):
		for w in range(3):
			if a[h][w] == x:
				a[h][w] = 0
for i in range(3):
	if a[i][0] == a[i][1] == a[i][2] == 0:
		print("Yes")
		exit()
	elif 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")
elif a[2][0] == a[1][1] == a[0][2] == 0:
	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()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

A = [LI() for i in range(3)]
N = I()
b = [I() for i in range(N)]

B = [[0]*3 for i in range(3)]  

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

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

print('No')

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


def bingo(i):
    if i in d:
        return True
    else:
        return False

if bingo(a[0]) and bingo(a[1]) and bingo(a[2]):
    print('Yes')
elif bingo(b[0]) and bingo(b[1]) and bingo(b[2]):
    print('Yes')
elif bingo(c[0]) and bingo(c[1]) and bingo(c[2]):
    print('Yes')
elif bingo(a[1]) and bingo(b[1]) and bingo(c[1]):
    print('Yes')
elif bingo(a[0]) and bingo(b[0]) and bingo(c[0]):
    print('Yes')
elif bingo(a[2]) and bingo(b[2]) and bingo(c[2]):
    print('Yes')
elif bingo(a[2]) and bingo(b[1]) and bingo(c[0]):
    print('Yes')
elif bingo(a[0]) and bingo(b[1]) and bingo(c[2]):
    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()))

A = A1 + A2 + A3
N = int(input())

index = []
for i in range(N):
    inp = int(input())
    if inp in A:
        index.append(A.index(inp))

if \
   (0 in index and 3 in index and 6 in index) or \
   (1 in index and 4 in index and 7 in index) or \
   (2 in index and 5 in index and 8 in index) or \
   (0 in index and 4 in index and 8 in index) or \
   (2 in index and 4 in index and 6 in index) or \
   (0 in index and 1 in index and 2 in index) or \
   (3 in index and 4 in index and 5 in index) or \
   (6 in index and 7 in index and 8 in index):
    print("Yes")
else:
    print("No")

Solution (Python):
l=[0]*3
for i in range(3):
    a=list(map(int,input().split()))
    l[i]=a
n=int(input())
bingo=[[1]*3 for _ in range(3)]
b=[]
for i in range(n):
    B=int(input())
    b.append(B)
for i in range(3):
    for j in range(3):
        if l[i][j] in b:
            bingo[i][j]=0
x=0
cnt1=0
cnt2=0
cnt3=0
nana1=0
nana2=0
for i in range(3):
    if sum(bingo[i])==0:
        print("Yes")
        x=1
        break
    cnt1+=bingo[i][0]
    cnt2+=bingo[i][1]
    cnt3+=bingo[i][2]
    nana1+=bingo[i][i]
    nana2+=bingo[i][2-i]
if x==0:
    if cnt1==0 or cnt2==0 or cnt3==0 or nana1==0 or nana2==0:
        print("Yes")
    else:
        print("No")

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

n = int(input())

b = []

for j in range(n):
    b.append(int(input()))
    
for k in range(9):
    for l in b:
        if bingo[k] == l:
            bingo[k] = 0
            
flag = 0

if (bingo[0] == 0 and bingo[1] == 0 and bingo[2] == 0) or (bingo[3] == 0 and bingo[4] == 0 and bingo[5] == 0) or (bingo[6] == 0 and bingo[7] == 0 and bingo[8] == 0):
    flag = 1

if (bingo[0] == 0 and bingo[3] == 0 and bingo[6] == 0) or (bingo[1] == 0 and bingo[4] == 0 and bingo[7] == 0) or (bingo[2] == 0 and bingo[5] == 0 and bingo[8] == 0):
    flag = 1

if (bingo[0] == 0 and bingo[4] == 0 and bingo[8] == 0) or (bingo[2] == 0 and bingo[4] == 0 and bingo[6] == 0):
    flag = 1
    
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):


a=[]
for _ in range(3):
    num_a=list(map(int,input().split()))
    for i in range(3):
        a.append(num_a[i])
n=int(input())
res=[-1 for i in range(9)]
for i in range(n):
    b=int(input())
    if b in a:
        num_index=a.index(b)
        res[num_index]=1

for i in range(3):
    if (res[i]==res[i+3])&(res[i+3]==res[i+6])&(res[i]==1):
        print("Yes")
        exit()
for i in range(3):
    if (res[3*i]==res[3*i+1])&(res[3*i+1]==res[3*i+2])&(res[3*i]==1):
        print("Yes")
        exit()
if ((res[0]==res[4])&(res[4]==res[8])&(res[0]==1))|((res[2]==res[4])&(res[4]==res[6])&(res[2]==1)):
    print("Yes")
    exit()
print("No")

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
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')

Solution (Python):
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
f=[0]*9
flag=False
for i in range(N):
  for j in range(3):
    for k in range(3):
      if(b[i]==A[j][k]):
        f[3*j+k]=1
if((f[0]==1 and f[1]==1 and f[2]==1)or(f[3]==1 and f[4]==1 and f[5]==1)or(f[6]==1 and f[7]==1 and f[8]==1)):
  flag=True
elif((f[0]==1 and f[3]==1 and f[6]==1)or(f[1]==1 and f[4]==1 and f[7]==1)or(f[2]==1 and f[5]==1 and f[8]==1)):
  flag=True
elif((f[0]==1 and f[4]==1 and f[8]==1)or(f[2]==1 and f[4]==1 and f[6]==1)):
  flag=True
if(flag==True):
  print("Yes")
else:
  print("No")

Solution (Python):
lst = [[v for v in map(int, input().split())] for _ in range(3)]
cnt = int(input())
for _ in range(cnt):
    v = int(input())
    for x in range(3):
        for y in range(3):
            if lst[x][y] == v:
                lst[x][y] = '*'
def bingo():
    for _ in range(3):
        if lst[_][0] == lst[_][1] == lst[_][2]:
            return print('Yes')
        if lst[0][_] == lst[1][_] == lst[2][_]:
            return print('Yes')
    if lst[0][0] == lst[1][1] == lst[2][2]:
        return print('Yes')
    if lst[0][2] == lst[1][1] == lst[2][0]:
        return print('Yes')
    else:
        return print('No')

bingo()

Solution (Python):
def resolve():
    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)]
 
    A = A1 + A2 + A3
    checkA = [0]*9
    for i in range(N):
        if b[i] in A:
            checkA[A.index(b[i])] = 1
    if checkA[0] + checkA[1] + checkA[2] == 3:
        print('Yes')
    elif checkA[3] + checkA[4] + checkA[5] == 3:
        print('Yes')
    elif checkA[6] + checkA[7] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[3] + checkA[6] == 3:
        print('Yes')
    elif checkA[1] + checkA[4] + checkA[7] == 3:
        print('Yes')
    elif checkA[2] + checkA[5] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[4] + checkA[8] == 3:
        print('Yes')
    elif checkA[2] + checkA[4] + checkA[6] == 3:
        print('Yes')
    else:
        print('No')
resolve()

Solution (Python):
def resolve():
    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)]

    A = A1 + A2 + A3
    checkA = [0]*9
    for i in range(N):
        if b[i] in A:
            checkA[A.index(b[i])] = 1
    if checkA[0] + A[1] + A[2] == 3:
        print('Yes')
    elif checkA[3] + checkA[4] + checkA[5] == 3:
        print('Yes')
    elif checkA[6] + checkA[7] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[3] + checkA[6] == 3:
        print('Yes')
    elif checkA[1] + checkA[4] + checkA[7] == 3:
        print('Yes')
    elif checkA[2] + checkA[5] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[4] + checkA[8] == 3:
        print('Yes')
    elif checkA[2] + checkA[4] + checkA[6] == 3:
        print('Yes')
    else:
        print('No')
resolve()

Solution (Python):
a = []
appear = [[False, False, False], [False, False, False], [False, False, False]]

for i in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
b = [0] * n
for j in range(n):
    b[j] = int(input())

for s in range(3):
    for t in range(3):
        for j in range(n):
            if a[s][t] == b[j]:
                appear[s][t] = True
ans = 'No'
if appear[0][0] and appear[1][1] and appear[2][2]:
    ans = 'Yes'
for s in range(3):
    if appear[s][0] and appear[s][1] and appear[s][2]:
        ans = 'Yes'
    if appear[0][s] and appear[1][s] and appear[2][s]:
        ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
    ans = 'Yes'
print(ans)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, B: "List[int]"):
    exists = []
    
    for b in B:
        for i, row in enumerate(A):
            for j, col in enumerate(row):
                if b == col:
                    exists.append((i, j))
    bingo_pattern = (
        ((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),),
        ((2, 0), (1, 1), (0, 2),),
    )
    for bingo in bingo_pattern:
        ok = 0
        for pair in bingo:
            if pair in exists:
                ok += 1
            if ok == 3:
                print(YES)
                return

    print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = [
        [int(next(tokens)) for _ in range(3)] for _ in range(3)
    ]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)


if __name__ == "__main__":
    main()

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

n=int(input())

for i in range(n):
  b=int(input())
  idx=np.where(A==b)
  if idx:
    A[idx]=0

yoko=0 in A.sum(axis=1)
tate=0 in A.sum(axis=0)
naname1=A[0,0]+A[1,1]+A[2,2]
naname2=A[0,2]+A[1,1]+A[2,0]

if yoko or tate or naname1*naname2==0:
  print("Yes")
else:
  print("No")

Solution (Python):
A = [[] for _ in range(3)]

A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))

N = int(input())
B = [[False, False, False] 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:
                B[j][k] = True

if all(B[0]) or all(B[1]) or all(B[2]):
    print('Yes')
elif all([B[0][0], B[1][0], B[2][0]]) or all([B[0][1], B[1][1], B[2][1]]) or all([B[0][2], B[1][2], B[2][2]]):
    print('Yes')
elif all([B[0][0], B[1][1], B[2][2]]) or all([B[0][2], B[1][1], B[2][0]]):
    print('Yes')
else:
    print("No")

Solution (Python):
from sys import stdin


a_mat = []
for _ in range(3):
  a_mat.append([int(x) for x in stdin.readline().strip().split()])
n = int(stdin.readline().strip())
b_lst = []
for _ in range(n):
  b_lst.append(int(stdin.readline().strip()))
  
op_mat = []
for a in a_mat:
  op_mat.append([x in b_lst for x in a])
op_mat_t = list(map(list, zip(*op_mat)))
  

if(all(op_mat[0]) or all(op_mat[1]) or all(op_mat[2])):
  print("Yes")

elif(all(op_mat_t[0]) or all(op_mat_t[1]) or all(op_mat_t[2])):
  print("Yes")

elif(all([op_mat[0][0], op_mat[1][1], op_mat[2][2]]) or all([op_mat[0][2], op_mat[1][1], op_mat[2][0]])):
  print("Yes")
else:
  print("No")

Solution (Python):
bingo=[]
karibingo=[]
for i in range(3):
    a=list(map(int,input().split()))
    bingo.append(a)
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k]==b:
                karibingo.append([j,k])
def bingohantei():
    count3 = 0
    if [0,2] in karibingo and [1,1] in karibingo and [2,0] in karibingo:
        return True
    for i in range(3):
        count=0
        count2=0
        if [i,i] in karibingo:
            count3+=1
        if count3==3:return True
        for j in range(3):
            if [i,j] in karibingo:
                count+=1
            if [j,i] in karibingo:
                count2+=1
            if count==3 or count2==3:return True
if bingohantei():
    print("Yes")
else:print("No")

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

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

ans = False
for i in range(3):
    if all(a[i][j] == 0 for j in range(3)) or all(a[j][i] == 0 for j in range(3)):
        ans = True
if a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]:
    ans = True

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

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

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



for i in range(3):
  if card[i] == [0, 0, 0]:
    
    print("Yes")
    exit()
  elif [x[i] for x in card] == [0, 0, 0]:
    
    print("Yes")
    exit()
    
if [card[i][i] for i in range(3)] == [0, 0, 0]:
  
  print("Yes")
  exit()
elif [card[2-i][i] for i in range(3)] == [0, 0, 0]:
  
  print("Yes")
  exit()
else:
  
  print("No")

Solution (Python):
def B():
    a = [list(map(int, input().split())) for i in range(3)]
    n = int(input())
    for b in (int(input()) for _ in range(n)):
        for i in range(3):
            for j in range(3):
                if a[i][j] == b:
                    a[i][j] = 1
    if ((a[0][0] == a[1][1] == a[2][2] == 1) or (a[0][2] == a[1][1] == a[2][0] == 1)):
        print('Yes')
        return
    for i in range(3):
        if all(a[i][j] == 1 for j in range(3)) or all(a[j][i] == 1 for j in range(3)):
            print('Yes')
            return
    print('No')
B()

Solution (Python):
A11,A12,A13 = map(int,input().split())
A21,A22,A23 = map(int,input().split())
A31,A32,A33 = map(int,input().split())
zennbu = {A11,A12,A13,A21,A22,A23,A31,A32,A33}
yoko1 = {A11,A12,A13}
yoko2 = {A21,A22,A23}
yoko3 = {A31,A32,A33}
tate1 = {A11,A21,A31}
tate2 = {A12,A22,A32}
tate3 = {A13,A23,A33}
naname1 = {A11,A22,A33}
naname2 = {A13,A22,A31}
N = int(input())
for i in range(N):
  b = int(input())
  if b in zennbu:
    yoko1.discard(b)
    yoko2.discard(b)
    yoko3.discard(b)
    tate1.discard(b)
    tate2.discard(b)
    tate3.discard(b)
    naname1.discard(b)
    naname2.discard(b)
if len(yoko1) ==0 or len(yoko2) ==0 or len(yoko3) ==0:
  print('Yes')
elif  len(tate1) ==0 or len(tate2) ==0 or len(tate3) ==0:
  print('Yes')
elif len(naname1) == 0 or len(naname2)==0:
  print('Yes')
else:
  print('No')

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

for i in range(9):
  if a[i] in b:
    a[i] = 'x'
  else:
    next
if a[0]is a[1]is a[2] is 'x' or a[3]is a[4]is a[5]is 'x' or a[6]is a[7]is a[8]is 'x' or a[0]is a[3]is a[6]is 'x' or a[1]is a[4]is a[7]is 'x' or a[2]is a[5]is a[8]is 'x' or a[0]is a[4]is a[8]is 'x' or a[2]is a[4]is a[6]is 'x':
  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())

A = [[0,0,0],[0,0,0],[0,0,0]]

for _ in range(n):
    b = int(input())
    if b in A1:
        tmp = A1.index(b)
        A[0][tmp] = 1
    elif b in A2:
        tmp = A2.index(b)
        A[1][tmp] = 1
    elif b in A3:
        tmp = A3.index(b)
        A[2][tmp] = 1
'''
if A[0][0] + A[0][1] + A[0][2] == 3 or A[1][0] + A[1][1] + A[1][2] == 3 or A[2][0] + A[2][1] + A[2][2] == 3:
    print('Yes')
elif A[0][0] + A[1][0] + A[2][0] == 3 or A[0][1] + A[1][1] + A[2][1] == 3 or A[0][2] + A[1][2] + A[2][2] == 3:
    print('Yes')
'''
ans = 'No'

for i in range(3):
    if A[0][i] == A[1][i] == A[2][i] == 1:
        ans = 'Yes'
    elif A[i][0] == A[i][1] == A[i][2]== 1:
        ans = 'Yes'
if A[0][0] + A[1][1] + A[2][2] == 3 or A[0][2] + A[1][1] + A[2][0] == 3:
    ans = 'Yes'

print(ans)