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 math
from functools import lru_cache





MOD = 10**9 +7
INF = float('inf')





kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr





a,b,c = list(map(int,input().split()))
d,e,f = list(map(int,input().split()))
g,h,i = list(map(int,input().split()))

bingo = [a,b,c,d,e,f,g,h,i]


check = [0,0,0,0,0,0,0,0,0]

N = int(input())
for i in range(N):
  z = int(input())
  for j in range(9):
    if bingo[j] == z:
      check[j] = 1
      
is_bingo = 0

if check[0] and check[1] and check[2]:
  is_bingo = 1
if check[3] and check[4] and check[5]:
  is_bingo = 1
if check[6] and check[7] and check[8]:
  is_bingo = 1
if check[0] and check[3] and check[6]:
  is_bingo = 1
if check[1] and check[4] and check[7]:
  is_bingo = 1
if check[2] and check[5] and check[8]:
  is_bingo = 1
if check[0] and check[4] and check[8]:
  is_bingo = 1
if check[2] and check[4] and check[6]:
  is_bingo = 1

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

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

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

for i in range(n):
    for j in range(9):
        if s[i] == x[j]:
            x[j] = 0

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

Solution (Python):


a = []
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
n = int(input())
c = [[0,0,0],[0,0,0],[0,0,0]]

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

flag = False

for i in range(3):
    if c[0][i] + c[1][i] + c[2][i] == 3 and flag == False:
        print("Yes")
        flag = True
        break
        
    if c[i][0] + c[i][1] + c[i][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break

    """
    if c[i%3][0] + c[(i+1)%3][1] + c[(i+2)%3][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    """
    if c[0][0] + c[1][1] + c[2][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break

    if c[0][2] + c[1][1] + c[2][0] == 3 and flag == False:
        print("Yes")
        flag = True
        break

if flag == False:
    print("No")

Solution (Python):
A = []
for i in range(3):
    A.append(input().split())
N = int(input())
for i in range(N):
    X = input()
    for j in range(3):
        if A[j][0] == X:
            A[j][0] = 'X'
        if A[j][1] == X:
            A[j][1] = 'X'
        if A[j][2] == X:
            A[j][2] = 'X'
result = []
for i in range(3):
    result.append(A[i])
if (result[0][0] == result[0][1] == result[0][2]) or (result[1][0] == result[1][1] == result[1][2]) or (result[2][0] == result[2][1] == result[2][2]):
    print('Yes')
elif (result[0][0] == result[1][0] == result[2][0]) or (result[0][1] == result[1][1] == result[2][1]) or (result[0][2] == result[1][2] == result[2][2]):
    print('Yes')
elif (result[0][0] == result[1][1] == result[2][2]) or (result[0][2] == result[1][1] == result[2][0]):
    print('Yes')
else:
    print('No')

Solution (Python):
A = []
card = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
r = False
for _ in range(3):
    a = list(map(int, input().split()))
    A.append(a)
n = int(input())
B = []
for _ in range(n):
    b = int(input())
    B.append(b)
for b in B:
    for k, a in enumerate(A):
        if b in a:
            card[k][a.index(b)] = 1
for i in range(3):
    if card[0][i] == card[1][i] == card[2][i] == 1:
        r = True
for i in range(3):
    if card[i][0] == card[i][1] == card[i][2] == 1:
        r = True
if (
    card[0][0] == card[1][1] == card[2][2] == 1
    or card[0][2] == card[1][1] == card[2][0] == 1
):
    r = True
print("Yes") if r else print("No")

Solution (Python):
lsa=list(map(int,input().split()))
lsb=list(map(int,input().split()))
lsc=list(map(int,input().split()))
n=int(input())
called=[int(input()) for i in range(n)]

lsaa=[lsa[0],lsb[0],lsc[0]]
lsbb=[lsa[1],lsb[1],lsc[1]]
lscc=[lsa[2],lsb[2],lsc[2]]

lsx=[lsa[0],lsb[1],lsc[2]]
lsy=[lsa[2],lsb[1],lsc[0]]

ls=[lsa,lsb,lsc,lsaa,lsbb,lscc,lsx,lsy]

for i in ls:
    flag=False
    for j in i:
        if j in called:
            flag=True
        else:
            flag=False
            break
    if flag:
        break

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

Solution (Python):
As = []
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))

