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):
bingoSheet = [0 for x in range(9)]

for i in range(3):
    bingoRow = input().split()
    for j in range(3):
        bingoSheet[i*3 + j] = int(bingoRow[j])

bingoCount = int(input())

responses = []

for i in range(bingoCount):
    responses.append(int(input()))

hasBingo = False

step = 1
initialIndex = 0

for i in range(3):
    firstIndex = i*3
    subList = [bingoSheet[index] for index in [firstIndex, firstIndex+1, firstIndex+2]]
    if (all(elem in responses for elem in subList)):
        hasBingo = True
        break

for i in range(3):
    firstIndex = i
    subList = [bingoSheet[index] for index in [firstIndex, firstIndex+3, firstIndex+6]]
    if (all(elem in responses for elem in subList)):
        hasBingo = True
        break

subList = [bingoSheet[index] for index in [0, 4, 8]]
if (all(elem in responses for elem in subList)):
    hasBingo = True

subList = [bingoSheet[index] for index in [2, 4, 6]]
if (all(elem in responses for elem in subList)):
    hasBingo = True

if hasBingo:
    print('Yes')
    quit()

print('No')
quit()

Solution (Python):
matrix = []
for i in range(3):
    line = []
    line = input().split(" ")
    matrix.append(line)

n = int(input())
chosen = 0

for i in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == b:
                chosen += 1
                matrix[i][j] = 0
bingo = False
for i in range(3):
    if(matrix[i][0] == 0 and matrix[i][1] == 0 and matrix[i][2] == 0):
        bingo = True
        break
    elif(matrix[0][i] == 0 and matrix[1][i] == 0 and matrix[2][i] == 0):
        bingo = True
        break

if(matrix[1][1] == 0 and matrix[0][0] == 0 and matrix[2][2] == 0):
    bingo = True
if(matrix[1][1] == 0 and matrix[2][0] == 0 and matrix[0][2] == 0):
    bingo = True
if bingo:
    print("Yes")
else:
    print("No")

Solution (Python):
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

a = [r1, r2, r3]

n = int(input())

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


if a[0][0] in b and a[0][1] in b and a[0][2] in b:
	print('Yes')
	quit()
if a[1][0] in b and a[1][1] in b and a[1][2] in b:
	print('Yes')
	quit()
if a[2][0] in b and a[2][1] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][0] in b and a[1][0] in b and a[2][0] in b:
	print('Yes')
	quit()
if a[0][1] in b and a[1][1] in b and a[2][1] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][2] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
	print('Yes')
	quit()
print('No')

Solution (Python):
"""Boot-camp-for-Beginners_Easy007_B_Bingo_25-August-2020.py"""
import numpy as np
import sys

A = list(list(map(int, input().split())) for i in range(3))
N = int(input())
b = list(int(input()) for i in range(N))

MARK = []
for k in range(N):
    for i in range(3):
        for j in range(3):
            if(A[i][j] == b[k]):
                MARK.append([i-1, j-1])

count_row_m1, count_row_0, count_row_p1, count_column_m1, count_column_0, count_column_p1, count_backslash, count_slash = 0, 0, 0, 0, 0, 0, 0, 0
for k in range(len(MARK)):
    if MARK[k][0] == -1:
        count_column_m1 += 1
    elif MARK[k][0] == 0:
        count_column_0 += 1
    else:
        count_column_p1 += 1

    if MARK[k][1] == -1:
        count_row_m1 += 1
    elif MARK[k][1] == 0:
        count_row_0 += 1
    else:
        count_row_p1 += 1

    if MARK[k][0] == MARK[k][1]:
        count_backslash += 1
    if MARK[k][0] == -MARK[k][1]:
        count_slash += 1
bingo = count_row_m1 >= 3 or count_row_0 >= 3 or count_row_p1 >= 3 or count_column_m1 >= 3 or count_column_0 >= 3 or count_column_p1 >= 3 or count_backslash >= 3 or count_slash >= 3
"""
print("count_column_m1", count_column_m1)
print("count_column_0", count_column_0)
print("count_column_p1", count_column_p1)
print("count_row_m1", count_row_m1)
print("count_row_0", count_row_0)
print("count_row_p1", count_row_p1)
print("count_backslash", count_backslash)
print("count_slash", count_slash)
"""
if bingo == True:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
a = [list(map(int, input().split())) for _ 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] = 0
c = []
c.append(np.sum(a,axis = 0))
c.append(np.sum(a,axis = 1))
d = np.prod(c)
if d == 0:
    print("Yes")
