Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

Solution (Python):
import sys
import math
sys.setrecursionlimit(int(1e6))

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

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

c = [[0]*3 for i in range(3)]
for bn in b:
    for m in range(3*3):
        i = m % 3
        j = m // 3
        if (A[i][j] == bn):
            c[i][j] = 1
            break

ans = 'No'
for i in range(3):
    if sum(c[i]) == 3:
        ans = 'Yes'
        break
    if sum([c[0][i], c[1][i], c[2][i]]) == 3:
        ans = 'Yes'
        break
else:
    if sum([c[0][0], c[1][1], c[2][2]]) == 3:
        ans = 'Yes'
    elif sum([c[2][0], c[1][1], c[0][2]]) == 3:
        ans = 'Yes'

print(ans)

Solution (Python):

import sys
a_list = []
a = []
c = [False for i in range(9)]
for i in range(3):
    a_list = list(map(int, input().split()))
    for num in a_list:
        a.append(num)
n = int(input())
for i in range(n):
    num = int(input())
    if num in a:
        index = a.index(num)
        c[index] = True

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

Solution (Python):
mt = [[0, 0, 0] for i in range(3)]
bf = [[0, 0, 0] for i in range(3)]
res = 'No'
for i in range(3):
    mt[i] = list(map(int, input().split(' ')))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
for i in b:
    for j in range(3):
        if i in mt[j]:
            bcol = mt[j].index(i)
            bf[j][bcol] = 1
            if sum(bf[j]) == 3 or bf[0][bcol] == 1 and bf[1][bcol] == 1 and bf[2][bcol] == 1:
                res = 'Yes'
            if bf[0][0] == 1 and bf[1][1] == 1 and bf[2][2] == 1 or bf[0][2] == 1 and bf[1][1] == 1 and bf[0][2] == 1:
                res = 'Yes'
print(res)

Solution (Python):
listA = []
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;

listB = []
listB = listA[:3]
n = listA[3][0]

listC = []
for i in range(0,n):
	listC.append(listA[i+4][0])


for i in range(0,n):
  for j in range(0,3):
    for k in range(0,3):
      if listB[j][k]==listC[i]:
        listB[j][k] = -1

kekka = 0
for i in range(0,3):
  if listB[i][0]==-1 and listB[i][1]==-1 and listB[i][2]==-1:
    kekka = 1
for i in range(0,3):
  if listB[0][i]==-1 and listB[1][i]==-1 and listB[2][i]==-1:
    kekka = 1
if listB[0][0]==-1 and listB[1][1]==-1 and listB[2][2]==-1:
  kekka = 1
if listB[0][2]==-1 and listB[1][1]==-1 and listB[2][0]==-1:
  kekka = 1

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

Solution (Python):
import numpy as np

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

A = [A1,A2,A3]
a = np.array(A)

N = int(input())
for i in range(N):
    tmp = int(input())
    a = np.where(a==tmp, 0,a)

ans = 'Yes' if ((a[0][0]==0)and(a[0][1]==0)and(a[0][2]==0)) or ((a[1][0]==0)and(a[1][1]==0)and(a[1][2]==0)) or ((a[2][0]==0)and(a[2][1]==0)and(a[2][2]==0)) or ((a[0][0]==0)and(a[1][0]==0)and(a[2][0]==0)) or ((a[0][1]==0)and(a[1][1]==0)and(a[2][1]==0)) or ((a[0][2]==0)and(a[1][2]==0)and(a[2][2]==0)) or ((a[0][0]==0)and(a[1][1]==0)and(a[2][2]==0)) or ((a[0][2]==0)and(a[1][1]==0)and(a[2][0]==0)) else 'No'
print(ans)

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

N = int(input())

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

card_nums = r1 + r2 + r3

bingo_list = set()
for b in bs:
    if b in card_nums:
        index = card_nums.index(b)
        bingo_list.add(index)

bingo_candidates = [
    [0,1,2], [3,4,5], [6,7,8],
    [0,3,6], [1,4,7], [2,5,8],
    [0,4,8], [2,4,6]
]


def main():
    for bingo_candidate in bingo_candidates:
        result = set(bingo_candidate) & bingo_list

        if len(result) == 3:
            print("Yes")
            return
        else:
            continue
    print("No")

main()