cs = [[0,0,0], [0,0,0],[0,0,0]]
pos_dic = {}
for i,x in enumerate(As):
  for j,xx in enumerate(x):
    pos_dic[xx] = (i,j)
    
def check(cs):
  for i in range(3):
    if sum(cs[i]) == 3:
      return True
    if (cs[0][i] + cs[1][i] + cs[2][i]) == 3:
      return True
  if (cs[2][2] + cs[1][1] + cs[0][0]) == 3:
    return True
  if (cs[2][0] + cs[1][1] + cs[0][2]) == 3:
    return True
  return False
    

flag = 0
N = int(input())
for i in range(N):
  x = int(input())
  if x in pos_dic:
    i,j = pos_dic[x]
    cs[i][j] = 1
    if check(cs):
      flag = 1
      break
if flag == 0:
  print("No")
else:
  print("Yes")

Solution (Python):
bingo = []
for i in range(3):
    arr = list(map(int, input().split()))
    bingo.append(arr)
n = int(input())
for i in range(n):
    cursor = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == cursor:
                bingo[j][k] = 0
flag = False
for i in bingo:
    if sum(i) == 0:
        flag = True
for i in range(3):
    if bingo[0][i] + bingo[1][i] + bingo[2][i] == 0:
        flag = True
cross1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
cross2 = bingo[0][2] + bingo[1][1] + bingo[2][0]
if cross1 == 0 or cross2 == 0:
    flag = True

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

Solution (Python):
R_1 = list(map(int,input().split()))
R_2 = list(map(int,input().split()))
R_3 = list(map(int,input().split()))

C_1 = [R_1[0],R_2[0],R_3[0]]
C_2 = [R_1[1],R_2[1],R_3[1]]
C_3 = [R_1[2],R_2[2],R_3[2]]

S_R = [R_1[2],R_2[1],R_3[0]]
S_L = [R_1[0],R_2[1],R_3[2]]

n = int(input())
for i in range(n):
    tmp = int(input())
    R_1 = [j for j in R_1 if j != tmp]
    R_2 = [j for j in R_2 if j != tmp]
    R_3 = [j for j in R_3 if j != tmp]
    C_1 = [j for j in C_1 if j != tmp]
    C_2 = [j for j in C_2 if j != tmp]
    C_3 = [j for j in C_3 if j != tmp]
    S_R = [j for j in S_R if j != tmp]
    S_L = [j for j in S_L if j != tmp]

if len(R_1)*len(R_2)*len(R_3)*len(C_1)*len(C_2)*len(C_3)*len(S_R)*len(S_L) == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

num_array = np.ones((3, 3), int)
for row in range(3):
    num_array[row, :] = list(map(int, input().split()))

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

b_set = set(b_list)
flag = False

for i in range(3):
    tate = set(num_array[i, :])
    yoko = set(num_array[:, i])
    if len(tate & b_set) == 3 or len(yoko & b_set) == 3:
        flag = True 

naname_one = set([num_array[0,0], num_array[1,1], num_array[2,2]])
naname_two = set([num_array[0,2], num_array[1,1], num_array[2,0]])
if len(naname_one & b_set) == 3 or len(naname_two & b_set) == 3:
    flag = True

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

Solution (Python):

A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))

A=[]
A.append(A1)
A.append(A2)
A.append(A3)
N=int(input())

ans='No'

for _ in range(N):
    b=int(input())
    if b in A1:
        A1[A1.index(b)]=0
    if b in A2:
        A2[A2.index(b)]=0
    if b in A3:
        A3[A3.index(b)]=0

if not any(A1) or not any(A2) or not any(A3) :
    ans='Yes'

A1c=[A1[0],A2[0],A3[0]]
A2c=[A1[1],A2[1],A3[1]]
A3c=[A1[2],A2[2],A3[2]]

