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
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

card = [[0] * 3 for i in range(3)]
bingo = [[0] * 3 for i in range(3)]
flag = 0
for i in range(3):
    card[i][0],  card[i][1], card[i][2] = splitintinput()

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

for i in range(3):
    for j in range(3):
        if bingo[i][j] == 0:
            break
    else:
        flag = 1

for i in range(3):
    for j in range(3):
        if bingo[j][i] == 0:
            break
    else:
        flag = 1

for i in range(3):
    if bingo[i][i] == 0:
        break
else:
    flag = 1

for i in range(3):
    if bingo[i][2-i] == 0:
        break
else:
    flag = 1

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

Solution (Python):
def check(bingo):
    for j in range(3):
        if bingo[j][0] == bingo[j][1] == bingo[j][2] == 0:
            return True
        elif bingo[0][j] == bingo[1][j] == bingo[2][j] == 0:
            return True
        else:
            pass
    
    if bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:
        return True
    elif bingo[2][0] == bingo[1][1] == bingo [0][2] == 0:
        return True
    else:
        return False
    
    

bingo = []
for _ in range(3):
    bingo.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 bingo[i][j] == b:
                bingo[i][j] = 0



if check(bingo) == True:
    print("Yes")
else:
    print("No")

Solution (Python):
arr = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for k in range(3):
        for l in range(3):
            if arr[k][l] == b:
                arr[k][l] = 0
flg = False
for i in arr:
    if sum(i) == 0:
        flg = True
for i in range(3):
    if arr[0][i] + arr[1][i] + arr[2][i] == 0:
        flg = True
if arr[0][0] + arr[1][1] + arr[2][2] == 0:
    flg = True
if arr[0][2] + arr[1][1] + arr[2][0] == 0:
    flg = True
if flg:
    print('Yes')
else:
    print('No')

Solution (Python):
def resolve():
    a = []
    for i in range(3):
        a.append([int(x) for x in input().split(" ")])
    
    n = int(input())
    lst = []
    for i in range(n):
        lst += [int(input())]

    flag = False
    for i in range(3):
        if row(i,lst,a):
            print("Yes")
            return
        if col(i,lst,a):
            print("Yes")
            return
    if diag1(lst,a) or diag2(lst,a):
        print("Yes")
        return
    print("No")
        
        

def row(i,lst,a):
    '''print("aは", file=sys.stderr)
    print(a, file=sys.stderr)
    print("lstは", file=sys.stderr)
    print(lst, file=sys.stderr)'''
    for j in range(3):
        if not a[i][j] in lst:
            return False
    return True

def col(j,lst,a):
    for i in range(3):
        if not a[i][j] in lst:
            return False
    return True

def diag1(lst,a):
    for i in range(3):
        if not a[i][i] in lst:
            return False
    return True

def diag2(lst,a):
    for i in range(3):
        if not a[2-i][i] in lst:
            return False
    return True

resolve()

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

N = int(input())
for i in range(N):
  num = int(input())
  for j in range(3):
    for k in range(3):
      if l_map[j][k] == num:
        l_bingo[j][k] = 1

ans = "No"
for i in range(3):
  if l_bingo[i][0] == l_bingo[i][1] == l_bingo[i][2] == 1:
    ans = "Yes"
    break
  elif l_bingo[0][i] == l_bingo[1][i] == l_bingo[2][i] == 1:
    ans = "Yes"
    break

if l_bingo[0][0] == l_bingo[1][1] == l_bingo[2][2] == 1:
  ans = "Yes"
elif l_bingo[0][2] == l_bingo[1][1] == l_bingo[2][0] == 1:
  ans = "Yes"

print(ans)

Solution (Python):
import sys

bingo=[]

for _ in range(3):
  bingo.append(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]=0



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

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

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

print('No')

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

bingo = [False for i in range(9)]

for i in range(N):
    if B[i] in A:
        a_index = A.index(B[i])
        bingo[a_index] = True

ans = False



for i in range(3):
    if all([bingo[i*3], bingo[i*3 + 1], bingo[i*3 + 2]]):
        ans = True


for i in range(3):
    if all([bingo[i], bingo[3 + i], bingo[6 + i]]):
        ans = True

if all([bingo[0], bingo[4], bingo[8]]) or all([bingo[2], bingo[4], bingo[6]]):
    ans = True
print("Yes") if ans else print("No")

Solution (Python):
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq


def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()

