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()
for i in range(3):
    a.append([int(x) for x in input().split()])
n = int(input())
b = list()
for i in range(n):
    b.append(int(input()))
appear = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in b:
            if (a[i][j] == k):
                appear[i][j] = 1

def x ():
    for i in range(3):
        if (appear[i][0] and appear[i][1] and appear[i][2] ):
            return "Yes"
    for i in range(3):
        if (appear[0][i] and appear[1][i] and appear[2][i]):
            return "Yes"
    if (appear[0][0] and appear[1][1] and appear[2][2]):
        return "Yes"
    if (appear[0][2] and appear[1][1] and appear[2][0]):
        return "Yes"
    return "No"
print(x())

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


for i in range(3):
    bingo.append([rows[0][i], rows[1][i], rows[2][i]])


bingo.append([rows[0][0], rows[1][1], rows[2][2]])
bingo.append([rows[0][2], rows[1][1], rows[2][0]])

N = int(input())

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

result = 'No'
for numbers in bingo:
    matched_numbers = set(numbers) & set(selected_numbers)
    if len(matched_numbers) == 3:
        result = 'Yes'
        break

print(result)

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = -1
m = False
for i in range(3):
    if sum(a[i]) == -3:
        m = True
    if a[0][i] + a[1][i] + a[2][i] == -3:
        m = True
if a[0][0] + a[1][1]  + a[2][2] == -3:
    m = True
if a[0][2] + a[1][1]  + a[2][0] == -3:
    m = True

if m == True:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

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

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

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

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

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

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

for i in range(3):
    if all(c[i]):
        print("Yes")
        exit()

col = [0] * 3
for i in range(3):
    for j in range(3):
        if c[i][j]:
            col[j] += 1
if any(map(lambda x: x == 3, col)):
    print("Yes")
    exit()

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

print("No")

Solution (Python):
a=open(0).read().split();print('YNeos'[all(t-set(map(a.index,a[9:]))for t in({0,3,6},{0,4,8},{2,4,6},{2,5,8},{3,4,5},{6,7,8}))::2])

Solution (Python):
import sys

A = []

for i in range(3):
    A += [int(i) for i in input().split()]

P = [False for _ in range(9)]

isBingo = False

N = int(input())

for _ in range(N):
    b = int(input())
    for i in range(9):
        if A[i] == b:
            P[i] = True


for i in range(3):
    i *= 3
    if P[i] == P[i+1] == P[i+2] == True:
        isBingo = True

for i in range(3):
    if P[i] == P[i+3] == P[i+6] == True:
        isBingo = True

if (P[0] == P[4] == P[8] == True) or (P[2] == P[4] == P[6] == True):
    isBingo = True

if isBingo == True:
    print("Yes")
else:
    print("No")

Solution (Python):
a=[]
for i 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 in range(3):
			if a[i][j]==b:
				a[i][j]=0
for i in range(3):
	flag = True
	for j in range(3):
		if a[i][j] != 0:
			flag = False
			break
	if flag:
		print("Yes")
		exit(0)

for i in range(3):
	flag = True
	for j in range(3):
		if a[j][i] != 0:
			flag = False
			break
	if flag:
		print("Yes")
		exit(0)

flag = True
for i in range(3):
	if a[i][i] != 0:
		flag = False
		break
if flag:
	print("Yes")
	exit(0)

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

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

n = int(input())
b = [int(input()) for _ in range(n)]
ans = [x, y, z]

for i in range(3):
    ans.append([x[i], y[i], z[i]])

ans.append([x[0], y[1], z[2]])
ans.append([x[2], y[1], z[0]])

cnt_list = []
for i in range(len(ans)):
    cnt = 0
    for j in list(set(x + y + z) & set(b)):
        if j in ans[i]:
            cnt += 1
    cnt_list.append(cnt)

for cnt in cnt_list:
  if cnt >= 3:
    print('Yes')
    exit()
 
print('No')

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

