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):
C = []
result = [[0]*3 for i in range(3)]
ans = "No"
for i in range(3):
    a = list(map(int, input().split()))
    C.append(a)

def check():
    b = int(input())
    for i in range(3):
        for j in range(3):
            a = C[i][j]
            if b == a:
                result[i][j] = 1

def column():
    for j in range(3):
        for i in range(3):
            if result[i][j] == 0:
                break
        else:
            global ans
            ans = "Yes"

def row():
    for i in range(3):
        for j in range(3):
            if result[i][j] == 0:
                break
        else:
            global ans
            ans = "Yes"

def naname():
    global ans
    for j in range(3):
        if result[j][j] == 0:
            break
    else:
        ans = "Yes"
    for j in range(3):
        if result[j][2-j] == 0:
            break
    else:
        ans = "Yes"

N = int(input())
for i in range(N):
    check()
    column()
    row()
    naname()

print(ans)

Solution (Python):
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)

if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Solution (Python):
a11, a12, a13 = list(map(int, input().split()))
a21, a22, a23 = list(map(int, input().split()))
a31, a32, a33 = list(map(int, input().split()))
n = int(input())
b = [0]*n
for i in range(n):
  b[i] = int(input())
  if a11 == b[i]:
    a11 = -1
  if a12 == b[i]:
    a12 = -1
  if a13 == b[i]:
    a13 = -1
  if a21 == b[i]:
    a21 = -1
  if a22 == b[i]:
    a22 = -1
  if a23 == b[i]:
    a23 = -1
  if a31 == b[i]:
    a31 = -1
  if a32 == b[i]:
    a32 = -1
  if a33 == b[i]:
    a33 = -1
flag = False
if a11 == -1 and a12 == -1 and a13 ==-1:
  flag = True
if a21 == -1 and a22 == -1 and a23 ==-1:
  flag = True
if a31 == -1 and a32 == -1 and a33 ==-1:
  flag = True
if a11 == -1 and a21 == -1 and a31 ==-1:
  flag = True
if a12 == -1 and a22 == -1 and a32 ==-1:
  flag = True
if a13 == -1 and a23 == -1 and a33 ==-1:
  flag = True
if a11 == -1 and a22 == -1 and a33 ==-1:
  flag = True
if a13 == -1 and a22 == -1 and a31 ==-1:
  flag = True
if flag:
  print("Yes")
else:
  print("No")

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

    N = int(input())
    for i in range(N):
        b = int(input())
        for j, r in enumerate(A):
            for k, c in enumerate(r):
                if c == b:
                    M[j][k] = True

    for i in M:
        if all(i):
            print('Yes')
            return

    for i in list(zip(*M)):
        if all(i):
            print('Yes')
            return

    if (M[0][0] and M[1][1] and M[2][2]):
        print('Yes')
        return

    if (M[0][2] and M[1][1] and M[2][0]):
        print('Yes')
        return

    print('No')


main()

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

a_hit = [[False, False, False],
         [False, False, False],
         [False, False, False]]

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

if (a_hit[0][0]) and (a_hit[0][1]) and (a_hit[0][2]):
    print("Yes")
elif (a_hit[1][0]) and (a_hit[1][1]) and (a_hit[1][2]):
    print("Yes")
elif (a_hit[2][0]) and (a_hit[2][1]) and (a_hit[2][2]):
    print("Yes")
elif (a_hit[0][0]) and (a_hit[1][0]) and (a_hit[2][0]):
    print("Yes")
elif (a_hit[0][1]) and (a_hit[1][1]) and (a_hit[2][1]):
    print("Yes")
elif (a_hit[0][2]) and (a_hit[1][2]) and (a_hit[2][2]):
    print("Yes")
elif (a_hit[0][0]) and (a_hit[1][1]) and (a_hit[2][2]):
    print("Yes")
elif (a_hit[0][2]) and (a_hit[1][1]) and (a_hit[2][0]):
    print("Yes")
else:
    print("No")

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

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




match = []
for A_line in A:
  match.append([(a in B) for a in A_line])


ans = False