def main():
    A = [ria() for _ in range(3)]
    N = ri()
    B = [ri() for _ in range(N)]
    d = set()
    for n in B: d.add(n)

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

    if A[0][0] in d and A[1][1] in d and A[2][2] in d:    
            print("Yes")
            sys.exit(0)
    if A[0][2] in d and A[1][1] in d and A[2][0] in d:    
            print("Yes")
            sys.exit(0)

    print("No")

if __name__ == "__main__":
    main()

Solution (Python):
t=[]
for i in range(3):
    t.append([int(i) for i in input().split()])
n = int(input())
lst = []
for i in range(n):lst+=[int(input())]
def ligne(i):
    for j in range(3):
        if not t[i][j] in lst:
            return False
    return True
def col(j):
    for i in range(3):
        if not t[i][j] in lst:
            return False
    return True
def diag1():
    for i in range(3):
        if not t[i][i] in lst:
            return False
    return True
def diag2():
    for i in range(3):
        if not t[2-i][i] in lst:
            return False
    return True
ans = False
for i in range(3):
    ans = ans or ligne(i)
    ans = ans or col(i)
ans  = ans or diag1() or diag2()
if ans :
    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()))
A1s = [0, 0, 0]
A2s = [0, 0, 0]
A3s = [0, 0, 0]
N = int(input())
for i in range(N):
  b = int(input())
  if b in A1:
    A1s[A1.index(b)]=1
  if b in A2:
    A2s[A2.index(b)]=1
  if b in A3:
    A3s[A3.index(b)]=1
f = False
if sum(A1s)==3 or sum(A2s)==3 or sum(A3s)==3:
  f = True
if A1s[0]+A2s[0]+A3s[0]==3 or A1s[1]+A2s[1]+A3s[1]==3 or A1s[2]+A2s[2]+A3s[2]==3:
  f = True
if A1s[0]+A2s[1]+A3s[2]==3 or A1s[2]+A2s[1]+A3s[0]==3:
  f = True
if f:
  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)]
ans = False

bingolist = []
for i in range(3):
  bingolist.append([A[i][0], A[i][1], A[i][2]])
  bingolist.append([A[0][i], A[1][i], A[2][i]])

bingolist.append([A[0][0], A[1][1], A[2][2]])
bingolist.append([A[2][0], A[1][1], A[0][2]])

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

Solution (Python):
list1 = input().split()
list2 = input().split()
list3 = input().split()
n = int(input())

for _ in range(n):
    value = input()
    list1 = ['' if value == s else s for s in list1]
    list2 = ['' if value == s else s for s in list2]
    list3 = ['' if value == s else s for s in list3]
ans = 'No'
if all(s == '' for s in list1) or all(s == '' for s in list2) or all(s == '' for s in list3):
    ans = 'Yes'
for x, y, z in zip(list1, list2, list3):
    if all(s == '' for s in [x, y, z]):
        ans = 'Yes'
if list1[0] == '' and list2[1] == '' and list3[2] == '' or list1[2] == '' and list2[1] == '' and list3[0] == '':
    ans = 'Yes'
print(ans)

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

c = [[False]*3 for i in range(3)]

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

flag = False

for i in range(3):
    if all(c[i]) == True:
        flag = True
    elif all([x[i] for x in c]) == True:
        flag = True

if c[0][0] == c[1][1] == c[2][2] == True:
    flag = True
if c[0][2] == c[1][1] == c[2][0] == True:
    flag = True

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

Solution (Python):
import numpy as np

A = []
a = [int(x) for x in input().split()]
A.append(a)
A_len = len(a)
naname1 = 0
naname2 = 0

for s in range(A_len - 1):
    A.append([int(x) for x in input().split()])

A = np.array(A)

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




for i in range(N):
    B.append(int(input()))

for i in range(N):
    A = np.where(A==B[i], 0, A)


for i in range(A_len):
    if (A[i].sum() == 0) or (A[:,i].sum() == 0):
        print('Yes')
        exit()

for i in range(A_len):
    naname1 += A[i,i]
    naname2 += A[i,A_len-i-1]


if naname1==0 or naname2==0:
    print('Yes')
else:
    print('No')

Solution (Python):
def contains(lista, n):
    for i in range(3):
        for j in range(3):
            if lista[i][j] == n:
                lista[i][j] = "x"

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

    
lista = []
for i in range(3):
    x = list(map(float,input().split()))
    lista.append(x)
for i in range(int(input())):
    b = float(input())
    contains(lista,b)