elif (a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0) or (a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
A = [0] * 9
nums = dict()
for i in range(3):
  temp = list(map(int, input().split()))
  for j, var in enumerate(temp):
    nums[var] = i * 3 + j
N = int(input())

for _ in range(N):
  i = int(input())
  if i in nums:
    A[nums[i]] = 1

bingo = [
  A[0] + A[1] + A[2],
  A[3] + A[4] + A[5],
  A[6] + A[7] + A[8],
  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]]

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

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

N = int(input())
B_list = []

for i in range(N):
    B_temp = int(input())
    B_list.append(B_temp)

ans_list = [[0 for _ in range(3)] for i in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B_list[i] == A_list[j][k]:
                ans_list[j][k] = 1

for i in range(3):
    ans_r_flag = 0
    ans_c_flag = 0
    for j in range(3):
        ans_r_flag += ans_list[i][j]
        ans_c_flag += ans_list[j][i]
        if ans_r_flag == 3 or ans_c_flag == 3:
            print("Yes")
            exit()
            
if ans_list[0][0] == 1 and ans_list[1][1] == 1 and ans_list[2][2] == 1:
    print("Yes")
    exit()
if ans_list[0][2] == 1 and ans_list[1][1] == 1 and ans_list[2][0] == 1:
    print("Yes")
    exit()

print("No")

Solution (Python):
def main():
    a_lst = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b_lst = [int(input()) for _ in range(n)]
    appear = [[False for _ in range(3)] for _ in range(3)]
    is_bingo = False

    for b in b_lst:
        for r in range(3):
            for c in range(3):
                if a_lst[r][c] == b:
                    appear[r][c] = True

    for r in range(3):
        if appear[r][0] == True and appear[r][1] == True and appear[r][2] == True:
            is_bingo = True

    for c in range(3):
        if appear[0][c] == True and appear[1][c] == True and appear[2][c] == True:
            is_bingo = True

    if appear[0][0] == True and appear[1][1] == True and appear[2][2] == True:
        is_bingo = True

    if appear[0][2] == True and appear[1][1] == True and appear[2][0] == True:
        is_bingo = True

    if is_bingo:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
B = [[0 for i in range(3)] for j 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 A[j][k] == b:
        B[j][k] = 1
c = []
for i in range(3):
  c.append(B[i][0] & B[i][1] & B[i][2])
  c.append(B[0][i] & B[1][i] & B[2][i])
c.append(B[0][0] & B[1][1] & B[2][2])
c.append(B[0][2] & B[1][1] & B[2][0])
if sum(c) > 0:
  print("Yes")
else:
  print("No")

Solution (Python):
x = []

for i in range(3):
  a =input().split()
  x.append(a)

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

for i in range(3):
  for j in range(3):
    if x[i][j] in b:
      x[i][j] = '*'

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

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

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

Solution (Python):
A = [[int(x) for x in input().split()] for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

Bingo = [[0, 0, 0] for _ in range(3)] 
for i in range(3):
  for j in range(3):
    for l in range(N):
      if(A[i][j] == b[l]):
        Bingo[i][j] = 1
bingo = 0
for i in range(3):
  if(Bingo[i][0]+Bingo[i][1]+Bingo[i][2])==3:
    bingo += 1
  elif(Bingo[0][i]+Bingo[1][i]+Bingo[2][i])==3:
    bingo += 1
if(Bingo[0][0]+Bingo[1][1]+Bingo[2][2])==3:
  bingo += 1
elif(Bingo[0][2]+Bingo[1][1]+Bingo[2][0])==3:
  bingo += 1

if(bingo!=0):
  print('Yes')
else:
  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()))

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

B=get_unique_list(B)
s=0
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    s+=1
elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
    s+=1
else:    
    for i in range(3):
        if A[0][i] in B and A[1][i] in B and A[2][i] in B:
            s+=1
        elif A[i][0] in B and A[i][1] in B and A[i][2] in B:
            s+=1

if s>=1:
    print("Yes")
else:
    print("No")

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

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

card = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                card[j][k] = True

yes = "Yes"
no = 'No'

answer = no

for i in range(3):
    if card[0][i] and card[1][i] and card[2][i]:
        answer = yes
for i in range(3):
    if card[i][0] and card[i][1] and card[i][2]:
        answer = yes
if card[0][0] and card[1][1] and card[2][2]:
    answer = yes
if card[0][2] and card[1][1] and card[2][0]:
    answer = yes

print(answer)

Solution (Python):
a=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
b=int(input())
for i in range(b):
    c=int(input())
    if a.count(c)==1:
        a[a.index(c)]=0
if a[0]==a[1]==a[2] or a[3]==a[4]==a[5] or a[6]==a[7]==a[8]:
    print("Yes")
elif a[0]==a[3]==a[6] or a[1]==a[4]==a[7] or a[2]==a[5]==a[8]:
    print("Yes")
elif a[0]==a[4]==a[8] or a[2]==a[4]==a[6]:
    print("Yes")
else:
    print("No")

Solution (Python):
H = [[0] * 3 for i in range(3)]
A = [[0] * 3 for i in range(3)]

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

N = int(input())
for i in range(N):
	ball = int(input())
	for l in range(3):
		for c in range(3):
			if A[l][c] == ball:
				H[l][c] = 1

flag = 0
for l in range(3):
	if H[l][0] ==1 and H[l][1] ==1  and H[l][2] ==1:
		flag =1

for c in range(3):
	if H[0][c] ==1 and H[1][c] ==1  and H[2][c] ==1:
		flag =1

if H[0][0]==1 and H[1][1]==1 and H[2][2]== 1:
	flag = 1

if H[2][0]==1 and H[1][1]==1 and H[0][2]== 1:
	flag = 1

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

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

A=np.array(A)
N=int(input())

for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]!=b:
                continue
            B[j][k]=0