for m in match:
  ans = ans or all(m)


match_v = [[m[i] for m in match] for i in range(3)]

for m in match_v:
  ans = ans or all(m)

ans = ans or all([match[i][i] for i in range(3)])
ans = ans or all([match[2-i][i] for i in range(3)])

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

Solution (Python):
def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    B = [int(input()) for _ in range(n)]
    ans =  [None]*8
    AT = list(zip(*A))
    ans[0] = set(A[0])
    ans[1] = set(A[1])
    ans[2] = set(A[2])
    ans[3] = set(AT[0])
    ans[4] = set(AT[1])
    ans[5] = set(AT[2])
    ans[6] = set([A[i][i] for i in range(3)])
    ans[7] = set([A[i][2-i] for i in range(3)])

    for b in B:
        for a in ans:
            if b in a:
                a -= {b}
                if not a:
                    print("Yes")
                    return
    print("No")

if __name__ == "__main__":
    main()

Solution (Python):
import sys
from io import StringIO
import unittest
def resolve():
    a1=list(map(int,input().strip().split()))
    a2=list(map(int,input().strip().split()))
    a3=list(map(int,input().strip().split()))
    n = int(input().strip())
    b=[]
    for i in range(n):
        tmp=int(input().strip())
        b.append(tmp)

    if a1[0] in b and a1[1] in b and a1[2] in b:
        print("Yes")
        return
    
    if a2[0] in b and a2[1] in b and a2[2] in b:
        print("Yes")
        return
    
    if a3[0] in b and a3[1] in b and a3[2] in b:
        print("Yes")
        return

    
    if a1[0] in b and a2[0] in b and a3[0] in b:
        print("Yes")
        return
    
    if a1[1] in b and a2[1] in b and a3[1] in b:
        print("Yes")
        return
    
    if a1[2] in b and a2[2] in b and a3[2] in b:
        print("Yes")
        return

    
    if a1[0] in b and a2[1] in b and a3[2] in b:
        print("Yes")
        return

    if a1[2] in b and a2[1] in b and a3[0] in b:
        print("Yes")
        return
    print("No")
    return

resolve()

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

def check(seen):
    ans = 0
    if seen[0][0] and seen[0][1] and seen[0][2]:
        ans = 1
    if seen[1][0] and seen[1][1] and seen[1][2]:
        ans = 1
    if seen[2][0] and seen[2][1] and seen[2][2]:
        ans = 1
    if seen[0][0] and seen[1][0] and seen[2][0]:
        ans = 1
    if seen[0][1] and seen[1][1] and seen[2][1]:
        ans = 1
    if seen[0][2] and seen[1][2] and seen[2][2]:
        ans = 1
    if seen[0][0] and seen[1][1] and seen[2][2]:
        ans = 1
    if seen[2][0] and seen[1][1] and seen[0][2]:
        ans = 1
    if ans == 1:
        print("Yes")
        exit()
    else:
        print("No")

N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == b:
                seen[j][k] = True

check(seen)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007




def main():
	A = []
	A1 = inputList()
	A2 = inputList()
	A3 = inputList()
	A.append(A1)
	A.append(A2)
	A.append(A3)

	hantei1 = [[False for j in range(3)] for i in range(3)]
	

	ans = "No"
	N = inputInt()
	for i in range(N):
		tmp = inputInt()
		for ii,vol in enumerate(A):
			for jj,val in enumerate(vol):
				if tmp == val:
					hantei1[ii][jj] = True

		for iii in hantei1:
			if iii == [True,True,True]:
				ans = "Yes"
				
		for iii in range(3):
			flg = True
			for jjj in hantei1:
				if jjj[iii] == False:
					flg = False
					break
			if flg == True:
				ans = "Yes"
		if hantei1[0][0] == True and hantei1[1][1] == True and hantei1[2][2] == True:
			ans = "Yes"
		if hantei1[0][2] == True and hantei1[1][1] == True and hantei1[2][0] == True:
			ans = "Yes"
	
	print(ans)