print(busca(lista))

Solution (Python):
import math

a1 = list(map(int, input().rstrip().split()))
a2 = list(map(int, input().rstrip().split()))
a3 = list(map(int, input().rstrip().split()))
a = [a1,a2,a3]

m = [[0,0,0],[0,0,0],[0,0,0]]

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

if m[0].count(1) == 3 :
    print('Yes')
elif m[1].count(1) == 3 :
    print('Yes')
elif m[2].count(1) == 3 :
    print('Yes')
elif m[0][0] == 1 and m[1][0] == 1 and m[2][0] ==1 :
    print('Yes')
elif m[0][1] == 1 and m[1][1] == 1 and m[2][1] ==1 :
    print('Yes')
elif m[0][2] == 1 and m[1][2] == 1 and m[2][2] ==1 :
    print('Yes')
elif m[0][0] == 1 and m[1][1] == 1 and m[2][2] ==1 :
    print('Yes')
elif m[0][2] == 1 and m[1][1] == 1 and m[2][0] ==1 :
    print('Yes')
else :
    print('No')

Solution (Python):
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []
 
for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
          total.append(k * 3 + j)
          
if 0 in total and 1 in total and 2 in total: 
  print("Yes")
elif 3 in total and 4 in total and 5 in total: 
  print("Yes")
elif 6 in total and 7 in total and 8 in total: 
  print("Yes")
elif 0 in total and 3 in total and 6 in total: 
  print("Yes")
elif 1 in total and 4 in total and 7 in total: 
  print("Yes")
elif 2 in total and 5 in total and 8 in total: 
  print("Yes")
elif 0 in total and 4 in total and 8 in total: 
  print("Yes")
elif 2 in total and 4 in total and 6 in total: 
  print("Yes")
else:
  print("No")

Solution (Python):

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

mylist=[a,b,c,d,e,f,g,h,i]
num = int(input())

for i in range(num):
    x = int(input())
    k=0
    for j in mylist:
      if j==x:
        mylist[k]=0
      k+=1

x=0
def bingo(a,b,c):
  global x
  if mylist[a]==0 and mylist[b]==0 and mylist[c]==0:
    x=1
      
      
bingo(0,1,2)
bingo(3,4,5)
bingo(6,7,8)
bingo(0,3,6)
bingo(1,4,7)
bingo(2,5,8)
bingo(0,4,8)
bingo(2,4,6)


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

Solution (Python):
class BingoCard():
  A1 = []
  A2 = []
  A3 = []
  
  def __init__(self):
    self.A1 = [int(x) for x in input().split(' ')]
    self.A2 = [int(x) for x in input().split(' ')]
    self.A3 = [int(x) for x in input().split(' ')]

  def BingoProgress(self):
    N  = int(input())
    for i in range(N):
      B = int(input())
      if B in self.A1:
        self.A1[self.A1.index(B)] = 0
      if B in self.A2:
        self.A2[self.A2.index(B)] = 0
      if B in self.A3:
        self.A3[self.A3.index(B)] = 0

  def BingoJudge(self):
    flg = 0
    
    if sum(self.A1) == 0 or sum(self.A2) == 0 or sum(self.A3) == 0:
      flg = 1
    
    
    if flg == 0:
      for i in range(3):
        if (self.A1[i] + self.A2[i] + self.A3[i]) == 0:
          flg = 1
          break
          
    
    if flg == 0:
      if (self.A1[0] + self.A2[1] + self.A3[2]) == 0 or (self.A1[2] + self.A2[1] + self.A3[0]) == 0:
        flg = 1

    
    print('Yes' if flg == 1 else 'No')
    
def main():
  Bingo = BingoCard()
  Bingo.BingoProgress()
  Bingo.BingoJudge()

if __name__=='__main__':
  main()

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

BINGO = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]

for bingo in BINGO:
	c = 0
	for b in B:
		if b in A:
			idx = A.index(b)
			c += bingo[idx]
	if c >= 3:
		print('Yes')
		break
else:
	print('No')

Solution (Python):
A_one = [int(i) for i in input().split()]
A_two = [int(i) for i in input().split()]
A_three = [int(i) for i in input().split()]

X = [0, 0, 0]
Y = [0, 0, 0]
Z = [0, 0, 0]
res = False
N = int(input())
for i in range(N):
    j = int(input())
    try:
        a = A_one.index(j)
    except:
        pass
    else:
        X[a] = 1
    
    try:
        a = A_two.index(j)
    except:
        pass
    else:
        Y[a] = 1

    try:
        a = A_three.index(j)
    except:
        pass
    else:
        Z[a] = 1