if not any(A1c) or not any(A2c) or not any(A3c) :
    ans='Yes'

A1n=[A1[0],A2[1],A3[2]]
A2n=[A1[2],A2[1],A3[0]]

if not any(A1n) or not any(A2n):
    ans='Yes'

print(ans)

Solution (Python):
from itertools import product

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
bingo = [[0] * 3 for _ in range(3)]
for b in B:
    for i, j in product(range(3), repeat=2):
        if A[i][j] == b:
            bingo[i][j] = 1
            break
flag = False
for i in range(3):
    if sum(bingo[i][j] for j in range(3)) == 3:
        flag = True
for j in range(3):
    if sum(bingo[i][j] for i in range(3)) == 3:
        flag = True
if sum(bingo[i][i] for i in range(3)) == 3 or sum(bingo[i][2-i] for i in range(3)) == 3:
    flag = True
print('Yes' if flag else 'No')

Solution (Python):
*A1, = map(int, input().split())
*A2, = map(int, input().split())
*A3, = map(int, input().split())
A = A1 + A2 + A3
N = int(input())
a = [int(input()) for _ in range(N)]
chk = [A[:3], A[3:6], A[6:9], A[::3], A[1::3], A[2::3], A[::4], A[2:7:2]]
for c in chk:
    ans = 0
    for cc in c:
        if cc in a:
            ans += 1
    if ans == 3:
        print("Yes")
        exit()
print("No")

Solution (Python):



'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''


    
def main():
    import sys
    input = sys.stdin.readline
    
    A = []
    for i in range(3): 
        a = list(map(int, input().split()))
        A.append(a)

    
    n = int(input())
    B = []
    for i in range(n):
        B.append(int(input()))
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if B[i]==A[j][k]:
                    A[j][k]=101
    flg = False
    for i in range(3):
        if A[i][0] == A[i][1]== A[i][2]==101:
            flg = True
            break
    for j in range(3):
        if A[1][j] == A[2][j] == A[0][j]==101:
            flg = True
            break
    if A[0][0] == A[1][1] == A[2][2] == 101 or A[0][2] == A[1][1] == A[2][0] == 101:
        flg = True
    if flg:
        print("Yes")
    else:
        print("No")



    



if __name__ == "__main__":
    main()

Solution (Python):
def solve():
    from sys import stdin
    f_i = stdin
    
    A = []
    for i in range(3):
        A += list(map(int, f_i.readline().split()))
    
    nums = dict()
    for a in A:
        nums[a] = True
    
    N = int(f_i.readline())
    
    for i in range(N):
        b = int(f_i.readline())
        if b in nums:
            nums[b] = False
    
    line = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7),
            (2, 5, 8), (0, 4, 8), (2, 4, 6)]
    
    for l in line:
        for n in l:
            if nums[A[n]]:
                break
        else:
            ans = 'Yes'
            break
    else:
        ans = 'No'
    
    print(ans)

solve()

Solution (Python):
def Yes():
    print("Yes")
    exit()

A1 = list(map(int, input().split(" ")))
A2 = list(map(int, input().split(" ")))
A3 = list(map(int, input().split(" ")))

a1 = [False,False,False]
a2 = [False,False,False]
a3 = [False,False,False]

N  = int(input())

for i in range(0,N):
    b = int(input())
    
    for j in range(0,3):
        if A1[j] == b:
            a1[j] = True
                
    for j in range(0,3):
        if A2[j] == b:
            a2[j] = True
                
    for j in range(0,3):
        if A3[j] == b:
            a3[j] = True  





if sum(a1) == 3 or sum(a2) == 3 or sum(a3) == 3:
    Yes()
    
for n in range(0,3):
    if a1[n] == True and a2[n]== True and a3[n] == True:
        Yes()

if (a1[0] == True and a2[1] == True and a3[2] == True) or (a3[0] == True and a2[1] == True and a1[2] == True):
    Yes()
    
print("No")

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


card = [[False for _ in range(3)] for _ in range(3)]

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