Solution (Python):
A=[]
cnt=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]="○"
for l in range(3):
  if A[l][0]=="○"and A[l][1]=="○"and A[l][2]=="○":
    cnt+=1
  elif A[0][l]=="○" and A[1][l]=="○"and A[2][l]=="○":
    cnt+=1
  elif A[0][0]=="○"and A[1][1]=="○"and A[2][2]=="○":
    cnt+=1
  elif A[0][2]=="○"and A[1][1]=="○"and A[2][0]=="○":
    cnt+=1

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

Solution (Python):
A=[]
flag=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]=0

if A[0]==[0,0,0] or A[1]==[0,0,0] or A[2]==[0,0,0]:
  print("Yes")
  flag=1
elif A[1][1]==0 and A[2][2]==0 and A[0][0]==0:
  print("Yes")
  flag=1
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  flag=1
else:
  for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
      print("Yes")
      flag=1
      break
if flag == 0:
  print("No")

Solution (Python):
A=[]
flag=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]=0

if A[0]==[0,0,0] or A[1]==[0,0,0] or A[2]==[0,0,0]:
  print("Yes")
  flag=1
elif A[1][1]==0 and A[2][2]==0 and A[0][0]==0:
  print("Yes")
  flag=1
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  flag=1
else:
  for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
      print("Yes")
      flag=1
      break
if flag == 0:
  print("No")

Solution (Python):
A = [[int(i) for i in input().split()] for j in range(3)]
B = [[0 for i in range(3)] for j in range(3)]
n = int(input())
num_to_loc = dict()
for i in range(3):
    for j in range(3):
        num_to_loc[A[i][j]] = (i,j)
for i in range(n):
    b = int(input())
    if b in num_to_loc:
        x = num_to_loc[b]
        B[x[0]][x[1]] = 1
tmp = max([sum([B[i][j] for i in range(3)]) for j in range(3)])
tmp = max(tmp, max([sum([B[i][j] for j in range(3)]) for i in range(3)]))
tmp = max(tmp, sum([B[i][i] for i in range(3)]), sum([B[i][2-i] for i in range(3)]))
if tmp == 3:
    print("Yes")
else:
    print("No")

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

Solution (Python):


i=[input().split() for l in range(4)]

n=int(i[3][0])

j = [input() for i in range(n)]





k = [['0' for o in range(3)] for p in range(3)]

for b in range(3):
    
    for c in range(3):
        
        for d in range(n):
            
            if i[b][c]==j[d]:
                k[b][c]='1'
                
                
                





if  k[0][0]=='1' and k[0][1]=='1' and k[0][2]=='1'\
or k[1][0]=='1' and k[1][1]=='1' and k[1][2]=='1'\
or k[2][0]=='1' and k[2][1]=='1' and k[2][2]=='1'\
or k[0][0]=='1' and k[1][0]=='1' and k[2][0]=='1'\
or k[0][1]=='1' and k[1][1]=='1' and k[2][1]=='1'\
or k[0][2]=='1' and k[1][2]=='1' and k[2][2]=='1'\
or k[0][0]=='1' and k[1][1]=='1' and k[2][2]=='1'\
or k[2][0]=='1' and k[1][1]=='1' and k[0][2]=='1':
	print('Yes')
else:
    print('No')

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

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

n = int(input())
for x in range(n):
  b = int(input()) 
  try:
    i = aaa.index(b) 
  except:
    continue 
  if i >= 0: 
    aaa[i] = -1 
for i, j, k in [(0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)]:
  if aaa[i] == -1 and aaa[j] == -1 and aaa[k] == -1:
    print('Yes')
    break
else:
  print('No')

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


for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())
    
N = int(input())

k = 0
flag = [[0 for j in range(3)] for i in range(3)]

b = [0] * N
for n in range(N):
    b[n] = int(input())
    for i in range(3):
        for j in range(3):
            
            if(b[n] == A[i][j]):
                A[i][j] = 0
                
            '''
            if(b[n] == A[i][j]): 
                flag[i][j] = 1
           
            '''
ans = 'No'

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

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

if(A[0][2] + A[1][1] + A[2][0] == 0):
    ans = 'Yes' 
    
print(ans)

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

A = [A1,A2,A3]