def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a = inpll(3)
    n = inp()
    b = inplm(n)
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                a[i][j] = 0
    for i in range(3):
        flag = True
        for j in range(3):
            if a[i][j] != 0:
                flag = False
        if flag:
            print('Yes')
            return
    for i in range(3):
        flag = True
        for j in range(3):
            if a[j][i] != 0:
                flag = False
        if flag:
            print('Yes')
            return
    flag = True
    for i in range(3):
        if a[i][i] != 0:
            flag = False
    if flag:
        print('Yes')
        return
    flag = True
    for i in range(3):
        if a[i][2-i] != 0:
            flag = False
    if flag:
        print('Yes')
        return
    print('No')
    
if __name__ == "__main__":
    main()

Solution (Python):
a_ = [[int(x) for x in input().split()] for _ in range(3)]
n = int(input())
b = []
for _ in range(n): b.append(int(input()))
a = []
for i in range(3):
    for a_i in a_[i]:
        a.append(a_i)
for b_i in b:
    if b_i not in a: continue
    else:
        a[a.index(b_i)] = 0
ans = "No"
for i in range(3):
    if a[i*3] == 0 and a[i*3+1] == 0 and a[i*3+2] == 0:
        ans = "Yes"
        break
for i in range(3):
    if a[i] == 0 and a[i+3] == 0 and a[i+6] == 0:
        ans = "Yes"
        break
if a[2] == 0 and a[4] == 0 and a[6] == 0: ans = "Yes"
if a[0] == 0 and a[4] == 0 and a[8] == 0: ans = "Yes"
print(ans)

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

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

flag = False



for al in Amat:
    if all([a == -1 for a in al]):
        flag = True
        break


for i in range(3):
    if all([Amat[j][i] == -1 for j in range(3)]):
        flag = True
        break
        

if all([Amat[0][0]==-1, Amat[1][1]==-1, Amat[2][2]==-1]) or all([Amat[0][2]==-1,Amat[1][1]==-1,Amat[2][0]==-1]):
    flag = True

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

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

bingo = [
    [[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 B in bingo:
    for b in B:
        if A[b[0]][b[1]] != 0:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Solution (Python):

''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return [int(x) for x in sys.stdin.readline().strip().split()]


def judge(a):
    for aij in ai:
        if aij not in b:
            flag = False
            break


def main():
    a = [_ia() for _ in range(3)]

    n = _i()
    b = [_i() for _ in range(n)]
    f1 = True
    f4 = True
    for i in range(3):
        if a[i][i] not in b: f1 = False
        if a[i][-1-i] not in b: f4 = False

        f2, f3 = [True] * 2
        for j in range(3):
            if a[i][j] not in b: f2 = False
            if a[j][i] not in b: f3 = False
        if f2 or f3: return "Yes"
    return "Yes" if f1 or f4 else "No"


if __name__ == "__main__":
    print(main())

Solution (Python):
import math
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = []
for i in range(3):
  n = IL()
  for j in n:
    a.append(j)

N = I()
used = [False]*9
for _ in range(N):
  n = I()
  for i in range(9):
    if a[i] == n:
      used[i] = True

f = 0
if all(used[0:3]) or all(used[3:6]) or all(used[6:9]):
  f = 1
if (used[0] and used[3] and used[6]) or (used[1] and used[4] and used[7]) or (used[2] and used[5] and used[8]):
  f = 1
if (used[0] and used[4] and used[8]):
  f = 1
if (used[2] and used[4] and used[6]):
  f = 1
if f == 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)]

if A[0][0] in B and A[0][1] in B and A[0][2] in B:
  print('Yes')
elif A[1][0] in B and A[1][1] in B and A[1][2] in B:
  print('Yes')
elif A[2][0] in B and A[2][1] in B and A[2][2] in B:
  print('Yes')
elif A[0][0] in B and A[1][0] in B and A[2][0] in B:
  print('Yes')
elif A[0][1] in B and A[1][1] in B and A[2][1] in B:
  print('Yes')
elif A[0][2] in B and A[1][2] in B and A[2][2] in B:
  print('Yes')
elif A[0][0] in B and A[1][1] in B and A[2][2] in B:
  print('Yes')
elif A[2][0] in B and A[1][1] in B and A[0][2] in B:
  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 = list(int(input()) for i in range(N))

def check(A, B):
    for k in range(N):
        for j in range(3):
            if A[j] == B[k]:
                A[j] = 0
    return A

A1 = check(A1, B)
A2 = check(A2, B)
A3 = check(A3, B)

if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print("Yes")
elif (A1[0] + A2[0] + A3[0] == 0) or (A1[1] + A2[1] + A3[1] == 0) or (A1[2] + A2[2] + A3[2] == 0):
    print("Yes")
elif (A1[0] + A2[1] + A3[2] == 0) or (A1[2] + A2[1] + A3[0] == 0):
    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())