bingo = False
for i in range(3):
    if (card[i][0] and card[i][1] and card[i][2]) or (card[0][i] and card[1][i] and card[2][i]):
        bingo = True
        break
if (card[0][2] and card[1][1] and card[2][0]) or (card[0][0] and card[1][1] and card[2][2]):
    bingo = True

ans = "Yes" if bingo else "No"
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()))
N = int(input())

A = list()
A.extend(A_1)
A.extend(A_2)
A.extend(A_3)

card = [0]*9

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


bingo = list()
bingo.append(card[0]+card[1]+card[2])
bingo.append(card[3]+card[4]+card[5])
bingo.append(card[6]+card[7]+card[8])

bingo.append(card[0]+card[3]+card[6])
bingo.append(card[1]+card[4]+card[7])
bingo.append(card[2]+card[5]+card[8])

bingo.append(card[0]+card[4]+card[8])
bingo.append(card[2]+card[4]+card[6])

get_bingo = 0
for i in range(8):
    if bingo[i] == 3:
        get_bingo += 1

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

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
flag = 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] = 1
        
for m in range(3):
  if A[m][0] == A[m][1] and A[m][1] == A[m][2] and A[m][0] == A[m][2]:
    flag = 1
    
for n in range(3):
  if A[0][n] == A[1][n] and A[1][n] == A[2][n] and A[0][n] == A[2][n]:
    flag = 1
    
if A[0][0] == A[1][1] and A[1][1] == A[2][2] and A[0][0] == A[2][2]:
  flag = 1
  
if A[0][2] == A[1][1] and A[1][1] == A[2][0] and A[0][2] == A[2][0]:
  flag = 1
  
if flag == 1:
  print("Yes")
else:
  print("No")

Solution (Python):
matrix = []

for i in range(0,3):
  matrix.append( list(map(int,input().split())) )
  
num = int(input())
num_list = []

for i in range(0,num):
  num_list.append(int(input()))
  
for i in range(0,3):
  for j in range(0,3):
    if matrix[i][j] in num_list :
      matrix[i][j] = 1
    elif matrix[i][j] not in num_list:
      matrix[i][j] = 0
  
sign = []
sign.append(matrix[0][0]*matrix[0][1]*matrix[0][2])
sign.append(matrix[1][0]*matrix[1][1]*matrix[1][2])
sign.append(matrix[2][0]*matrix[2][1]*matrix[2][2])
sign.append(matrix[0][0]*matrix[1][0]*matrix[2][0])
sign.append(matrix[0][1]*matrix[1][1]*matrix[2][1])
sign.append(matrix[0][2]*matrix[1][2]*matrix[2][2])
sign.append(matrix[0][0]*matrix[1][1]*matrix[2][2])
sign.append(matrix[2][0]*matrix[1][1]*matrix[2][0])

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

Solution (Python):
import numpy as np

A = np.array([list(map(int, input().split())) for _ in range(3)])
N = int(input())
B = [[False for j in range(3)] for i in range(3)]
for i in range(N):
    b = int(input())
    idx = np.where(A == b)
    
    try:
        x, y = int(idx[0]), int(idx[1])
        B[x][y] = True
    except:
        pass

flag = False

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

Solution (Python):
def check_bingo(point_list):
  BINGO_LIST = (
    ((0, 0), (0, 1), (0, 2)),
    ((1, 0), (1, 1), (1, 2)),
    ((2, 0), (2, 1), (2, 2)),
    ((0, 0), (1, 0), (2, 0)),
    ((0, 1), (1, 1), (2, 1)),
    ((0, 2), (1, 2), (2, 2)),
    ((0, 0), (1, 1), (2, 2)),
    ((0, 2), (1, 1), (2, 0))
  )
  for bingo_line in BINGO_LIST:
    bingo_flg = True
    for point in bingo_line:
      if point in point_list:
        continue
      else:
        bingo_flg = False
        break
    if bingo_flg:
      return True
  return False

def get_point(ind):
  x = ind % 3
  y = ind // 3
  
  return x, y