Solution (Python):
import sys

a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
b = [int(input()) for i in range(n)]

a1.extend(a2)
a1.extend(a3)
result = []

for target_list in b:
    try:
        result.append(a1.index(target_list)+1)
    except:
        continue        

ans = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7],[2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7]]


for target_list in ans:
    tmp = set(target_list) & set(result)
    if len(tmp)>=3:
        print("Yes")
        sys.exit()

print("No")

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]=0
if a[0][0]==0 and a[0][1]==0 and a[0][2]==0:
    f=True
elif a[1][0]==0 and a[1][1]==0 and a[1][2]==0:
    f= True
elif a[2][0]==0 and a[2][1]==0  and a[2][2]==0:
    f= True
elif a[0][0]==0 and a[1][0]==0 and a[2][0]==0:
    f= True
elif a[0][1]==0 and a[1][1]==0 and a[2][1]==0:
    f= True
elif a[0][2]==0 and a[1][2]==0 and a[2][2]==0:
    f= True
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    f= True
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    f= True
else:
    f= False

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

Solution (Python):
def get(A, ar, ac):
    if ar > 2 or ar < 0 or ac > 2 or ac < 0:
        return 0
    if A[ar][ac] == 0:
        return 1
    return 0

def check(A, ar, ac):
    
    if 2 == get(A, ar-1, ac-1) + get(A, ar-2, ac-2) + get(A, ar+1, ac+1) + get(A, ar+2, ac+2):
        return True
    if 2 == get(A, ar+1, ac-1) + get(A, ar+2, ac-2) + get(A, ar-1, ac+1) + get(A, ar-2, ac+2):
        return True
    if 2 == get(A, ar+1, ac) + get(A, ar+2, ac) + get(A, ar-1, ac) + get(A, ar-2, ac):
        return True
    if 2 == get(A, ar, ac+1) + get(A, ar, ac+2) + get(A, ar, ac-1) + get(A, ar, ac-2):
        return True
    return False

A = [[0 for i in range(3)] for i in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for n in range(N):
    b = int(input())
    for ar in range(3):
        for ac in range(3):
            if A[ar][ac] == b:
                A[ar][ac] = 0
                if check(A, ar, ac):
                    print("Yes")
                    
                    import sys
                    sys.exit(0)
                continue
print("No")

Solution (Python):
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
l,m,k = map(int, input().split())
g = [a, b, c, d, e, f, l, m, k]
a1 = [a, b, c]
a2 = [d, e, f]
a3 = [l, m, k]
a4 = [a, d, l]
a5 = [b, e, m]
a6 = [c, f, k]
a7 = [a, e, k]
a8 = [c, e, l]
lis1 = []
n = int(input())
for i in range(n):
    op = int(input())
    lis1.append(op)
    
if set(a1) <= set(lis1) or set(a2) <= set(lis1) or set(a3) <= set(lis1) or set(a4) <= set(lis1) or set(a5) <= set(lis1) or set(a6) <= set(lis1) or set(a7) <= set(lis1) or set(a8) <= set(lis1):
    print('Yes')
else:
    print('No')

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

r = int(input())
for v in range(r):
    b.append(input())
for i in range(3):
    for a in range(3):
        for t in range(r):
            if l[i][a] == b[t]:
                l[i][a] = '@'
if l[0][0] == '@' and l[0][1] == '@' and l[0][2] == '@':
    print('Yes')
elif l[1][0] == '@' and l[1][1] == '@' and l[1][2] == '@':
    print('Yes')
elif l[2][0] == '@' and l[2][1] == '@' and l[2][2] == '@':
    print('Yes')
elif l[0][0] == '@' and l[1][0] == '@' and l[2][0] == '@':
    print('Yes')
elif l[0][1] == '@' and l[1][1] == '@' and l[2][1] == '@':
    print('Yes')
elif l[0][2] == '@' and l[1][2] == '@' and l[2][2] == '@':
    print('Yes')
elif l[0][0] == '@' and l[1][1] == '@' and l[2][2] == '@':
    print('Yes')
elif l[0][2] == '@' and l[1][1] == '@' and l[2][0] == '@':
    print('Yes')
else:
    print('No')

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = []
for _ in range(N):
  b.append(int(input()))
for n in range(N):
  for i in range(3):
    for j in range(3):
      if b[n]==A[i][j]:
        A[i][j]=0
a=A[0][0]+A[0][1]+A[0][2]
b=A[1][0]+A[1][1]+A[1][2]
c=A[2][0]+A[2][1]+A[2][2]
d=A[0][0]+A[1][0]+A[2][0]
e=A[0][1]+A[1][1]+A[2][1]
f=A[0][2]+A[1][2]+A[2][2]
g=A[0][0]+A[1][1]+A[2][2]
h=A[0][2]+A[1][1]+A[2][0]
if a==0 or b==0 or c==0 or d==0 or e==0 or f==0 or g==0 or h==0:
  print('Yes')
else:
  print('No')

Solution (Python):
r1 = [int(str) for str in input().split()]
r2 = [int(str) for str in input().split()]
r3 = [int(str) for str in input().split()]
n = int(input())

for i in range(n):
  b = int(input())
  r1 = [0 if x == b else x for x in r1]
  r2 = [0 if x == b else x for x in r2]
  r3 = [0 if x == b else x for x in r3]

c1 = [r1[0],r2[0],r3[0]]
c2 = [r1[1],r2[1],r3[1]]
c3 = [r1[2],r2[2],r3[2]]
s1 = [r1[0],r2[1],r3[2]]
s2 = [r1[2],r2[1],r3[0]]

s = [sum(r1),sum(r2),sum(r3),sum(c1),sum(c2),sum(c3),sum(s1),sum(s2)]

if 0 in s:
  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())