def check_bingo(l):
    if l[0][0] == l[0][1] == l[0][2]:print('Yes')
    elif l[1][0] == l[1][1] == l[1][2]:print('Yes')
    elif l[2][0] == l[2][1] == l[2][2]:print('Yes')
    elif l[0][0] == l[1][0] == l[2][0]:print('Yes')
    elif l[0][1] == l[1][1] == l[2][1]:print('Yes')
    elif l[0][2] == l[1][2] == l[2][2]:print('Yes')
    elif l[0][0] == l[1][1] == l[2][2]:print('Yes')
    elif l[0][2] == l[1][1] == l[2][0]:print('Yes')  
    else: print('No')

if __name__ == "__main__":
    for i in b:
        for y,row in enumerate(A):
            try:
                A[y][row.index(i)] = -1
                break
            except ValueError:
                continue
    check_bingo(A)

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

n = int(input())



for k in range(n):
    b = input()
    for i in range(3):
      for j in range(3):
        if(b == a[i][j]):
          a[i][j] = 'maru'



frag = False


for i in range(3):
     if((a[i][0] == 'maru') and (a[i][1] == 'maru')and(a[i][2] == 'maru')):
        frag = True

for i in range(3):
     if((a[0][i] == 'maru') and (a[1][i] == 'maru')and(a[2][i] == 'maru')):
        frag = True

if((a[0][0] == 'maru')and(a[1][1] == 'maru')and(a[2][2]=='maru')):
    frag = True
if((a[2][0] == 'maru')and(a[1][1] == 'maru')and(a[0][2]=='maru')):
    frag = True
        

if(frag == True):
    print('Yes')
else:
    print('No')

Solution (Python):
def main(a: list, n: int, b: list):
    res = [[False, False, False], [False, False, False], [False, False, False]]
    for b in b:
        for i, a_row in enumerate(a):
            for j, a_col in enumerate(a_row):
                if b == a_col:
                    res[i][j] = True

    for i in range(3):
        
        if False not in res[i]:
            print("Yes")
            return

        
        if False not in [res[0][i], res[1][i], res[2][i]]:
            print("Yes")
            return

    
    
    if False not in [res[0][0], res[1][1], res[2][2]]:
        print("Yes")
        return

    
    if False not in [res[0][2], res[1][1], res[2][0]]:
        print("Yes")
        return

    print("No")


if __name__ == "__main__":
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]

    main(a, n, b)

Solution (Python):
import sys

A = list()
for i in range(3):
    a = list(map(int,input().split()))
    A.append(a)
N = int(input())
for i in range(N):
    target = int(input())
    for a in range(len(A)):
        for k in range(len(A[a])):
            if target == A[a][k]:
                A[a][k] = 0


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

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

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

print('No')

Solution (Python):







times = 3
cardnums = []
for _ in range(times):
    cardnums = cardnums + list(map(int,input().split()))  

n = int(input())

times = n
bingonums = []
for _ in range(times):
    bingonums = bingonums + list(map(int,input().split()))  

for bingonum in bingonums:
    cardnums = [101 if cardnum == bingonum else cardnum for cardnum in cardnums]

def bingo_check(lis:list) -> str:
    if sum(lis[0:3])==303:
        return "Yes"
    if sum(lis[3:6])==303:
        return "Yes"
    if sum(lis[6:9])==303:
        return "Yes"
    if sum([lis[0],lis[3],lis[6]])==303:
        return "Yes"
    if sum([lis[1],lis[4],lis[7]])==303:
        return "Yes"
    if sum([lis[2],lis[5],lis[8]])==303:
        return "Yes"
    if sum([lis[0],lis[4],lis[8]])==303:
        return "Yes"
    if sum([lis[2],lis[4],lis[6]])==303:
        return "Yes"
    return "No"

ans = bingo_check(cardnums)
print(ans)

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

for i in range(int(input())):
    b = int(input())
    for j in range(3):
        if b in A[j]: A[j][A[j].index(b)] = -1

ans = False
for k in range(2):
    for i in range(3):
        c = 0
        for j in range(3):
            if k == 0: 
                if A[i][j] == -1: c += 1
            else:
                if A[j][i] == -1: c += 1
        if c == 3: ans = True