number_list = []
point_list = []
for i in range(3):
  number_list.extend(list(map(int, input().split())))
n = int(input())
for i in range(n):
  b = int(input())
  
  if b in number_list:
    point_list.append(get_point(number_list.index(b)))

if check_bingo(point_list):
  print("Yes")
else:
  print("No")

Solution (Python):
bingo = [[0]*3]*3

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

N = int(input())

for i in range(N):
  a = int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == a:
        bingo[j][k] = 200

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

Solution (Python):
card = []




card.extend([int(i) for i in input().split()])
card.extend([int(i) for i in input().split()])
card.extend([int(i) for i in input().split()])

N = int(input())
hits = []
for i in range(N) :
    h = int(input())
    if (h in card) :
        idx = card.index(h)
        card[idx] = "o"
    




is_bingo = False

if (card[0] == "o" and card[1] == "o" and card[2] == "o") :
    is_bingo = True
if (card[3] == "o" and card[4] == "o" and card[5] == "o") :
    is_bingo = True
if (card[6] == "o" and card[7] == "o" and card[8] == "o") :
    is_bingo = True


if (card[0] == "o" and card[3] == "o" and card[6] == "o") :
    is_bingo = True
if (card[1] == "o" and card[4] == "o" and card[7] == "o") :
    is_bingo = True
if (card[2] == "o" and card[5] == "o" and card[8] == "o") :
    is_bingo = True


if (card[0] == "o" and card[4] == "o" and card[8] == "o") :
    is_bingo = True
if (card[2] == "o" and card[4] == "o" and card[6] == "o") :
    is_bingo = True

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

Solution (Python):
L1=list(map(int,input().split()))
L2=list(map(int,input().split()))
L3=list(map(int,input().split()))
L=L1+L2+L3
ansL=[0]*9

n=int(input())

for i in range(n):
    p=int(input())
    if p in L:
        tmp=L.index(p)
        ansL[tmp]=1


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

Solution (Python):
combinations = [(1, 2, 3), (4, 5, 6), (7, 8, 9),
                (1, 4, 7), (2, 5, 8), (3, 6, 9),
                (1, 5, 9), (5, 5, 7)
                ]

def main():
    a9 = []
    for _ in range(3):
        temp = list(map(int, input().split()))
        a9 += temp

    n = int(input())
    bbb = []
    for _ in range(n):
        b = int(input())
        bbb.append(b)
        if b in a9:
            idx = a9.index(b)
            a9[idx] = 0

    ans = 'No'
    for ccc in combinations:
        bingo_flag = True
        for c in ccc:
            idx = c - 1
            if a9[idx] == 0:
                continue
            else:
                bingo_flag = False
        if bingo_flag:
            ans = 'Yes'
            break
    print(ans)


if __name__ == '__main__':
    main()

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