ans=[0]*9
a='No'
for i in range(N):
    b=int(input())
    if b in A:
        ans[A.index(b)]=1
cheack=[ans[0:3],ans[3:6],ans[6:9],ans[0::3],ans[1::3],ans[2::3],ans[0::4],ans[2:7:2]]
for C in cheack:
    if sum(C)==3:
        a='Yes'
        break
print(a)

Solution (Python):
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
g,h,i = map(int, input().split())
n = int(input())

ab = False
bb = False
cb = False
db = False
eb = False
fb = False
gb = False
hb = False
ib = False

for k in range(n):
  inp = int(input())
  if inp == a:
    ab = True
  elif inp == b:
    bb = True
  elif inp == c:
    cb = True
  elif inp == d:
    db = True
  elif inp == e:
    eb = True
  elif inp == f:
    fb = True
  elif inp == g:
    gb = True
  elif inp == h:
    hb = True
  elif inp == i:
    ib = True
    
if ab and bb and cb:
  print('Yes')
elif db and eb and fb:
  print('Yes')
elif gb and hb and ib:
  print('Yes')
elif ab and db and gb:
  print('Yes')
elif bb and eb and hb:
  print('Yes')
elif cb and fb and ib:
  print('Yes')
elif ab and eb and ib:
  print('Yes')
elif cb and eb and gb:
  print('Yes')
else:
  print('No')

Solution (Python):


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

n = int(input())

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


for line in board:
    result = True
    for v in line:
        if v in nums:
            pass
        else:
            result = False
            break
    if result:
        print('Yes')
        exit()


for i in range(3):
    result = True
    for j in range(3):
        if board[j][i] in nums:
            pass
        else:
            result = False
            break
    if result:
        print('Yes')
        exit()


if board[0][0] in nums and board[1][1] in nums and board[2][2] in nums:
    print('Yes')
    exit()

if board[0][2] in nums and board[1][1] in nums and board[2][0] in nums:
    print('Yes')
    exit()


print('No')

Solution (Python):
import numpy as np
A = [list(map(int, input().split()))]
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A = np.array(A)
result = A
for _ in range(int(input())):
    result[A == int(input())] = 0
ans = "No"
for i in range(3):
    if sum(result[i, :] == 0) == 3:
        ans = "Yes"
for j in range(3):
    if sum(result[:, j] == 0) == 3:
        ans = "Yes"
if sum([result[0, 0], result[1, 1], result[2, 2]]) == 0:
    ans = "Yes"
if sum([result[2, 0], result[1, 1], result[0, 2]]) == 0:
    ans = "Yes"
print(ans)

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

lst = [[0]*3 for _ in range(3)]
for i in range(N):
  num = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == num:
        lst[j][k] = 1
ans = 'No'
if (lst[0][0] == 1 and lst[0][1] == 1 and lst[0][2] == 1):
  ans = 'Yes'
elif (lst[1][0] == 1 and lst[1][1] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[2][0] == 1 and lst[2][1] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[0][0] == 1 and lst[1][0] == 1 and lst[2][0] == 1):
  ans = 'Yes'
elif (lst[0][1] == 1 and lst[1][1] == 1 and lst[2][1] == 1):
  ans = 'Yes'
elif (lst[0][2] == 1 and lst[1][2] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[0][0] == 1 and lst[1][1] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[2][0] == 1 and lst[1][1] == 1 and lst[0][2] == 1):
  ans = 'Yes'