c = 0
for i in range(3):
    if A[i][i] == -1: c += 1
if c == 3: ans = True

c = 0
for i in range(3):
    if A[i][2-i] == -1: c += 1
if c == 3: ans = True

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

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

for i in range(3):
  for j in range(3):
    for b in bs:
      if a[i][j] == b:
        a[i][j] = 0
y = "Yes"
c = "No"
for i in range(3):
  if a[0][i] == 0 and a[1][i] == 0 and a[2][i]==0:
    c = y
    break
  elif a[i][0]==0 and a[i][1] == 0 and a[i][2]==0:
    c = y
    break
  elif a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    c = y
    break
  elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    c = y
    break
print(c)

Solution (Python):

import numpy as np
A = np.full((3, 3), 0)

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())
B = [0] * N
for j in range(N):
    B[j] = int(input())


if A[0, 0] in B and A[0, 1] in B and A[0, 2] in B:
    print("Yes")
elif A[1, 0] in B and A[1, 1] in B and A[1, 2] in B:
    print("Yes")
elif A[2, 0] in B and A[2, 1] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 0] in B and A[1, 0] in B and A[2, 0] in B:
    print("Yes")
elif A[0, 1] in B and A[1, 1] in B and A[2, 1] in B:
    print("Yes")
elif A[0, 2] in B and A[1, 2] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 0] in B and A[1, 1] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 2] in B and A[1, 1] in B and A[2, 0] in B:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    a = [input().split() for _ in range(3)]
    ans = [[0] * 3 for _ in range(3)]
    n = int(input())
    b = [input() for _ in range(n)]

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

    if ans[0][0] == ans[0][1] == ans[0][2] == 1:
        print('Yes')
    elif ans[1][0] == ans[1][1] == ans[1][2] == 1:
        print('Yes')
    elif ans[2][0] == ans[2][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][0] == ans[2][0] == 1:
        print('Yes')
    elif ans[0][1] == ans[1][1] == ans[2][1] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][2] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][1] == ans[2][0] == 1:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

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



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




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

for i in range(3):
    if A[i][0] == A[i][1] and A[i][1] == A[i][2] and A[i][2] == 1000:
        flag = 1
    if A[0][i] == A[1][i] and A[1][i] == A[2][i] and A[2][i] == 1000:
        flag = 1
    if A[0][0] == A[1][1] and A[1][1] == A[2][2] and A[2][2] == 1000:
        flag = 1
    if A[0][2] == A[1][1] and A[1][1] == A[2][0] and A[2][0] == 1000:
        flag = 1

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

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

bingo_flg = False
if c[1][0] + c[2][0] + c[0][0] == 3:
  bingo_flg= True
  
if c[1][1] + c[2][1] + c[0][1] == 3:
  bingo_flg= True

if c[1][2] + c[2][2] + c[0][2] == 3:
  bingo_flg= True

if c[0][0] + c[0][1] + c[0][2] == 3:
  bingo_flg= True

if c[1][0] + c[1][1] + c[1][2] == 3:
  bingo_flg= True
  
if c[2][0] + c[2][1] + c[2][2] == 3:
  bingo_flg= True
  
if c[0][0] + c[1][1] + c[2][2] == 3:
  bingo_flg= True
    
if c[2][0] + c[1][1] + c[0][2] == 3:
  bingo_flg= True
  
if bingo_flg:
  print("Yes")
else:
  print("No")

Solution (Python):
A=[]
flag=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]=0

if A[0]==[0,0,0] or A[1]==[0,0,0] or A[2]==[0,0,0]:
  print("Yes")
  flag=1
elif A[1][1]==0 and A[2][2]==0 and A[0][0]==0:
  print("Yes")
  flag=1
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  flag=1
else:
  for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
      print("Yes")
      flag=1
      break
if flag == 0:
  print("No")

Solution (Python):
from collections import OrderedDict

f_row_nums = list(input().split())
s_row_nums = list(input().split())
t_row_nums = list(input().split())
N = int(input())
chosen_nums = [input() for _ in range(N)]

f_dict = OrderedDict()
for key in f_row_nums:
    f_dict[key] = False