tf = [[False for _ in range(3)] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            tf[i][j] = True
ans = "No"
for i in range(3):
    total = 0
    for j in range(3):
        if tf[i][j]:
            total += 1
    if total == 3:
        ans = "Yes"
for i in range(3):
    total = 0
    for j in range(3):
        if tf[j][i]:
            total += 1
    if total == 3:
        ans = "Yes"
if tf[0][0] == tf[1][1] == tf[2][2] == True:
    ans = "Yes"
if tf[2][0] == tf[1][1] == tf[0][2] == True:
    ans = "Yes"
print(ans)

Solution (Python):
A1 = input().split()
A1 = [int(l) for l in A1]
A2 = input().split()
A2 = [int(l) for l in A2]
A3 = input().split()
A3 = [int(l) for l in A3]

N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        if A1[j] == b:
            A1[j] = 0
    for j in range(3):
        if A2[j] == b:
            A2[j] = 0
    for j in range(3):
        if A3[j] == b:
            A3[j] = 0
T = "No"
if A1[0] == 0 and A1[1] == 0 and A1[2] == 0:
    T = "Yes"
elif A2[0] == 0 and A2[1] == 0 and A2[2] == 0:
    T = "Yes"
elif A3[0] == 0 and A3[1] == 0 and A3[2] == 0:
    T = "Yes"
elif A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
    T = "Yes"
elif A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
    T = "Yes"
for i in range(3):
    if A1[i] == 0 and A2[i] == 0 and A3[i] == 0:
        T = "Yes"
print(T)

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

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

if sum(c[0])==3 or sum(c[1])==3 or sum(c[2])==3:
    print('Yes')

elif sum(list(map(lambda x: x[0], c)))==3 or sum(list(map(lambda x: x[1], c)))==3 or sum(list(map(lambda x: x[2], c)))==3:
    print('Yes')

elif (c[0][0]==1 and c[1][1]==1 and c[2][2]==1) or (c[0][2]==1 and c[1][1]==1 and c[2][0]==1):
    print('Yes')

else:
    print('No')

Solution (Python):
A = [[0] * 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())
S = []
for _ in range(n):
  S.append(int(input()))
  
for i in range(3):
  for j in range(3):
    if A[i][j] in S:
      A[i][j] = 0
  
ans = False
for i in range(3):
  if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
    ans = True
  if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
    ans = True
    
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
  ans = True
if A[0][2] == 0 and A[1][1] == 0 and A[0][2] == 0:
  ans = True
  
if ans:
  print('Yes')
else:
  print('No')

Solution (Python):
a11,a12,a13=map(int, input().split())
a21,a22,a23=map(int, input().split())
a31,a32,a33=map(int, input().split())
a=[]
for i in [a11,a12,a13,a21,a22,a23,a31,a32,a33]:
    a.append(i)
    
ans="No"
b=[]
n=int(input())

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

for i in range(3):
    if a[i]==a[i+3] and a[i+3] ==a[i+6]:
        ans="Yes"

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

if a[0]==a[4] and a[4]==a[8]:
    ans="Yes"
elif a[2]==a[4] and a[4]==a[6]:
    ans="Yes"

print(ans)

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

a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))

n = int(input())
for i in range(n):
    b = int(input())

    if b in a1:
        a1[a1.index(b)] = 0
    if b in a2:
        a2[a2.index(b)] = 0
    if b in a3:
        a3[a3.index(b)] = 0


