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

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
index_A1 = -1
index_A2 = -1
index_A3 = -1
result_A1 = [0, 0, 0]
result_A2 = [0, 0, 0]
result_A3 = [0, 0, 0]

for i in range(N):
    b = int(input())
    try:
        index_A1 = A1.index(b)
        if index_A1 > -1:
            result_A1[index_A1] = 1
    except ValueError:
        index_A1 = -1

    try:
        index_A2 = A2.index(b)
        if index_A2 > -1:
            result_A2[index_A2] = 1
    except ValueError:
        index_A2 = -1

    try:
        index_A3 = A3.index(b)
        if index_A3 > -1:
            result_A3[index_A3] = 1
    except ValueError:
        index_A3 = -1

if sum(result_A1) == 3 or sum(result_A2) == 3 or sum(result_A3) == 3:
    print('Yes')
    sys.exit()

for i in range(3):
    if result_A1[i] + result_A2[i] + result_A3[i] == 3:
        print('Yes')
        sys.exit()

if result_A1[0] + result_A2[1] + result_A3[2] == 3:
    print('Yes')
    sys.exit()

if result_A3[0] + result_A2[1] + result_A1[2] == 3:
    print('Yes')
    sys.exit()

print('No')

Solution (Python):
a11,a12,a13,a21,a22,a23,a31,a32,a33,n,*b=map(int, open(0).read().split())
b=set(b)
if {a11,a12,a13}<=b or {a21,a22,a23}<=b or {a31,a32,a33}<=b or {a11,a21,a31}<=b or {a12,a22,a32}<=b or {a13,a23,a33}<=b or {a11,a22,a33}<=b or{a13,a22,a31}<=b:
  print('Yes')
else:
  print('No')

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

for i in range(0,n):
  for j in range(0,3):
    if b[i]==p[j]:
      p[j]=0
    if b[i]==q[j]:
      q[j]=0
    if b[i]==r[j]:
      r[j]=0

if (p[0]==p[1]==p[2] or
    q[0]==q[1]==q[2] or
    r[0]==r[1]==r[2] or
    p[0]==q[0]==r[0] or
    p[1]==q[1]==r[1] or
    p[2]==q[2]==r[2] or
    p[0]==q[1]==r[2] or
    p[2]==q[1]==r[0]):
  print("Yes")
else:
  print("No")

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
ans='No'
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=-1
for i in range(3):
    if sum(A[i])==-3:
        ans='Yes'
    if A[0][i]+A[1][i]+A[2][i]==-3:
        ans='Yes'
if A[0][0]+A[1][1]+A[2][2]==-3:
    ans='Yes'
if A[0][2]+A[1][1]+A[2][0]==-3:
    ans='Yes'
print(ans)

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

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

for i in range(N):
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == number[i]:
        check[j][k] = 1
        
ans = 'No'
for i in range(3):
  if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
    ans = 'Yes'
    
for i in range(3):
  if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
    ans = 'Yes'
    
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
  ans = 'Yes'
  
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
  ans = 'Yes'
  
print(ans)

Solution (Python):

A = []
A_append = A.append
for i in range(3):
    An = list(map(int, input().split()))
    A_append(An)

N = int(input())

b = []
append = b.append
for i in range(N):
    bn = int(input())
    append(bn)



marker = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

bingo_fl = False
for i in b:
    for n, An in enumerate(A):

        if i in An:
            m = An.index(i)

            marker[n][m] = 1

            break

if (
        [1, 1, 1] in [marker[i][:] for i in range(3)] or
        [1, 1, 1] in [[marker[0][i], marker[1][i], marker[2][i]] for i in range(3)] or
        [1, 1, 1] == [marker[0][0], marker[1][1], marker[2][2]] or
        [1, 1, 1] == [marker[0][2], marker[1][1], marker[2][0]]
):
    bingo_fl = True

if bingo_fl is True:
    print("Yes")
else:
    print("No")

Solution (Python):
a = [0] *9

a[0], a[1], a[2] = list(map(int, input().split()))
a[3], a[4], a[5] = list(map(int, input().split()))
a[6], a[7], a[8] = list(map(int, input().split()))