b=[]
for i in range(n):
    b.append(int(input()))
    
c=[]   
for j1 in range(3):
    c.append([0,0,0])

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

csum1=0                
csum2=0                
csum3=0                
for j1 in range(3):
    csum1=csum1+c[j1][0]                
    csum2=csum2+c[j1][1]                
    csum3=csum3+c[j1][2]
                
csum4=0                
csum5=0                
csum6=0                
for j1 in range(3):
    csum4=csum4+c[0][j1]                
    csum5=csum5+c[1][j1]                
    csum6=csum6+c[2][j1]

csum7=c[0][0]+c[1][1]+c[2][2]                
csum8=c[2][0]+c[1][1]+c[0][2]  

if csum1==3 or csum2==3 or csum3==3:
    print("Yes")
elif csum4==3 or csum5==3 or csum6==3:
    print("Yes")
elif csum7==3 or csum8==3 :
    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 = A1 + A2 + A3

N = int(input())

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


def isExistTatePair():
    
    for i in range(3):
            sum = 0
            for j in range(3):
                sum += A[3 * j + i]
            
            
            if sum == 0:
                return True
    return False
    

def isExistYokoPair():
    
    for i in range(3):
            sum = 0
            for j in range(3):
                sum += A[3 * i + j]
            
            
            if sum == 0:
                return True
    return False
    

def isExistNanamePair():
    
    naname1 = A[0] + A[4] + A[8]
    
    if naname1 == 0:
        return True
    
    
    naname2 = A[2] + A[4] + A[6]
    
    if naname2 == 0:
        return True
    
    return False


for b in B:
    for index in range(len(A)):
        a = A[index]
        if a == b:
            A[index] = 0
    
isExistBingo = isExistTatePair() or isExistYokoPair() or isExistNanamePair()
print('Yes' if isExistBingo else 'No')

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

for i in range(N):
  for j in range(3):
    for k in range(3):
      if A[j][k] == B[i]:
        A[j][k] = 'ok'
        
if A[0][0] == 'ok' and A[0][1] == 'ok' and A[0][2] == 'ok':
  print('Yes')
  exit
elif A[1][0] == 'ok' and A[1][1] == 'ok' and A[1][2] == 'ok':
  print('Yes')
  exit
elif A[2][0] == 'ok' and A[2][1] == 'ok' and A[2][2] == 'ok':
  print('Yes')
  exit
elif A[0][0] == 'ok' and A[1][0] == 'ok' and A[2][0] == 'ok':
  print('Yes')
  exit
elif A[0][1] == 'ok' and A[1][1] == 'ok' and A[2][1] == 'ok':
  print('Yes')
  exit
elif A[0][2] == 'ok' and A[1][2] == 'ok' and A[2][2] == 'ok':
  print('Yes')
  exit