if (a1[0] == a1[1] == a1[2] == 0) or (a2[0] == a2[1] == a2[2] == 0) or (a3[0] == a3[1] == a3[2] == 0) \
    or (a1[0] == a2[0] == a3[0] == 0) or (a1[1] == a2[1] == a3[1] == 0) or (a1[2] == a2[2] == a3[2] == 0) \
    or (a1[0] == a2[1] == a3[2] == 0) or (a1[2] == a2[1] == a3[0] == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
for i in range(3):
    a += list((map(int, input().split())))
card = [False] * 9
n = int(input())

for i in range(n):
    
    try:
        card[a.index(int(input()))] = True
    except ValueError:
        continue
if (sum(card[:3]) == 3 or sum(card[3:6]) == 3 or sum(card[6:]) == 3
        or sum(card[::3]) == 3 or sum(card[1::3]) == 3 or sum(card[2::3]) == 3
        or sum(card[::4]) == 3 or sum(card[2:7:2]) == 3):
    print('Yes')
else:
    print('No')

Solution (Python):
from sys import stdin
import numpy as np
A1 = [int(x) for x in stdin.readline().rstrip().split()]
A2 = [int(x) for x in stdin.readline().rstrip().split()]
A3 = [int(x) for x in stdin.readline().rstrip().split()]
A = [A1,A2,A3]
N = int(stdin.readline().rstrip())
B = []
for i in range(N):
    b = int(stdin.readline().rstrip())
    B.append(b)
    
ans = [[False,False,False] for i in range(3)]

for x,j in enumerate(A):
    for y,k in enumerate(j):
        if k in B:
            ans[x][y] = True

f = False
if ans[0][0] and ans[1][1] and ans[2][2]:
    f = True

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

ans = np.array(ans)
for m in range(3):
    if all(list(ans[m])):
        f = True
        
    if all (list(ans[:,m])):
        f = True
        
if f:
    print("Yes")
else:
    print("No")

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
data = [0] * 9
for i in b:
    if i in a1:
        data[a1.index(i)] = 1
    if i in a2:
        data[a2.index(i)+3] = 1
    if i in a3:
        data[a3.index(i)+6] = 1

if data[0:3] == [1, 1, 1]:
    print('Yes')
elif data[3:6] == [1, 1, 1]:
    print('Yes')
elif data[6:9] == [1, 1, 1]:
    print('Yes')
elif data[0::3] == [1, 1, 1]:
    print('Yes')
elif data[1::3] == [1, 1, 1]:
    print('Yes')
elif data[2::3] == [1, 1, 1]:
    print('Yes')
elif [data[0], data[4], data[8]] == [1, 1, 1]:
    print('Yes')
elif [data[2], data[4], data[6]] == [1, 1, 1]:
    print('Yes')
else:
    print('No')

Solution (Python):
card=[list(map(int,input().split())) for i in range(3)]
n=int(input())
at=[[False for i in range(3)] for j in range(3)]
for i in range(n):
    num=int(input())
    for j in range(3):
        for h in range(3):
            if num==card[j][h]:at[j][h]=True
for i in range(3):
    if False not in at[i]:print('Yes');exit()
for j in range(3):
    if False not in (at[0][j],at[1][j],at[2][j]):print('Yes');exit()
if False not in (at[0][0],at[1][1],at[2][2]) or False not in (at[0][2],at[1][1],at[2][0]):print("Yes");exit()
print("No")

Solution (Python):
a11,a12,a13=map(int,input().split())
a21,a22,a23=map(int,input().split())
a31,a32,a33=map(int,input().split())
A=[a11,a12,a13,a21,a22,a23,a31,a32,a33]
n=int(input())
b=[]
for i in range(n):
  b.append(int(input()))
for i in range(n):
  for j in range(9):
    if b[i]==A[j]:
      A[j]=0
if A[0]==A[1] and A[1]==A[2] or A[3]==A[4] and A[3]==A[5] or A[6]==A[7] and A[6]==A[8] or A[0]==A[3] and A[0]==A[6] or A[1]==A[4] and A[1]==A[7] or A[2]==A[5] and A[2]==A[8] or A[0]==A[4] and A[0]==A[8] or A[2]==A[4] and A[2]==A[6]:
  print("Yes")
else:
  print("No")

Solution (Python):

field = []
for i in range(3):
    field += list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
hit = [0 for i in range(9)]
for i in b:
    if i in field:
        
        hit[field.index(i)] += 1

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

patterns = (
    [[a[i][i] for i in range(3)], [a[2 - i][i] for i in range(3)]]
    + [[a[0][i], a[1][i], a[2][i]] for i in range(3)]
    + [[a[i][0], a[i][1], a[i][2]] for i in range(3)]
)

answer = "No"
for a0, a1, a2 in patterns:
    if a0 in b and a1 in b and a2 in b:
        answer = "Yes"
        break

print(answer)

Solution (Python):
s = list(map(int, input().split()))
bingo=[]
bingo+=s
s = list(map(int, input().split()))
bingo += s
s = list(map(int, input().split()))
bingo += s
s = list(map(int, input().split()))
n=s[0]
for i in range(n):
    s = list(map(int, input().split()))
    bingo=[ 0 if j==s[0] else j for j in bingo]
if bingo[0]==bingo[1]==bingo[2]:print('Yes')
elif bingo[0] == bingo[1] == bingo[2]:print('Yes')
elif bingo[3] == bingo[4] == bingo[5]:print('Yes')
elif bingo[6] == bingo[7] == bingo[8]:print('Yes')
elif bingo[0] == bingo[3] == bingo[6]:print('Yes')
elif bingo[1] == bingo[4] == bingo[7]:print('Yes')
elif bingo[2] == bingo[5] == bingo[8]:print('Yes')
elif bingo[0] == bingo[4] == bingo[8]:print('Yes')
elif bingo[2] == bingo[4] == bingo[6]:print('Yes')
else:
    print('No')