n = int(input())

b = [0]*9

for i in range(n):
    c = int(input())
    for j in range(9):
        if a[j] == c:
            b[j] = 1

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

Solution (Python):
a_1 = list(map(int,input().split(" ")))
a_2 = list(map(int,input().split(" ")))
a_3 = list(map(int,input().split(" ")))
n = int(input())
open_number =[]
for i in range(3):
  open_number.append([0,0,0])
for i in range(n):
  number = int(input())
  for j in range(3):
    if number == a_1[j]:
      open_number[0][j] = 1
    if number == a_2[j]:
      open_number[1][j] = 1
    if number == a_3[j]:
      open_number[2][j] = 1
bingo = False
line_1 = 0
line_2 = 0
line_3 = 0
cross_1 = 0
cross_2 = 0
for i in range(3):
  if not 0 in open_number[i]:
    bingo = True
  if open_number[i][0] == 1:
    line_1 += 1
  if open_number[i][1] == 1:
    line_2 += 1
  if open_number[i][2] == 1:
    line_3 += 1
  if open_number[i][i] == 1:
    cross_1 += 1
  if open_number[2-i][i] == 1:
    cross_2 += 1
  if line_1 == 3:
    bingo = True
  if line_2 == 3:
    bingo = True
  if line_3 == 3:
    bingo = True
  if cross_1 == 3:
    bingo = True
  if cross_2 == 3:
    bingo = True
if bingo:
  print("Yes")
else:
  print("No")

Solution (Python):
a=[list(map(int,input().split())) for _ in range(3)]
tf=[[0]*3 for _ in  range(3)]
n=int(input())
b=[]
for i in range(n):
  s=int(input())
  b.append(s)
for i in  b:
  for j in range(3):
    for k in range(3):
      if i==a[j][k]:
        tf[j][k]=1
for i in range(3):
  if tf[i]==[1,1,1]:
    print('Yes')
    exit()
  if [row[i] for row in tf]==[1,1,1]:
    print('Yes')
    exit()
if [tf[i][i] for i in range(3)]==[1,1,1]:
  print('Yes')
elif [tf[i][2-i] for i in range(3)]==[1,1,1]:
  print('Yes')
else:
  print('No')

Solution (Python):
s = []
for i in range(3):
    array = list(map(int,input().split()))
    s.append(array)
N = int(input())
t = [int(input()) for i in range(N)]
 
for i in range(N):
    for j in range(3):
        for l in range(3):
            if t[i] == s[j][l]:
                s[j][l] = 0
 
if sum(s[0]) == 0 or sum(s[1]) == 0 or sum(s[2]) == 0 or s[0][0]+s[1][0]+s[2][0] == 0 or s[0][1]+s[1][1]+s[2][1] == 0 or s[0][2]+s[1][2]+s[2][2] == 0 or s[0][0]+s[1][1]+s[2][2] == 0 or s[2][0]+s[1][1]+s[0][2] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

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

n = int(input())
a2 = [[0 for _ in range(3)]for _ in range(3)]

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

for i in range(3):
	if sum(a2[i]) == 3:
		print('Yes')
		sys.exit()
tate = 0
for i in range(3):
	for j in range(3):
		if a2[j][i] == 1:
			tate += 1
	if tate == 3:
		print('Yes')
		sys.exit()
	tate = 0
naname = 0
for i in range(3):
	if a2[i][i] == 1:
		naname += 1
if naname == 3:
	print('Yes')
	sys.exit()
naname = 0
for i in range(3):
	if a2[i][-i-1] == 1:
		naname += 1
if naname == 3:
	print('Yes')
	sys.exit()
print('No')

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

N = int(input())
B = [int(input()) for i in range(N)]

ans='No'

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

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

if A[0][0]+A[1][1]+A[2][2]==-3:
    ans='Yes'

if A[0][2]+A[1][1]+A[2][0]==-3:
    ans='Yes'

print(ans)

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

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

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