elif A[0][0] == 'ok' and A[1][1] == 'ok' and A[2][2] == 'ok':
  print('Yes')
  exit
elif A[0][2] == 'ok' and A[1][1] == 'ok' and A[2][0] == 'ok':
  print('Yes')
  exit
else :
  print('No')

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
N = int(input())

a = a + b + c

list = []

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

b = [0,0,0,0,0,0,0,0,0]

for i in range(len(a)):
    for j in range(len(list)):
        if a[i] == list[j]:
            b[i] = 1

sum = 0
for i in range(len(b)):
    sum = sum + b[i]

if sum == 0:
    print("No")
elif b[2]+b[4]+b[6] ==3:
    print("Yes")
elif b[0]+b[1]+b[2] ==3:
    print("Yes")
elif b[3]+b[4]+b[5] ==3:
    print("Yes")
elif b[6]+b[7]+b[8] ==3:
    print("Yes")
elif b[0]+b[4]+b[8] ==3:
    print("Yes")
elif b[2]+b[5]+b[8] ==3:
    print("Yes")
elif b[1]+b[4]+b[7] ==3:
    print("Yes")
elif b[0]+b[3]+b[6] ==3:
    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()))
mx = [a1, a2, a3]

N = int(input())
b = {}
for i in range(N):
  b[int(input())] = True
  


def checkList(arr):
  for i in arr:
    if i not in b:
      return False
  return True
def check():
  if checkList(a1):
    return True
  if checkList(a2):
    return True
  if checkList(a3):
    return True
  if checkList([a1[0], a2[0], a3[0]]):
    return True
  if checkList([a1[1], a2[1], a3[1]]):
    return True
  if checkList([a1[2], a2[2], a3[2]]):
    return True
  if checkList([a1[0], a2[1], a3[2]]):
    return True
  if checkList([a1[2], a2[1], a3[0]]):
    return True
  return False

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

Solution (Python):
import sys
import numpy as np

lines = sys.stdin.readlines()
bingo_card = np.zeros([3,3])
for i, l in enumerate(lines):
    if i <= 2:
        bingo_card[i] = [int(num) for num in l.split()]
    else:
        bingo_card[bingo_card == int(l)] = None
        
check_arr = np.isnan(bingo_card)
if check_arr[0].sum() == 3 or check_arr[1].sum() == 3 or check_arr[2].sum() == 3:
    print('Yes')
elif check_arr[:, 0].sum() == 3 or check_arr[:, 1].sum() == 3 or check_arr[:, 2].sum() == 3:
    print('Yes')
elif check_arr[0,0] and check_arr[1,1] and check_arr[2,2]:
    print('Yes')
elif check_arr[0,2] and check_arr[1,1] and check_arr[2,0]:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

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())
S = []
for j in range(N):
    S.append(int(input())) 
for l in range(N):
    for k in range(3):
        if x[k] == S[l]:
            x[k] = 0
        else:
            a = 1
        if y[k] == S[l]:
            y[k] = 0
        else:
            a = 1
        if z[k] == S[l]:
            z[k] = 0
        else:
            a = 1
        
if x[0] == y[0] == z[0] == 0 or  x[1] == y[1] == z[1] == 0 or  x[2] == y[2] == z[2] == 0 or x[0] == x[1] == x[2] == 0 or y[0] == y[1] == y[2] == 0 or z[0] == z[1] == z[2] == 0 or x[0] == y[1] == z[2] == 0 or z[0] == y[1] == x[2] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
a,b,c = [int(x) for x in input().split()]
d,e,f = [int(x) for x in input().split()]
g,h,i = [int(x) for x in input().split()]

n = int(input())
S = {int(input()) for x in range(n)}

def q(x,y,z):
    return x in S and y in S and z in S

print('Yes' if q(a,b,c) or q(d,e,f) or q(g,h,i) or q(a,d,g) or q(b,e,h) or q(c,f,i) or q(a,e,i) or q(g,e,c) else 'No')

Solution (Python):
a = []
for i in range(3):
    a.append(input().split(" "))
b = [['101', '102', '103'], ['104', '105', '106'], ['107', '108', '109']]
N = input()
suji = []
for i in range(int(N)):
    suji.append(input())