if sum(X) == 3: 
    res = True

if sum(Y) == 3: 
    res = True

if sum(Z) == 3: 
    res = True

if X[0] + Y[1] + Z[2] == 3:
    res = True

if X[2] + Y[1] + Z[0] == 3:
    res = True

if X[0] + Y[0] + Z[0] == 3:
    res = True

if X[1] + Y[1] + Z[1] == 3:
    res = True

if X[2] + Y[2] + Z[2] == 3:
    res = True

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

Solution (Python):
cards = []

cards.append(list(map(int, input().split())))
cards.append(list(map(int, input().split())))
cards.append(list(map(int, input().split())))

N = int(input())
for _ in range(N):
    a = int(input())
    for row in cards:
        if a in row:
            row[row.index(a)] = 0

for row in cards:
    if sum(row) == 0:
        print('Yes')
        break
else:
    for row in zip(*cards):
        if sum(row) == 0:
            print('Yes')
            break
    else:
        if sum([cards[0][0], cards[1][1], cards[2][2]]) == 0:
            print('Yes')
        elif sum([cards[0][2], cards[1][1], cards[2][0]]) == 0:
            print('Yes')
        else:
            print('No')

Solution (Python):
A = []
A.extend(list(map(int, input().split())))
A.extend(list(map(int, input().split())))
A.extend(list(map(int, input().split())))
hits = [[0] * 3 for _ in range(3)]
N = int(input())
for _ in range(N):
    n = int(input())
    if n not in A:
        continue
    i = A.index(n)
    row = i // 3
    col = i % 3
    hits[row][col] = 1

for i in range(3):
    if sum(hits[j][i] for j in range(3)) == 3:
        print('Yes')
        break
    if sum(hits[i][j] for j in range(3)) == 3:
        print('Yes')
        break
else:
    if sum(hits[i][i] for i in range(3)) == 3 or sum(hits[i][2 - i] for i in range(3)) == 3:
        print('Yes')
    else:
        print('No')

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

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

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

for i in range(3):
    ok = True
    for j in range(3):
        if a[i][j] != -1:
            ok = False

    if ok:
        print("Yes")
        exit(0)

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

if a[0][0] == -1 and a[1][1] == -1 and a[2][2]:
    print("Yes")
    exit(0)
if a[2][0] == -1 and a[1][1] == -1 and a[0][2]:
    print("Yes")
    exit(0)

print("No")

Solution (Python):
l=[list(map(int,input().split())) for i in range(3)]
l=sum(l,[])
n=int(input())
li=set([int(input()) for ini in range(n)])
d=[0 for i in range(9)]
for g in range(9):
  if l[g] in li:d[g]=1

for a,s,x in [(0,1,2),(3,4,5),(6,7,8),(0,4,8),(2,4,6),(0,3,6),(1,4,7),(2,5,8)]:
  if d[a]==d[x]==d[s]==1:
    print("Yes");exit()
print("No")

Solution (Python):
r1=list(map(int,input().split()))
r2=list(map(int,input().split()))
r3=list(map(int,input().split()))
N=int(input())
a=[]
for i in range(N):
    a.append(int(input()))


bing=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(0,3):
    if r1[i] in a:
        bing[0][i]=1
    if r2[i] in a:
        bing[1][i]=1
    if r3[i] in a:
        bing[2][i]=1


ans=0

if sum(bing[0])==3 or sum(bing[1])==3 or sum(bing[2])==3:
    ans += 1

if bing[0][0]+bing[1][0]+bing[2][0]==3 or bing[0][1]+bing[1][1]+bing[2][1]==3 or bing[0][2]+bing[1][2]+bing[2][2]==3:
    ans += 1

if bing[0][0]+bing[1][1]+bing[2][2]==3 or bing[2][0]+bing[1][1]+bing[0][2]==3:
    ans += 1

if ans >=1:
    print('Yes')
else:
    print('No')

Solution (Python):
from sys import exit

d = dict()

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

N = int(input())
d_inv = {v: k for k, v in d.items()}
for _ in range(N):
    try:
        d[d_inv[int(input())]] = 0
    except KeyError:
        pass
for i in range(3):
    if d[(i, 0)] == d[(i, 1)] == d[(i, 2)] == 0 \
            or d[(0, i)] == d[(1, i)] == d[(2, i)] == 0:
        print('Yes')
        exit()