bingo = False
for n in range(int(input())):
    num = int(input())
    if num in A:
        A[A.index(num)] = 0
    if A[0] == A[1] == A[2] == 0: bingo = True
    if A[3] == A[4] == A[5] == 0: bingo = True
    if A[6] == A[7] == A[8] == 0: bingo = True
    if A[0] == A[3] == A[6] == 0: bingo = True
    if A[1] == A[4] == A[7] == 0: bingo = True
    if A[2] == A[5] == A[8] == 0: bingo = True
    if A[0] == A[4] == A[8] == 0: bingo = True
    if A[2] == A[4] == A[6] == 0: bingo = True

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

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

cross_line = []
reverse_cross = []
for i in range(3):
    vertiual_line = []
    cross_line.append(Bingo_list[i][i])
    reverse_cross.append(Bingo_list[i][2-i])
    for j_line in Bingo_list[:3]:
        vertiual_line.append(j_line[i])
    Bingo_list.append(vertiual_line)

Bingo_list.append(cross_line)
Bingo_list.append(reverse_cross)

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

for i_line in Bingo_list:
    for i_num in i_line:
        if not i_num in SelectNum:
            break
    else:
        ans = 'Yes'
        break
else:
    ans = 'No'

print(ans)

Solution (Python):
input1  = input().split()
input2  = input().split()
input3  = input().split()
N = int(input())

A = [input1, input2, input3]


for i in range(N):
  n = input()
  A[0] = ['0' if j == n else j for j in A[0]]
  A[1] = ['0' if j == n else j for j in A[1]]
  A[2] = ['0' if j == n else j for j in A[2]]



ans = 'No'
if A[1][1] == A[2][2] == A[0][0] == "0":
  ans = "Yes"

if A[1][1] == A[2][0] == A[0][2] == "0":
  ans = "Yes"
  
for i in range(3):
  if A[i] == ['0','0','0']:
    ans = "Yes"
  if A[0][i] == A[1][i] == A[2][i] == "0":
    ans ='Yes'
  
print(ans)

Solution (Python):
def main():
    import sys
    import math
    import collections
    
    A=[list(map(int,input().split())) for _ in range(3)]
    N=int(input())
    C=[]
    D=[]
    for _ in range(N):
        b=int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j]==b:
                    C.append(i)
                    D.append(j)
                    A[i][j]=0
    c=collections.Counter(C)
    d=collections.Counter(D)
    if 3 in c.values():
        print("Yes")
    elif 3 in d.values():
        print("Yes")
    elif A[0][0]==A[1][1] and A[1][1]==A[2][2]:
        print("Yes")
    elif A[0][2]==A[1][1] and A[1][1]==A[2][0]:
        print("Yes")
    else:
        print("No")

    
if __name__ == '__main__':
    main()

Solution (Python):
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

a=[intl() for _ in range(3)]
n=i()
b=[int(input()) for _ in range(n)]
flag=0
falg=0
for i in range(3):
	for j in range(3):
		if a[i][j] in b:
			a[i][j]=0
for i in range(3):
	for j in range(3):
		if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
			flag+=1
		elif a[0][j]==0 and a[1][j]==0 and a[2][j]==0:
			flag+=1
		elif i==j and a[i][j]==0:
			falg+=1
			if falg==3:
				flag+=1
if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
	flag+=1
if flag>=1:
	print('Yes')
else:
	print('No')

Solution (Python):
A_1 = input().split()
A_2 = input().split()
A_3 = input().split()
A_1 = [int(k) for k in A_1]
A_2 = [int(k) for k in A_2]
A_3 = [int(k) for k in A_3]
A = []
A.append(A_1)
A.append(A_2)
A.append(A_3)

N = int(input())

b = []
for i in range(N):
    b.append(int(input()))

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

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

Solution (Python):
mat = []
for _ in range(3):
    mat.append(list(map(int, input().split())))
N = int(input())
nums = set()
for _ in range(N):
    nums.add(int(input()))