if 0 in np.sum(B,axis=0) or 0 in np.sum(B,axis=1) or B[0][0]+B[1][1]+B[2][2] == 0 or B[0][2]+B[1][1]+B[2][0] == 0:
    print("Yes")
else:
    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 a[j][k] == b[i]:
        a[j][k] = 0
        
flg = 0
if flg == 0:
  for i in range(3):
    if flg ==0:
      for j in range(3):
        if a[i][j] == 0 and j != 2:
          continue
        elif j == 2 and a[i][j]==0:
          flg = 1
        else:
          break
if flg == 0:
  for i in range(3):
    if flg ==0:
      for j in range(3):
        if a[j][i] == 0 and j != 2:
          continue
        elif j == 2 and a[j][i]==0:
          flg = 1
        else:
          break
if flg == 0:
  for i in range(3):
    if a[i][i] == 0 and i != 2:
      continue
    elif a[i][i] == 0:
      flg = 1
    else:
      break
if flg == 0:
  for i in range(3):
    if a[i][2-i] == 0 and i != 2:
      continue
    elif a[i][2-i] == 0:
      flg = 1
    else:
      break
if flg == 0:
  print("No")
else:
  print("Yes")

Solution (Python):
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
b=[int(p())for _ in r(int(p()))]
print('YNeos'[all([sum(1<<i for i in r(9)if A[i]in b)&v!=v for v in[7,56,73,84,146,273,292,448]])::2])

Solution (Python):
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
b=[int(p())for _ in r(int(p()))]
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No')

Solution (Python):
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
N=int(p())
b=[int(p())for _ in r(N)]
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No')

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

f=sum(1<<i for i in range(9)if A[i]in b)
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if f&v==v]else'No')

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

f=0
for i in range(9):
	if A[i]in b:f|=1<<i
ans=[v for v in [7,56,73,84,146,273,292,448]if f&v==v]
print('Yes' if ans else 'No')

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

f=0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			f|=1<<i
ans=[v for v in [7,56,73,84,146,273,292,448]if f&v==v]
print('Yes' if ans else 'No')

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