print(ans)

Solution (Python):
a = []

b = {}

for i in range(3):
    x = map(int, input().split())
    a += x

n = int(input())

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

for i in range(n):
    x = int(input())
    if x in a:
        index = a.index(x)
        ans[index] = 1




flag = False

for i in range(3):
    if ans[i * 3] + ans[i * 3 + 1] + ans[i * 3 + 2] == 3:
        flag = True
        break
    if ans[i] + ans[i + 3] + ans[i + 6] == 3:
        flag = True
        break

if ans[0] + ans[4] + ans[8] == 3:
    flag = True
elif ans[2] + ans[4] + ans[6] == 3:
    flag = True

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

Solution (Python):
a = []
for j in range(3):
    a.append([int(x) for x in input().split()])
n = int(input())
b = [int(input()) for i in range(n)]
def hasbingo(ps):
    for x, y in ps:
        if a[y][x] not in b:
            return False
    return True

def hasany():
    for i in range(3):
        if hasbingo([(i, 0),(i, 1),(i, 2)]):
            return True
        if hasbingo([(0, i), (1, i), (2, i)]):
            return True
    if hasbingo([(0,0),(1,1),(2,2)]):
        return True
    return hasbingo([(0,2),(1,1), (2,0)])

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

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

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

ans = "No"
for i in range(3):
    if sum(a[i]) == 0:
        ans = "Yes"

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

if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"

if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"

print(ans)

Solution (Python):
a = []
for i in range(3):
    s = list(map(int,input().split()))
    a.append(s)
n = int(input())
b = [int(input()) for i 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] = -1
cnt = 0
tate = 0
for i in range(3):
    cnt = 0
    for j in range(3):
        if a[j][i] == -1:
            cnt +=1
    if cnt ==3:
        tate = 1
        break
cnt = 0
yoko = 0
for i in range(3):
    cnt = 0
    for j in range(3):
        if a[i][j] == -1:
            cnt+=1
    if cnt == 3:
        yoko = 1
        break
cnt = 0
naname1 = 0
for i in range(3):
    if a[i][i] == -1:
        cnt+=1
if cnt == 3:
    naname1 = 1
cnt = 0
naname2 = 0
for i in range(3):
    if a[i][2-i] == -1:
        cnt +=1
if cnt == 3:
    naname2 = 1
if tate == 1 or yoko == 1 or naname1 == 1 or naname2 == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
A = [0]*3
for i in range(3):
    A[i] = [int(a) for a in input().split()]

N = int(input())
B = [int(input()) for _ in range(N)]

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

f = 0
for i in range(3):
    if sum(A[i][:]) == 0:
        f = 1


for i in range(3):
    x = 0
    for j in range(3):
        x += A[j][i]
    if x == 0:
        f = 1
x = 0
for i in range(3):
    x += A[i][i]
if x == 0:
    f = 1

x = 0
x = A[0][2]+A[1][1]+A[2][0]
if x == 0:
    f = 1

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

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

for bi in b:
    if bi in a:
        a[a.index(bi)] = 0

bingo = [
    a[0] + a[1] + a[2],
    a[3] + a[4] + a[5],
    a[6] + a[7] + a[8],
    a[0] + a[3] + a[6],
    a[1] + a[4] + a[7],
    a[2] + a[5] + a[8],
    a[0] + a[4] + a[8],
    a[2] + a[4] + a[6],
]

if min(bingo) == 0:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007




def main():
	A = []
	A1 = inputList()
	A2 = inputList()
	A3 = inputList()
	A.append(A1)
	A.append(A2)
	A.append(A3)

	hantei1 = [[False for j in range(3)] for i in range(3)]
	

	ans = "No"
	N = inputInt()
	for i in range(N):
		tmp = inputInt()
		for ii,vol in enumerate(A):
			for jj,val in enumerate(vol):
				if tmp == val:
					hantei1[ii][jj] = True

		for iii in hantei1:
			if iii == [True,True,True]:
				ans = "Yes"
				
		for iii in range(3):
			flg = True
			for jjj in hantei1:
				if jjj[iii] == False:
					flg = False
					break
			if flg == True:
				ans = "Yes"
		if hantei1[0][0] == True and hantei1[1][1] == True and hantei1[2][2] == True:
			ans = "Yes"
		if hantei1[0][2] == True and hantei1[1][1] == True and hantei1[2][0] == True:
			ans = "Yes"
	
	print(ans)