rows = [3] * 3
cols = [3] * 3
diags = [3] * 2
for i in range(3):
    for j in range(3):
        if mat[i][j] in nums:
            rows[i] -= 1
            cols[j] -= 1
            if i == j:
                diags[0] -= 1
            if i + j == 2:
                diags[1] -= 1
print(["No", "Yes"][0 in (rows + cols + diags)])

Solution (Python):
S = [list(map(int, input().split())) for _ in range(3)]
s = []
for i in range(3):
    for j in range(3):
        s.append(S[i][j])
n = int(input())
a = [int(input()) for i in range(n)]
if (s[0]in a and s[1] in a and s[2] in a)or(s[3]in a and s[4] in a and s[5] in a)or(s[6]in a and s[7] in a and s[8] in a)or(s[0]in a and s[3] in a and s[6] in a)or(s[4]in a and s[1] in a and s[7] in a)or(s[2]in a and s[5] in a and s[8] in a)or(s[0]in a and s[4] in a and s[8] in a)or(s[2]in a and s[4] in a and s[6] in a):
    print("Yes")
else:
    print("No")

Solution (Python):
lia = input().split()
lib = input().split()
lic = input().split()
n=int(input())
num_list=[input() for i in range(n)]

ans=0

for i in range(0,3):
  for l in range(0,n):
    if lia[i]==num_list[l]:
      lia[i]=0
for i in range(0,3):
  for l in range(0,n):
    if lib[i]==num_list[l]:
      lib[i]=0
for i in range(0,3):
  for l in range(0,n):
    if lic[i]==num_list[l]:
      lic[i]=0
    
if lia.count(0)==3:
  ans=1
if lib.count(0)==3:
  ans=1
if lic.count(0)==3:
  ans=1
for k in range(0,3):
  if lia[k]==lib[k]==lic[k]:
    ans=1
    
if lia[0]==lib[1]==lic[2] or lia[2]==lib[1]==lic[0]:
  ans=1
  
if ans==1:
  print('Yes')
else:
  print('No')

Solution (Python):
import math
line1 = list(map(int, input().split()))
line2 = list(map(int, input().split()))
line3 = list(map(int, input().split()))
lines = [line1, line2, line3]
N = int(input())
List = [int(input()) for i in range(4, N + 4)]

for num in List:
    for i in range(len(lines)):
        for j in range(len(lines)):
            if lines[i][j] == num:
                lines[i][j] = -1

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

Solution (Python):
b=[list(map(int,input().split()))for i in range(3)]
n=int(input())
nums=set([int(input())for i in range(n)])
for i in range(3):
    for j in range(3):
        if b[i][j] in nums:
            b[i][j]=0
flag=False
for i in range(3):
    if b[i][0] == b[i][1] == b[i][2] == 0:
        flag=True
    if b[0][i] == b[1][i] == b[2][i] == 0:
        flag=True
if b[0][0] == b[1][1] == b[2][2] == 0:
    flag=True
if b[2][0] == b[1][1] == b[0][2] == 0:
    flag=True

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

Solution (Python):
list0=[]
date0=input().rstrip().split(" ")
date1=input().rstrip().split(" ")
date2=input().rstrip().split(" ")
list0.append(date0)
list0.append(date1)
list0.append(date2)
num=int(input())
for k in range(num):
  memo=input()
  for i in range(3):
    j=0
    for j in range(3):
      if list0[i][j]==memo:
        list0[i][j]="0"
if list0[0]==['0','0','0'] or list0[1]==['0','0','0'] or list0[2]==['0','0','0']:
  print("Yes")
elif list0[0][1]=="0" and list0[1][1]=="0" and list0[2][1]=="0":
  print("Yes")
elif list0[0][2]=="0" and list0[1][2]=="0" and list0[2][2]=="0":
  print("Yes")
elif list0[0][0]=="0" and list0[1][0]=="0" and list0[2][0]=="0":
  print("Yes")
elif list0[0][0]=="0" and list0[1][1]=="0" and list0[2][2]=="0":
  print("Yes")