f=0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			f|=1<<i
ans = 0
for v in [7,56,73,84,146,273,292,448]:
  ans |= f&v==v;
print('Yes' if ans else 'No')

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

field = 0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			field = field | (1 << i)
ans = False
for v in sum([[273,84],sum([[73<<i,7<<i*3]for i in range(3)],[])],[]):
  ans = ans or field&v==v;
print('Yes' if ans else 'No')

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

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

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

if A[0][0] == A[1][0] == A[2][0]:
    print("Yes")
elif A[0][0] == A[0][1] == A[0][2]:
    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[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][1] == A[2][2]:
    print("Yes")
elif A[0][2] == A[1][1] == A[2][0]:
    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)]
for k in range(n):
  for i in range(3):
    for j in range(3):
      if a[i][j]==b[k]:
        a[i][j]=-1
def result():
  for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==-1 or a[0][i]==a[1][i]==a[2][i]==-1:
      return 'Yes'
  if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
    return 'Yes'
  else:
    return 'No'
print(result())

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

for i in range(n):
  d=int(input())
  for j in range(9):
    if l1[j]==d:
      l1[j]=0
if l1[0]+l1[1]+l1[2]==0 or l1[3]+l1[4]+l1[5]==0 or l1[6]+l1[7]+l1[8]==0 or l1[0]+l1[4]+l1[8]==0 or l1[2]+l1[4]+l1[6]==0 or l1[0]+l1[3]+l1[6]==0 or l1[1]+l1[4]+l1[7]==0 or l1[2]+l1[5]+l1[8]==0:
  print("Yes")
else:
  print("No")

Solution (Python):

def main():
    A = []
    for i in range(3):
        A.append([int(x) for x in input().split()])
    N = int(input())
    bingo = [[False] * 3 for _ in range(3)]
    for n in range(N):
        B = int(input())
        for i in range(3):
            if B in A[i]:
                bingo[i][A[i].index(B)] = True
    for i in range(3):
        if bingo[i][0] == bingo[i][1] == bingo[i][2] is True:
            print('Yes')
            return
        if bingo[0][i] == bingo[1][i] == bingo[2][i] is True:
            print('Yes')
            return
    if bingo[0][0] == bingo[1][1] == bingo[2][2] is True:
        print('Yes')
        return
    if bingo[0][2] == bingo[1][1] == bingo[2][0] is True:
        print('Yes')
        return
    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