def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Solution (Python):
def main():
    a =[]
    for i in range(3):
        aa =list(map(int,input().split()))
        a.append(aa)
    n = int(input())
    b = []
    for _ in range(n):
        bb = int(input())
        b.append(bb)

    ans = [[0] * 3 for i in range(3)]
    
    for i, bb in enumerate(b):
        f = 0
        for j , aa in enumerate(a):
            if bb in aa:
                f = 1
                break
        if f ==1:
            ans[j][aa.index(bb)] = 1
    if sum(ans[0]) == 3 or sum(ans[1]) == 3 or sum(ans[2]) == 3 :
        print('Yes')
        return
    if ans[0][0] + ans[1][0] + ans[2][0] == 3 or ans[0][1] + ans[1][1] + ans[2][1] == 3 or ans[0][2] + ans[1][2] + ans[2][2] == 3:
        print('Yes')
        return
    if ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3:
        print('Yes')
        return
    print('No')
    

if __name__=='__main__':
    main()

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

for i in ListC:
	for y in range(3):
		for x in range(3):
			if ListA[y][x] == i:
				ListB[y][x] = 1

if ListB[0][0] == 1 and ListB[0][1] and ListB[0][2]:
	print('Yes')
elif ListB[1][0] == 1 and ListB[1][1] and ListB[1][2]:
	print('Yes')
elif ListB[2][0] == 1 and ListB[2][1] and ListB[2][2]:
	print('Yes')
elif ListB[0][0] == 1 and ListB[1][0] and ListB[2][0]:
	print('Yes')
elif ListB[0][1] == 1 and ListB[1][1] and ListB[2][1]:
	print('Yes')
elif ListB[0][2] == 1 and ListB[1][2] and ListB[2][2]:
	print('Yes')
elif ListB[0][0] == 1 and ListB[1][1] and ListB[2][2]:
	print('Yes')
elif ListB[0][2] == 1 and ListB[1][1] and ListB[2][0]:
	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()))
t1=[a1[0],a2[0],a3[0]]
t2=[a1[1],a2[1],a3[1]]
t3=[a1[2],a2[2],a3[2]]
n1=[a1[0],a2[1],a3[2]]
n2=[a1[2],a2[1],a3[0]]
n=int(input())
b=[int(input()) for i in range(n)]
def f(list):
  if list[0] in b and list[1] in b and list[2] in b:
    return True
  else:
    return False
if f(a1) or f(a2) or f(a3) or f(t1) or f(t2) or f(t3) or f(n1) or f(n2):
  print("Yes")
else:
  print("No")

Solution (Python):

import sys
input = sys.stdin.readline





def main():
    B = [[]*3 for i in range(3)]
    for i in range(3):
        B[i] = list(map(int, input().split()))
    
    C = [[0]*3 for i in range(3)]
    n = int(input())
    for i in range(n):
        check = int(input())
        for i in range(3):
            for j in range(3):
                if B[i][j] == check:
                    C[i][j] = 1
    ans = "No"
    for i in range(3):
        if (C[i][0] == 1 and C[i][1] == 1 and C[i][2] == 1):
            ans = "Yes"
            break
        if (C[0][i] == 1 and C[1][i] == 1 and C[2][i] == 1):
            ans = "Yes"
            break
        if (C[0][0] == 1 and C[1][1] == 1 and C[2][2] == 1):
            ans = "Yes"
            break
        if (C[2][0] == 1 and C[1][1] == 1 and C[0][2] == 1):
            ans = "Yes"
            break
    
    print("Yes") if ans == "Yes" else print("No")
            
            


    
if __name__ == '__main__':
    main()