for k in range(int(N)):
    for i in range(3):
        for s in range(3):
            if suji[k] == a[i][s]:
                b[i][s] = 0

judge = 0

for i in range(3):
    if b[i][0] == b[i][1] == b[i][2]:
        judge = 1
        
    if b[0][i] == b[1][i] == b[2][i]:
        judge = 1

if b[0][0] == b[1][1] == b[2][2]:
    judge = 1

if b[0][2] == b[1][1] == b[2][0]:
    judge = 1

if judge == 1:
    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=[0]*N
for i in range(N):
  b[i]=int(input())
C1=any([i == A1[0] for i in b])
C2=any([i == A1[1] for i in b])
C3=any([i == A1[2] for i in b])
C4=any([i == A2[0] for i in b])
C5=any([i == A2[1] for i in b])
C6=any([i == A2[2] for i in b])
C7=any([i == A3[0] for i in b])
C8=any([i == A3[1] for i in b])
C9=any([i == A3[2] for i in b])

if(any([all([C1,C2,C3]),all([C4,C5,C6]),all([C7,C8,C9]),all([C1,C4,C7]),all([C2,C5,C8]),all([C3,C6,C9]),all([C1,C5,C9]),all([C3,C5,C7])])):
   print("Yes")
else:
   print("No")

Solution (Python):
import numpy as np

a1,a2,a3 = map(int,input().split())
a4,a5,a6 = map(int,input().split())
a7,a8,a9 = map(int,input().split())

a = np.array([[a1, a2, a3], [a4, a5, a6], [a7, a8, a9]])

n = int(input())
for i in range(n):
  b = int(input())
  a = np.where(a == b, 0, a)

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

Solution (Python):
def check(cor, cc):
    
    for i in range(cc):
        flg = True
        for j in range(cc):
            if cor[i][j] != 1:
                flg = False
                break
        if flg:
            return True

    
    for i in range(cc):
        flg = True
        for j in range(cc):
            if cor[j][i] != 1:
                flg = False
                break
        if flg:
            return True

    flg = True
    for i in range(cc):
        if cor[i][i] != 1:
            flg = False
            break
    if flg:
        return True

    flg = True
    for i in range(cc):
        if cor[i][cc-1-i] != 1:
            flg = False
            break
    if flg:
        return True
    
    return False
    
    

tmp = list(map(int, input().split(' ')))
cc = len(tmp)
box = [[]for _ in range(cc)]
cor = [[0 for _ in range(cc)] for _ in range(cc)]
box[0] = tmp

for i in range(cc-1):
    box[i+1] = list(map(int, input().split(' ')))


N = int(input())
for _ in range(N):
    num = int(input())
    for i in range(cc):
        for j in range(cc):
            if num == box[i][j]:
                cor[i][j] = 1

if check(cor, cc):
    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())
B = [int(input()) for _ in range(N)]

for i in range(N):
    if B[i] in A[0]:
        A[0][A[0].index(B[i])] = True
    elif B[i] in A[1]:
        A[1][A[1].index(B[i])] = True
    elif B[i] in A[2]:
        A[2][A[2].index(B[i])] = True

bingo_flag = False
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == True:
        bingo_flag = True
    elif A[0][i] == A[1][i] == A[2][i] == True:
        bingo_flag = True

if A[0][0] == A[1][1] == A[2][2] == True:
    bingo_flag = True
if A[0][2] == A[1][1] == A[2][0] == True:
    bingo_flag = True

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

Solution (Python):
card = []
for i in range(3):
    num = [int(i) for i in input().split(" ")]
    for n in num:
        card.append(n)

N = int(input())
for i in range(N):
    m = int(input())
    try:
        idx = card.index(m)
    except ValueError:
        continue
    card[idx]=0

flag = 0
for i in [0,3,6]:
    if (card[i]+card[i+1]+card[i+2])==0:
        flag=1
        break
if flag!=1:
    for i in [0,1,2]:
        if (card[i]+card[i+3]+card[i+6])==0:
            flag=1
            break
if flag!=1:
    if (card[0]+card[4]+card[8])==0:
        flag=1
    elif (card[2]+card[4]+card[6])==0:
        flag=1
        
if flag==1:
    print("Yes")
else:
    print("No")