if d[(0, 0)] == d[(1, 1)] == d[(2, 2)] == 0 \
        or d[(0, 2)] == d[(1, 1)] == d[(2, 0)] == 0:
    print('Yes')
    exit()
print('No')

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

n = int(input())

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


for i in range(3):
    sum = 0
    for j in range(3):
        sum += lst[i][j]
    if sum == 3:
        print("Yes")
        exit(0)  


for i in range(3):
    sum = 0
    for j in range(3):
        sum += lst[j][i]
    if sum == 3:
        print("Yes")
        exit(0)  


sum = 0
for i in range(3):
    sum += lst[i][i]
if sum == 3:
    print("Yes")
    exit(0)  


sum = 0
for i in range(3):
    sum += lst[i][2-i]
if sum == 3:
    print("Yes")
    exit(0)

print("No")

Solution (Python):
a = [[int(x) for x in input().split()] for _ in range(3)]
n = int(input())
b = [[0, 0, 0] for _ in range(3)]
def isExist(num):
    global a
    for i in range(3):
        for j in range(3):
            if a[i][j] == num:
                return i, j
    return -1, -1

def judge(b):
    for i in range(3):
        for j in range(3):
            if b[i][j] != 1:
                break
        else:
            return 1
            break
        for j in range(3):
            if b[j][i] != 1:
                break
        else:
            return 1
            break
    for i in range(3):
        if b[i][i] != 1:
            break
    else:
        return 1
    for i in range(3):
        if b[i][2-i] != 1:
            break
    else:
        return 1
    return 0

for _ in range(n):
    num = int(input())
    i, j = isExist(num)
    if i == -1 and j == -1: continue
    b[i][j] = 1

flag = judge(b)
print('Yes' if flag else 'No')

Solution (Python):
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)]
ans = "No"

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

if bingo[0][0] == bingo[1][1] == bingo[2][2] ==1 or bingo[0][2] == bingo[1][1] == bingo[2][0] == 1:
    ans = "Yes"
else:
    for k in range(3):
        if 0 not in bingo[k]:
            ans = "Yes"
        elif bingo[0][k] == bingo[1][k] == bingo[2][k] == 1:
            ans = "Yes"

print(ans)

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 = [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 mark[i][0] and mark[i][1] and mark[i][2]:
        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):
import numpy as np
A=[]
for i in range(3):
    l=[int(a) for a in input().split()]
    A.extend(l)
for i in range(int(input())):
    b=int(input())
    if b in A:
        A[A.index(b)]=0
na=np.array(A)
ra=na.reshape(3,3)
flg=False
fa=np.all(ra==0,axis=0)
fb=np.all(ra==0,axis=1)
if any(fa) or any(fb):
    flg=True
flg2=flg3=True    
for i in range(3):
    if ra[i][i]!=0:
        flg2=False
    if ra[i][-1-i]!=0:
        flg3=False
if flg or flg2 or flg3:
    print("Yes")
else:
    print("No")

Solution (Python):
A1 = [0] * 3
A2 = [0] * 3
A3 = [0] * 3
for i in range(3):
    A1[i], A2[i], A3[i] = map(int, input().split())
A = A1 + A2 + A3

N = int(input())
l_index = []
for i in range(N):
    b = int(input())
    if b in A:
        l_index.append(A.index(b))
    
s0 = set(l_index)

if {0,1,2}.issubset(s0):
    print('Yes')
elif {3,4,5}.issubset(s0):
    print('Yes')
elif {6,7,8}.issubset(s0):
    print('Yes')
elif {0,3,6}.issubset(s0):
    print('Yes')
elif {1,4,7}.issubset(s0):
    print('Yes')
elif {2,5,8}.issubset(s0):
    print('Yes')
elif {0,4,8}.issubset(s0):
    print('Yes')
elif {2,4,6}.issubset(s0):
    print('Yes')
else:
    print('No')

Solution (Python):
as1 = [int(elem) for elem in input().split()]
as2 = [int(elem) for elem in input().split()]
as3 = [int(elem) for elem in input().split()]
n = int(input())
for i in range(n):
  b = int(input())
  if b in as1:
    as1[as1.index(b)] = -1
  elif b in as2:
    as2[as2.index(b)] = -1
  elif b in as3:
    as3[as3.index(b)] = -1

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

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

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

N = int(input())
judge = [0 for i in range(9)]
ans = 'No'