elif list0[0][2]=="0" and list0[1][1]=="0" and list0[2][0]=="0":
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
li = [list(map(int,input().split())) for i in range(3)]
n = int(input())
k = [int(input()) for i in range(n)]
cnt = 0
for i in range(3):
    for j in range(3):
        if li[i][j] in k:
            li[i][j] = -1
        else:
            pass
for a in range(3):
    if li[a][0] == li[a][1] == li[a][2] == -1:
        print("Yes")
        exit()
    else:
        pass
for b in range(3):
    if li[0][b] == li[1][b] == li[2][b] == -1:
        print("Yes")
        exit()
    else:
        pass
if li[0][0] == li[1][1] == li[2][2] == -1:
    print("Yes")
    exit()

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

f = 0

for i in range(n):
  for m in range(3):
    for n in range(3):
      if a[m][n] ==b[i]:
        a[m][n]='o'
for i in range(3):
  if a[0][i]=='o' and a[1][i]=='o' and a[2][i]=='o':
    f+=1

for i in range(3):
  if a[i][0]=='o' and a[i][1]=='o' and a[i][2]=='o':
    f +=1 

if a[0][0]=='o' and a[1][1]=='o' and a[2][2]=='o':
  f+=1

if a[0][2]=='o' and a[1][1]=='o' and a[2][0]=='o':
  f+=1
  
if f ==0:
  print('No')
else:
  print('Yes')

Solution (Python):
a = []
a.extend(map(int, input().split()))
a.extend(map(int, input().split()))
a.extend(map(int, input().split()))
n = int(input())
b = []

for i in range(n):
  b.append(int(input()))



for i in range(len(b)):
  a = [0 if mas == b[i] else mas for mas in a]

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

Solution (Python):
mat = [[False]*3 for i in range(3)]
a_mat = []
for i in range(3):
  a_list = list(map(int, input().split()))
  a_mat.append(a_list)
n = int(input())
for i in range(n):
  b = int(input())
  for x in range(3):
    for y in range(3):
      if a_mat[x][y] == b:
        mat[x][y] = True

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

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                A[i][j] =0
flag=0
for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2]==0:
        flag =1
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i]==0:
        flag =1
if A[0][0] ==0 and A[1][1] ==0 and A[2][2]==0:
    flag=1
if  A[0][2] ==0 and A[1][1] ==0 and A[2][0]==0:
    flag = 1

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

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

n = int(input())

v = []
for j in range(n):
    v.append(int(input()))

for k in v:
    for i in range(3):
        for j in range(3):
            if a[i][j] == k:
                a[i][j] = -1

bingo = False
for i in range(3):
    if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
        bingo = True
    if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
        bingo = True

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    bingo = True
elif a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    bingo = True

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

Solution (Python):
import numpy as np

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

n = int(input())

for j in range(n):
    val2 = int(input())
    if np.any(a == val2):
        a = np.where(a==val2, -1, a)

bingo = False
for i in range(3):
    if np.all(a[i,:] == -1):
        bingo = True
        break
    if np.all(a[:,i] == -1):
        bingo = True
        break
if a[0,0] == -1 and a[1,1] == -1 and a[2,2] == -1:
    bingo = True
if a[0,2] == -1 and a[1,1] == -1 and a[2,0] == -1:
    bingo = True

if bingo:
    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())
for i in range(N):
    bingo_num = int(input())
    A = np.where(A == bingo_num, 0, A)