A = []
hit = []
for _ in range(3):
    A.append(list(map(int, input().split())))
    hit.append([False]*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:
                hit[i][j] = True
                break

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

print('No')

Solution (Python):
a = []
b = []
ans = 'No'

for i in range(3):
    a.extend([int(s) for s in input().split()])
n = int(input())
for j in range(n):
    value = int(input())
    b.append(value)
    if value in a:
        a[a.index(value)] = '*'

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[4] == a[8]:
    ans = 'Yes'
if a[0] == a[3] == a[6] or a[1] == a[4] == a[7] or a[2] == a[5] == a[8] or a[2] == a[4] == a[6]:
    ans = 'Yes'
print(ans)

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

Solution (Python):
def row():
  c=0
  for y in range(HEIGHT):
    for x in range(WIDTH):
      if A[y][x]!=-1:
        break
    else:
      c+=1
  return c


def col():
  c=0
  for x in range(WIDTH):
    for y in range(HEIGHT):
      if A[y][x]!=-1:
        break
    else:
      c+=1
  return c


def obl():
  c=0
  for z in range(HEIGHT):
    if A[z][z]!=-1:
      break
  else:
    c+=1
  
  y=0
  for x in range(WIDTH-1,-1,-1):
    if A[y][x]!=-1:
      break
    y+=1
  else:
    c+=1
  return c  
    

def main():
  for b in B:
    for y in range(HEIGHT):
      for x in range(WIDTH):
        if A[y][x]==b:
          A[y][x]=-1
  cnt=row()+col()+obl()
  print('Yes' if cnt else 'No')

  
if __name__=='__main__':
  HEIGHT=3
  WIDTH=3
  A=[[int(a) for a in input().split()] for y in range(HEIGHT)]
  N=int(input())
  B=[int(input()) for n in range(N)]
  main()

Solution (Python):
board = []

def detect():
    if sum([board[0], board[4], board[8]]) == 0:
        return True

    if sum([board[2], board[4], board[6]]) == 0:
        return True

    for i in range(3):
        if sum([board[i], board[i + 3], board[i + 6]]) == 0:
            return True

    for i in range(0, 3 * 3, 3):
        if sum([board[i], board[i + 1], board[i + 2]]) == 0:
            return True

    return False


for i in range(3):
    row = [int(v) for v in input().rstrip().split()]
    board.extend(row)


N = int(input().rstrip())
for i in range(N):
    b = int(input().rstrip())
    try:
        j =  board.index(b)
        board[j] = 0
    except ValueError:
        pass

r = 'Yes' if detect() else 'No'
print(r)

Solution (Python):
a = []
a1 = []
for i in range(3):
    a2 = list(map(int, input().split()))
    a.append(a2)
    a1 += a2
n = int(input())
b = []
num = 0
for h in range(n):
    b1 = int(input())
    if b1 in a1:
        num += 1
    b.append(b1)
if num < 3:
    print('No')
else:
    z = 'No'
    for j in range(3):
        if a[j][0] in b and a[j][1] in b and a[j][2] in b:
            z = 'Yes'
            break
        if a[0][j] in b and a[1][j] in b and a[2][j] in b:
            z = 'Yes'
            break
    if z == 'No':
        if a[0][0] in b and a[1][1] in b and a[2][2] in b:
            z = 'Yes'
        elif a[2][0] in b and a[1][1] in b and a[0][2] in b:
            z = 'Yes'
    print(z)

Solution (Python):
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'
if Aij[0].count('0')==3 or Aij[1].count('0')==3 or Aij[2].count('0')==3:
    print('Yes')
elif Aij[0][0]=='0' and Aij[1][0]=='0' and Aij[2][0]=='0':
    print('Yes')
elif Aij[0][1]=='0' and Aij[1][1]=='0' and Aij[2][1]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][2]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

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

for k in range(N):
    B = int(input())
    for l in range(3):
        for m in range(3):
            if A[l][m] == B:
                A[l][m] = 0

if (A[0][0] == A[0][1] == A[0][2] == 0) or (A[1][0] == A[1][1] == A[1][2] == 0) or (A[2][0] == A[2][1] == A[2][2] == 0):
    print ("Yes")
elif (A[0][0] == A[1][0] == A[2][0] == 0) or (A[0][1] == A[1][1] == A[2][1] == 0) or (A[0][2] == A[1][2] == A[2][2] == 0):
    print ("Yes")