s_dict = OrderedDict()
for key in s_row_nums:
    s_dict[key] = False
t_dict = OrderedDict()
for key in t_row_nums:
    t_dict[key] = False

for num in chosen_nums:
    if num in f_dict:
        f_dict[num] = True
    if num in s_dict:
        s_dict[num] = True
    if num in t_dict:
        t_dict[num] = True

f_rows = list(f_dict.values())
s_rows = list(s_dict.values())
t_rows = list(t_dict.values())

f_cols = [f_rows[0], s_rows[0], t_rows[0]]
s_cols = [f_rows[1], s_rows[1], t_rows[1]]
t_cols = [f_rows[2], s_rows[2], t_rows[2]]

out = "No"

if all(f_rows) or all(s_rows) or all(t_rows) or all(f_cols) or all(s_cols) or all(t_cols):
    out = "Yes"
elif f_rows[0] and s_rows[1] and t_rows[2]:
    out = "Yes"
elif f_rows[2] and s_rows[1] and t_rows[0]:
    out = "Yes"

print(out)

Solution (Python):
a = []
for i in range(3):
    a.append([int(i) for i in input().split()])
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            num = a[j].index(b)
            a[j][num] = 0
f = a
flag = False

for i in f:
    if i[0] == 0 and i[1]==0 and i[2]==0:
        flag = True

for i in range(3):
    if f[0][i] == 0 and f[1][i]==0 and f[2][i]==0: 
        flag = True

if f[0][0] == 0 and f[1][1]==0 and f[2][2]==0: 
    flag = True 
elif f[0][2] ==0 and f[1][1]==0 and f[2][0]==0:
    flag = True
print('Yes' if flag==True else 'No')

Solution (Python):


ls = []
count = [0]*9
for i in range(3):
    ls.extend(input().split(' '))
for i in range(int(input())):
    s = input()
    if s in ls:
        i = ls.index(s)
        count[i]="1"
flag = 0
for i in range(3):
    if count[i] == count[i+3] == count[i+6]=="1":
        flag = 1
        break
for i in range(0,8,3):
    if count[i] == count[i+1] == count[i+2] == "1":
        flag = 1
        break
if count[0]==count[4]==count[8]=="1":
    flag = 1
if count[2] == count[4] == count[6] == "1":
    flag = 1
if flag == 1:
    print("Yes")
elif flag == 0:
    print("No")

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

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

		elif bingo[0][2] ==True:
			if bingo[2][0] == True:
				return True

for i in range(len(b)):
	for j in range(3):
		for k in range(3):
			if bingo[j][k] == b[i]:
				bingo[j][k] = True
if judge(bingo):
	print('Yes')
else:
	print('No')

Solution (Python):



def main():
    a = [input().split() for _ in range(3)]
    ans = [[0] * 3 for _ in range(3)]
    n = int(input())
    b = [input() for _ in range(n)]

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

    if ans[0][0] == ans[0][1] == ans[0][2] == 1:
        print('Yes')
    elif ans[1][0] == ans[1][1] == ans[1][2] == 1:
        print('Yes')
    elif ans[2][0] == ans[2][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][0] == ans[2][0] == 1:
        print('Yes')
    elif ans[0][1] == ans[1][1] == ans[2][1] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][2] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][1] == ans[2][0] == 1:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
ans = [[0 for i in range(3)] for j in range(3)]
N = int(input())
for i in range(N):
  a = int(input())
  for j in range(3):
    for k in range(3):
      if a == A[j][k]:
        ans[j][k] = 1

flag = 0
for i in range(3):
  if sum(ans[i]) == 3:
    flag = 1
  if sum(ans[j][i] for j in range(3)) == 3:
    flag = 1
if ans[0][0] * ans[1][1] * ans[2][2] == 1:
  flag = 1
  
if ans[2][0] * ans[1][1] * ans[0][2] == 1:
  flag = 1

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

Solution (Python):
a = [[]*3]*3

for i in range(3):
  a[i] = [int(i) for i in input().split()]

n = int(input())