if (0 in np.sum(A, axis=1)
    or 0 in np.sum(A, axis=0)
    or np.sum(np.diag(A)) == 0
        or A[0, 2]+A[1, 1]+A[2, 0] == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
A=[list(map(int,input().split()))for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
flag = True
for i in range(N):
    for n in range(3):
        for m in range(3):
            if A[n][m]==b[i]:
                A[n][m]='o'
for i in range(3):
    if A[i][0]=='o' and A[i][1]=='o' and A[i][2]=='o':
        flag = False
for i in range(3):
    if A[0][i]=='o' and A[1][i]=='o' and A[2][i]=='o':
        flag = False
if A[0][0] == A[1][1]==A[2][2] =='o':
    flag = False
if A[0][2] == A[1][1] ==A[2][0]=='o':
    flag = False
if flag == False:
    print('Yes')
else:
    print('No')

Solution (Python):
s1=list(map(int, input().split()))
s2=list(map(int, input().split()))
s3=list(map(int, input().split()))
n = int(input())
A=set()
for i in range(n):
	s=int(input())
	A.add(s)
c=[0]*9
for i in range(3):
	if s1[i] in A:
		c[i]+=1

for i in range(3):
	if s2[i] in A:
		c[i+3]+=1

for i in range(3):
	if s3[i] in A:
		c[i+6]+=1
p=0

if c[0]+c[4]+c[8]==3:
	print('Yes')
	p+=1
if p==0 and c[2]+c[4]+c[6]==3:
	print('Yes')
	p+=1


if p==0 and c[0]+c[1]+c[2]==3:
	print('Yes')
	p+=1
if p==0 and c[3]+c[4]+c[5]==3:
	print('Yes')
	p+=1
if p==0 and c[6]+c[7]+c[8]==3:
	print('Yes')
	p+=1

for i in range(3):
	if p==0 and c[i]+c[3+i]+c[6+i]==3:
		print('Yes')
		p+=1

if p==0:
	print('No')

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

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

for i in b:
  for j in range(3):
    if i in A[j]:
      A[j][A[j].index(i)] = 0
else:
  for i in range(3):
    if (A[0][i] + A[1][i] + A[2][i] == 0) or (A[i][0] + A[i][1] + A[i][2] == 0):
      print('Yes')
      break
  else:
    if (A[0][0] + A[1][1] + A[2][2] == 0) or (A[0][2] + A[1][1] + A[2][0] == 0):
      print('Yes')
    else:
      print('No')

Solution (Python):
import sys



bingo = [[int(c) for c in input().split()] for _ in range(3)]
n = int(input())
a = [int(input()) for _ in range(n)]

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

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[i] == bingo[j][k]:
                ans[j][k] = 1
                num += 1
if num < 3:
    print("No")
    exit()

if ans[1][1] == 1:
    if (ans[0][0] == 1 and ans[2][2]==1) or ( ans[0][2] == 1 and ans[2][0] == 1):
        print("Yes")
        exit()


for i in range(3):

    if ans[i][0] == 1 and ans[i][1] == 1 and ans[i][2] == 1:
        print("Yes")
        exit()
    elif ans[0][i] == 1 and ans[1][i] == 1 and ans[2][i] == 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()))
a = a1 + a2 + a3
 
n = int(input())
 

for _ in range(n):
  b = int(input())
  if b in a:
    a[a.index(b)]=0
  
  
check = 0
for i in range(3):
  
  if (a[3*i]==a[3*i+1] and a[3*i+1]==a[3*i+2]) or (a[i]==a[i+3] and a[i+3]==a[i+6]):
        check+=1

if (a[0]==a[4] and a[4]==a[8]) or (a[2]==a[4] and a[4]==a[6]):
    check+=1
if check>0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
  A = []
  for _ in range(3):
    A+=ints()
  n = aint()
  for _ in range(n):
    num = aint()
    for i in range(9):
      if A[i]==num: A[i]=0
  b = sum(A[:3])*sum(A[3:6])*sum(A[6:])*(A[0]+A[3]+A[6])*(A[1]+A[4]+A[7])*(A[2]+A[5]+A[8])*(A[0]+A[4]+A[8])*(A[2]+A[4]+A[6])
  Yes(b==0)
    
if __name__ == '__main__':
  main()

Solution (Python):
is_chosen = [False]*9
bingo = {}
for i in range(3):
    for j, a in enumerate([int(i) for i in input().split()]):
        bingo[a] = i*3 + j

N = int(input())
for i in range(N):
    b = int(input())
    if(b in bingo):
        is_chosen[bingo[b]] = True

ans = False
for i in range(3):
    ans |= is_chosen[i] and is_chosen[3 + i] and is_chosen[6 + i]
    ans |= is_chosen[i*3] and is_chosen[i*3 + 1] and is_chosen[i*3 + 2]