for i in range(N):
    b = int(input())
    
    for row in range(3):
        if (b in A[row]):
            index_r = A[row].index(b)
            index = 3 * row + index_r
            judge[index] += 1

for i in range(3):
    summ1 = sum(judge[i::3])
    summ2 = sum(judge[3 * i : 3 * i + 3])
    
    if (summ1 == 3 or summ2 == 3):
        ans = 'Yes'

summ3 = sum(judge[0::4])
summ4 = sum(judge[2:7:2])

if (summ3 == 3 or summ4 == 3):
    ans = 'Yes'

print(ans)

Solution (Python):
def cross1(arr,s):
    for i in range(3):
        if arr[i][i] not in s:
            return False
    return True
def cross2(arr,s):
    for i in range(3):
        if arr[i][2-i] not in s:
            return False
    return True
def calc(arr, s):
    for r in range(3):
        pos = True
        for c in range(3):
            if arr[r][c] not in s:
                pos = False
                break
        if pos:
            return True
    
    for c in range(3):
        pos = True
        for r in range(3):
            if arr[r][c] not in s:
                pos = False
                break
        if pos:
            return True
    if cross1(arr,s) or cross2(arr,s):
        return True
    return False
        


if __name__ == "__main__":
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    
    s = set()
    n = int(input())
    for _ in range(n):
        s.add(int(input()))

    print("Yes" if calc(arr, s) else "No")

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


for i in range(3):
    res = 0
    for j in range(3):
        if B[i][j] == 1:
            res += 1
    if res == 3:
        print('Yes')
        exit()

for j in range(3):
    res = 0
    for i in range(3):
        if B[i][j] == 1:
            res += 1
    if res == 3:
        print('Yes')
        exit()

res = 0
for k in range(3):
    if B[k][k] == 1:
        res += 1
if res == 3:
    print('Yes')
    exit()

res = 0
if B[0][2] + B[1][1] + B[2][0] == 3:
    print('Yes')
    exit()

print('No')

Solution (Python):
grid = []
F = dict()
for i in range(3):
    row = [int(s) for s in input().split()]
    for j in range(3):
        F[row[j]] = [i, j]
    grid.append(row)
N = int(input())
for i in range(N):
    num = int(input())
    if num in F:
        grid[F[num][0]][F[num][1]] = -1

found = False
for i in range(3):
    if grid[i][0] == -1 and grid[i][1] == -1 and grid[i][2] == -1:
        print("Yes")
        found = True
        break
if not found:
    for j in range(3):
        if grid[0][j] == -1 and grid[1][j] == -1 and grid[2][j] == -1:
            print("Yes")
            found = True
            break
if not found:
    if grid[0][0] == -1 and grid[1][1] == -1 and grid[2][2] == -1:
        print("Yes")
        found = True
if not found:
    if grid[0][2] == -1 and grid[1][1] == -1 and grid[2][0] == -1:
        print("Yes")
        found = True
if not found:
    print("No")

Solution (Python):
li_1 = list(map(int, input().split()))
li_2 = list(map(int, input().split()))
li_3 = list(map(int, input().split()))
n = int(input())
b = [int(input()) for i in range(n)]

index = 0
ans = 'No'

for i in b:
    for j in li_1:
        if i == j:
            li_1[index] = 0
        index += 1
    index = 0
for i in b:
    for j in li_2:
        if i == j:
            li_2[index] = 0
        index += 1
    index = 0
for i in b:
    for j in li_3:
        if i == j:
            li_3[index] = 0
        index += 1
    index = 0

if li_1[0] == 0 and li_1[1] == 0 and li_1[2] == 0:
    ans = 'Yes'
if li_2[0] == 0 and li_2[1] == 0 and li_2[2] == 0:
    ans = 'Yes'
if li_3[0] == 0 and li_3[1] == 0 and li_3[2] == 0:
    ans = 'Yes'

if li_1[0] == 0 and li_2[0] == 0 and li_3[0] == 0:
    ans = 'Yes'
if li_1[1] == 0 and li_2[1] == 0 and li_3[1] == 0:
    ans = 'Yes'
if li_1[2] == 0 and li_2[2] == 0 and li_3[2] == 0:
    ans = 'Yes'

if li_1[0] == 0 and li_2[1] == 0 and li_3[2] == 0:
    ans = 'Yes'
if li_1[2] == 0 and li_2[1] == 0 and li_3[0] == 0:
    ans = 'Yes'

print(ans)