for i in range(n):
  b = int(input())
  for j in range(3):
    if b in a[j]:
      for k in range(3):
        if b == a[j][k]:
          a[j][k] = 0
          break
b = 0          
for i in range(3):
  if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0:
    b += 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
    b += 1
    break
  elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    b += 1
    break
  elif a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0:
    b += 1
    break

if b == 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()))



def isBingo():
    
    for i in range(3):
        if all(a[i][j] is None for j in range(3)):
            return True

    
    for i in range(3):
        if all(a[j][i] is None for j in range(3)):
            return True

    
    if a[0][0] is None and a[1][1] is None and a[2][2] is None:
        return True
    if a[0][2] is None and a[1][1] is None and a[2][0] is None:
        return True

    return False

for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                a[i][j] = None

if isBingo():
    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()))
ans = "No"

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

for i in range(3):
    if A[3*i] in b and A[3*i+1] in b and A[3*i+2] in b:
        ans = "Yes"
    elif A[i] in b and A[i+3] in b and A[i+6] in b:
        ans = "Yes"
if A[0] in b and A[4] in b and A[8] in b:
        ans = "Yes"
elif A[2] in b and A[4] in b and A[6] in b:
    ans = "Yes"
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  
NO = "No"  

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    f = [[False] * (N) for i in range(N)]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i] == A[j][k]:
                    f[j][k] = True
    t = False
    for i in range(3):
        if all([f[i][k] for k in range(3)]):
            t = True

    for i in range(3):
        if all([f[k][i] for k in range(3)]):
            t = True
    
    if all([f[k][k] for k in range(3)]):
        t = True

    if f[0][2] and f[1][1] and f[2][0]:
        t = True

    if t:
        print(YES)
    else:
        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):
    Ai = list(map(int,input().split()))
    for j in range(3):
        A.append(Ai[j])

N = int(input())
b = [int(input()) for n in range(N)]
for k in range(len(A) - len(b)):
    b.append(-1)
bingo = [0] * 3

for n in range(len(A)):
    for m in range(len(A)):
        if b[n] == A[m]:
            A[m] = 0
        elif b[m] == -1:
            continue
ans = [A[0:3], A[3:6], A[6:9], A[::3], A[1::3], A[2::3], A[::4], A[2::2][0:3]]
if any([an == bingo for an in ans]):
    print("Yes")
else:
    print("No")

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

for _ in range(N):
  X = int(input())
  for i in range(3):
    for j in range(3):
      if board[i][j]==X:
        visited[i][j] = 1

check=False
for i in range(3):
  rows = 0
  cols = 0
  for j in range(3):
    rows+=visited[i][j]
    cols+=visited[j][i]
  if rows==3 or cols==3:
    check=True

rows = 0
for i in range(3):
  rows += visited[i][i]
if rows==3:
  check=True
rows = 0
cols = 0
for i in range(3):
  rows += visited[i][2-i]
  cols += visited[2-i][i]
if rows==3 or cols==3:
  check=True

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

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

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

for i in range(3):
    f = True
    for j in range(3):
        if a[i][j] != -1:
            f = False
    if f:
        print('Yes')
        exit()

for i in range(3):
    f = True
    for j in range(3):
        if a[j][i] != -1:
            f = False
    if f:
        print('Yes')
        exit()

f = True
for i in range(3):
    if a[i][i] != -1:
        f = False
if f:
    print('Yes')
    exit()

f = True
for i in range(3):
    if a[i][2-i] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')

Solution (Python):
l = [list(map(int, input().split())) for i in range(3)]
n = int(input())
m = [int(input()) for i in range(n)]
c = [[False, False, False], [False, False, False], [False, False, False]]
ans = False
for k in range(n):
    for i in range(3):
        for j in range(3):
            if m[k] == l[i][j]:
                c[i][j] = True
for i in range(3):
    ans = ans or c[i].count(True) == 3
    ans = ans or [c[0][i], c[1][i], c[2][i]].count(True) == 3
ans = ans or [c[0][0], c[1][1], c[2][2]].count(True) == 3
ans = ans or [c[2][0], c[1][1], c[0][2]].count(True) == 3
if ans:
    print("Yes")
else:
    print("No")