ans |= is_chosen[0] and is_chosen[4] and is_chosen[8]
ans |= is_chosen[2] and is_chosen[4] and is_chosen[6]

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

Solution (Python):
A = []
A.append( [ int(x) for x in input().split() ] )
A.append( [ int(x) for x in input().split() ] )
A.append( [ int(x) for x in input().split() ] )

N = int( input() )
for nn in range(N):
    b = int( input() )
    for ii in range(3):
        for jj in range(3):
            if( A[ii][jj] == b ):
                A[ii][jj] = 0

ans = False

for ii in range(3):
    if( sum( A[ii] ) == 0 ):
        ans = True

for jj in range(3):
    tmp = 0
    for ii in range(3):
        tmp += A[ii][jj]
    if( tmp == 0 ):
        ans = True

if( A[0][0]+A[1][1]+A[2][2] == 0 ):
    ans = True  
if( A[2][0]+A[1][1]+A[0][2] == 0 ):
    ans = True        


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

Solution (Python):
import sys
import math

input = sys.stdin.readline

BingoCard = []

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

N = int(input())

for i in range(N):
    b_i = int(input())

    for j in range(3):
        for k in range(3):
            if BingoCard[j][k] == b_i:
                BingoCard[j][k] =0


if BingoCard[0] ==[0,0,0]:
    print('Yes')
elif BingoCard[1] ==[0,0,0]:
    print('Yes')
elif BingoCard[2] ==[0,0,0]:
    print('Yes')
elif [n[0] for n in BingoCard] ==[0,0,0]:
    print('Yes')
elif [n[1] for n in BingoCard] ==[0,0,0]:
    print('Yes')
elif [n[2] for n in BingoCard] ==[0,0,0]:
    print('Yes')
elif [BingoCard[n][n] for n in range(3)] ==[0,0,0]:
    print('Yes')
elif [BingoCard[n][2-n] for n in range(3) ] ==[0,0,0]:
    print('Yes')
else:
    print('No')

Solution (Python):
bingo_card = []
for _ in range(3):
  bingo_card.extend(input().split())
  
N = int(input())

for _ in range(N):
  value = input()
  if value in bingo_card:
    bingo_card[bingo_card.index(value)] = '*'
    
row1 = bingo_card[0] + bingo_card[1] + bingo_card[2]
row2 = bingo_card[3] + bingo_card[4] + bingo_card[5]
row3 = bingo_card[6] + bingo_card[7] + bingo_card[8]
col1 = bingo_card[0] + bingo_card[3] + bingo_card[6]
col2 = bingo_card[1] + bingo_card[4] + bingo_card[7]
col3 = bingo_card[2] + bingo_card[5] + bingo_card[8]
dgn1 = bingo_card[0] + bingo_card[4] + bingo_card[8]
dgn2 = bingo_card[2] + bingo_card[4] + bingo_card[6]

bingo = '***'
if any([
  row1 == bingo,
  row2 == bingo,
  row3 == bingo,
  col1 == bingo, 
  col2 == bingo,
  col3 == bingo,
  dgn1 == bingo,
  dgn2 == bingo
]):
  print('Yes')
else:
  print('No')

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

memo = [[0]*3 for _3 in range(3)]

for _ in range(n):
    p = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == p:
                memo[i][j] = 1

sums = []

for l in memo:
    sums.append(sum(l))

for k in range(3):
    sums.append(memo[0][k]+memo[1][k]+memo[2][k])

sums.append(memo[0][0] + memo[1][1] + memo[2][2])
sums.append(memo[0][2] + memo[1][1] + memo[2][0])

if max(sums) == 3:
    print("Yes")

else:
    print("No")

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

matched_flag = list()
for i in range(3):
    matched_flag.append([1 if elem in b else 0 for elem in a[i]])

for row in matched_flag:
    if sum(row) == 3:
        print('Yes')
        exit(0)

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

if (sum([matched_flag[i][i] for i in range(3)]) == 3) or \
    (sum([matched_flag[i][2-i] for i in range(3)]) == 3):
    print('Yes')
    exit(0)
print('No')