elif (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
readline = sys.stdin.readline

A = [list(map(int, readline().split())) for _ in range(3)]

G = [[0, 0, 0] for _ in range(3)]
N = int(readline())
B = [int(readline()) for _ in range(N)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                G[i][j] = 1

ans = 'No'

if G[0][0] and G[1][1] and G[2][2]:
    ans = 'Yes'
if G[0][2] and G[1][1] and G[2][0]:
    ans = 'Yes'

for i in range(3):
    if G[i][0] and G[i][1] and G[i][2]:
        ans = 'Yes'
    if G[0][i] and G[1][i] and G[2][i]:
        ans = 'Yes'

print(ans)

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

bingocard = [[0]*4 for _ in range(4)]
N = int(input())
for _ in range(N):
    b = int(input())
    for row in range(3):
        for col in range(3):
            if b == A[row][col]:
                bingocard[row][col] = 1
                bingocard[row][3] += 1
                bingocard[3][col] += 1

flag = False

for row in bingocard:
    if row[3] == 3:
        flag = True


for col in bingocard[3]:
    if col == 3:
        flag = True
    

if bingocard[0][0] + bingocard[1][1] + bingocard[2][2] == 3:
    flag = True
if bingocard[2][0] + bingocard[1][1] + bingocard[0][2] == 3:
    flag = True

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

Solution (Python):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = -1
f = False
for i in range(3):
    for j in range(3):
        if (a[0][0] == a[0][1] == a[0][2]== -1) or (a[1][0] == a[1][1] == a[1][2]== -1) or (a[2][0] == a[2][1] == a[2][2]== -1):
            f = True
        elif (a[0][0] == a[1][0] == a[2][0] == -1) or (a[0][1] == a[1][1] == a[2][1] == -1) or (a[0][2] == a[1][2] == a[2][2] == -1):
            f = True
        elif (a[0][0] == a[1][1] == a[2][2] == -1) or (a[2][0] == a[1][1] == a[0][2] == -1):
            f = True
if f:
    print('Yes')
else:
    print('No')

Solution (Python):
A = [0]*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 = [0]*n
for i in range(n):
  b[i] = int(input())

flag = []
flag.append([0]*3)
flag.append([0]*3)
flag.append([0]*3)


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

  
ans = "No"
for i in range(3):
  if flag[i] == [1,1,1]:
    ans = "Yes"
  
x = [0,0,0]
y = [0, 0]
for i in range(3):
  y[0] += flag[i][i]
  y[1] += flag[i][2-i]
  for j in range(3):
  	x[j] += flag[i][j]

if 3 in x:
  ans = "Yes"
if 3 in y:
  ans = "Yes"
  
print(ans)

Solution (Python):
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
a = [a_1,a_2,a_3]
n = int(input())
for i in range(n):
  h = int(input())
  for j in range(3):
    for k in range(3):
      if(a[j][k]==h):
        a[j][k]=0
ans = "No"
for i in range(3):
  if(a[i][0]==0)and(a[i][0]==a[i][1])and(a[i][1]==a[i][2]):
    ans = "Yes"
for i in range(3):
  if(a[0][i]==0)and(a[0][i]==a[1][i])and(a[1][i]==a[2][i]):
    ans= "Yes"
if((a[0][0]==0)and(a[1][1]==a[2][2])and(a[0][0]==a[1][1]))or((a[0][2]==0)and(a[1][1]==a[2][0])and(a[0][2]==a[1][1])):
  ans = "Yes"
  
print(ans)

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

for _ in range(n):
  b = int(input())
  for i in range(9):
    if b == lis[i]:
      lis[i] = 0

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

Solution (Python):
l=list(map(int,input().split()))
l+=list(map(int,input().split()))
l+=list(map(int,input().split()))

n=int(input())

ans_list=[False]*9

for i in range(n):
  num=int(input())
  if num in l:
    index=l.index(num)
    ans_list[index]=True
    
if ans_list[0] and ans_list[1] and ans_list[2]:
  print("Yes")
elif ans_list[0] and ans_list[3] and ans_list[6]:
  print("Yes")
elif ans_list[3] and ans_list[4] and ans_list[5]:
  print("Yes")
elif ans_list[6] and ans_list[7] and ans_list[8]:
  print("Yes")
elif ans_list[1] and ans_list[4] and ans_list[7]:
  print("Yes")
elif ans_list[2] and ans_list[5] and ans_list[8]:
  print("Yes")
elif ans_list[0] and ans_list[4] and ans_list[8]:
  print("Yes")
elif ans_list[2] and ans_list[4] and ans_list[6]:
  print("Yes")
else:
  print("No")

Solution (Python):
card = []
check = [False for i in range(9)]
for i in range(3):
  card += list(map(int, input().split()))
N = int(input())
for i in range(N):
  a = int(input())
  if a in card:
    check[card.index(a)] = True
ans = "No"
for i in range(3):
  if check[i] and check[3+i] and check[6+i]:
    ans = "Yes"
  if check[i*3] and check[i*3+1] and check[i*3+2]:
    ans = "Yes"
if check[4] and ((check[0] and check[8])or(check[2] and check[6])):
  ans = "Yes"
  
print(ans)

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

N=int(input())

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

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

import numpy as np

if min(np.sum(x, axis=0))==0:
	kotae='Yes'
elif min(np.sum(x, axis=1))==0:
	kotae='Yes'
elif x[0][0]==0 and x[1][1]==0 and x[2][2]==0:
	kotae='Yes'
elif x[2][0]==0 and x[1][1]==0 and x[0][2]==0:
	kotae='Yes'
else:
	kotae='No'

print(kotae)