Solution (Python):
l=[list(map(int,input().split())) for i in range(3)]
n=int(input())
s=set()
for i in range(n):
    s.add(int(input()))
ans="No"
for i in range(3):
    if l[i][0] in s and l[i][1] in s and l[i][2] in s:
        ans="Yes"
    if l[0][i] in s and l[1][i] in s and l[2][i] in s:
        ans="Yes"
if l[0][0] in s and l[1][1] in s and l[2][2] in s:
        ans="Yes"
if l[0][2] in s and l[1][1] in s and l[2][0] in s:
        ans="Yes"
print(ans)

Solution (Python):
bingo1 = list(input().split())
bingo2 = list(input().split())
bingo3 = list(input().split())


for i in range(3):
    bingo1[i] = int(bingo1[i])
    bingo2[i] = int(bingo2[i])
    bingo3[i] = int(bingo3[i])
n = int(input())

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

if bingo1[0] in atari:
    bingo1[0] = 'y'
if bingo1[1] in atari:
    bingo1[1] = 'y'
if bingo1[2] in atari:
    bingo1[2] = 'y'
if bingo2[0] in atari:
    bingo2[0] = 'y'
if bingo2[1] in atari:
    bingo2[1] = 'y'
if bingo2[2] in atari:
    bingo2[2] = 'y'
if bingo3[0] in atari:
    bingo3[0] = 'y'
if bingo3[1] in atari:
    bingo3[1] = 'y'
if bingo3[2] in atari:
    bingo3[2] = 'y'

if bingo1[0] == bingo2[0] == bingo3[0] == 'y':
    print('Yes')
elif bingo1[1] == bingo2[1] == bingo3[1] == 'y':
    print('Yes')
elif bingo1[2] == bingo2[2] == bingo3[2] == 'y':
    print('Yes')

elif bingo1[0] == bingo1[1] == bingo1[2] == 'y':
    print('Yes')
elif bingo2[0] == bingo2[1] == bingo2[2] == 'y':
    print('Yes')
elif bingo3[0] == bingo3[1] == bingo3[2] == 'y':
    print('Yes')

elif bingo1[0] == bingo2[1] == bingo3[2] == 'y':
    print('Yes')
elif bingo1[2] == bingo2[1] == bingo3[0] == 'y':
    print('Yes')

else:
    print('No')

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


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

def f(ans):
    if yoko(ans) or tate(ans) or naname(ans):
        return True
    else:
        return False

def yoko(ans):
    tmp = []
    for i in ans:
        tmp.append(sum(i))
    if -3 in tmp:
        return True
    else:
        return False

def tate(ans):
    tmp = [0]*3
    for i in range(3):
        for j in range(3):
            tmp[j] += ans[i][j]
    if -3 in tmp:
        return True
    else:
        return False

def naname(ans):
    tmp = [0]*2
    tmp[0] = ans[0][0] + ans[1][1] + ans[2][2]
    tmp[1] = ans[0][2] + ans[1][1] + ans[2][0]
    if -3 in tmp:
        return True
    else:
        return False


if f(ans):
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
bit_ary = [1, 2, 4, 8, 16, 32, 64, 128, 256]
check_ary = [7, 56, 448, 73, 146, 292, 273, 84]
map_ = []
selecter = range(9)
player = 0

def checker(p):
    for check in check_ary:
        if ((check & p) == check):
            return True
    return False

for _ in range(3):
    a, b, c = map(int, input().split())
    map_.append(a)
    map_.append(b)
    map_.append(c)

    
n = int(input())
for _ in range(n):
    b = int(input())
    try:
        player += bit_ary[map_.index(b)]
        map_[map_.index(b)] = 'done'
    except:
        pass

if checker(player):
    print("Yes")
else:
    print("No")

Solution (Python):
list1=[0]*3
list2=[0]*3
list3=[0]*3
list4=[0]*3
c=0
for i in range(3):
    list1[i], list2[i],  list3[i]= map(int, input().split())
n=int(input())
for j in range(n):
    b=int(input())
    if b in list1:
        list1[list1.index(b)]=0
    if b in list2:
        list2[list2.index(b)]=0
    if b in list3:
        list3[list3.index(b)]=0
for i in range(3):
    list4[i]=list1[i]+list2[i]+list3[i]
d=list1[0]+list2[1]+list3[2]
e=list1[2]+list2[1]+list3[0]
if sum(list1)==0 or sum(list2)==0 or sum(list3)==0 or d==0 or e==0 or(0 in list4):
    print('Yes')
else:
    print('No')

Solution (Python):
a = []
b = []
flag = 0
a0 = list(map(int, input().split()))
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a.append(a0)
a.append(a1)
a.append(a2)
n = int(input())
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] = 0

for i in range(3):
    if((a[i][0] + a[i][1] + a[i][2]) == 0):
        flag = 1
    elif((a[0][i] + a[1][i] + a[2][i]) == 0):
        flag =2
    elif((a[0][0] + a[1][1] + a[2][2]) == 0):
        flag = 3
    elif((a[0][2] + a[1][1] + a[2][0]) == 0):
        flag = 4

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

Solution (Python):
bingo = []
for i in range(3):
    A1, A2, A3 = map(int, input().split())
    bingo.append(A1)
    bingo.append(A2)
    bingo.append(A3)

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

for i in range(3):
    if ((bingo[i-1] in b_list) and (bingo[i+2] in b_list) and (bingo[i+5] in b_list)):
        print("Yes")
        exit()

    elif ((bingo[3*(i-1)] in b_list) and (bingo[3*(i-1)+1] in b_list) and (bingo[3*(i-1)+2] in b_list)):
        print("Yes")
        exit()

if ((bingo[0] in b_list) and (bingo[4] in b_list) and (bingo[8] in b_list)):
    print("Yes")
    exit()

elif ((bingo[2] in b_list) and (bingo[4] in b_list) and (bingo[6] in b_list)):
    print("Yes")
    exit()

else:
    print("No")

Solution (Python):
import sys



def solve(lines):
    bingo = []
    for i in range(3):
        bingo.append(list(map(int, lines.pop(0).split(' '))))
    bingo = sum(bingo, [])
    N = int(lines.pop(0))
    for i in range(N):
        a = int(lines.pop(0))
        if a in bingo:
            b = bingo.index(a)
            bingo[b] = -1
    atari = [
        [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 ax in atari:
        ok = True
        for i in ax:
            if not bingo[i] < 0:
                ok = False
                continue
        if ok:
            print('Yes')
            return
    print('No')


lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

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


fl = 0
for b in range(N):
  for i in range(3):
    for j in range(3):
      if A[i][j] == B[b]:
        A[i][j] = -1
        
for i in range(3):
  if A[i] == [-1,-1,-1]:
    fl = 1
    
for i in range(3):
    if int(A[0][i])*int(A[1][i])*int(A[2][i]) == -1:
      fl = 1

if int(A[0][0])*int(A[1][1])*int(A[2][2]) == -1 or int(A[0][2])*int(A[1][1])*int(A[2][0]) == -1:
  fl = 1

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

Solution (Python):
A = [None] * 9

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



N = int(input())


ANS = [None] * 9



def main():

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

        if choice in A:
            ANS[A.index(choice)] = 1


    

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


print(main())

Solution (Python):
import sys
N = 3


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

A_t = [list(x) for x in zip(*A)]
A_n = [[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]
N = int(input())
B=[]
cnt = [0]*3
for i in range(N):
    B.append(int(input()))
    
num = 0
for j in A:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 3 in cnt:
    print("Yes")
    sys.exit(0)
cnt = [0,0,0]
num = 0
for j in A_t:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 3 in cnt:
    print("Yes")
    sys.exit()
cnt = [0,0,0]
num = 0
for j in A_n:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 3 in cnt:
    print("Yes")
else:
    print("No")

Solution (Python):

A = []
for _ in range(3):
    A.extend(input().rstrip().split(' '))
n = int(input())
lst = [input() for _ in range(n)]

C = [0 for i in range(9)]

for s in lst:
    for t in range(9):
        if s == A[t]:
            C[t] = 1
Ans = 'No'
Cset = max(C[0] + C[1] + C[2], C[3] + C[4] + C[5], C[6] + C[7] + C[8],C[0] + C[3] + C[6], C[1] + C[4] + C[7], C[2] + C[5] + C[8], C[0] + C[4] + C[8], C[2] + C[4] + C[6])
if Cset == 3:
  Ans = 'Yes'
print(Ans)