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):
from itertools import product

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

N = int(input())

B = []
for _ in range(N):
    b = int(input())
    for i, j in product(range(3), repeat=2):
        if A1[i][j] == b:
            A1[i][j] = 0
            continue

A2 = [
    [A1[0][0], A1[1][0], A1[2][0]],
    [A1[0][1], A1[1][1], A1[2][1]],
    [A1[0][2], A1[1][2], A1[2][2]]
]

A3 = [
    [A1[0][0], A1[1][1], A1[2][2]],
    [A1[2][0], A1[1][1], A1[0][2]]
]

AA = A1 + A2 + A3

R = 'No'
for aa in AA:
    if sum(aa) == 0:
        R = 'Yes'
        break

print(R)

Solution (Python):
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
N=int(input())
b=[]
for i in range(N):
    c=int(input())
    b.append(c)
flag=False
tmp1=0
tmp2=0
tmp3=0
for i in range(3):
    for j in range(N):
        if b[j]==a1[i]:
            tmp1+=1
        if b[j]==a2[i]:
            tmp2+=1
        if b[j]==a3[i]:
            tmp3+=1
if tmp1==3:
    flag=True
if tmp2==3:
    flag=True
if tmp3==3:
    flag=True
tmp=0
for i in range(3):
    tmp=0
    for j in range(N):
        if b[j]==a1[i]:
            tmp+=1
        if b[j]==a2[i]:
            tmp+=1
        if b[j]==a3[i]:
            tmp+=1
    if tmp==3:
        flag=True
tmp=0
for i in range(N):
    if b[i]==a1[0]:
        tmp+=1
    if b[i]==a2[1]:
        tmp+=1
    if b[i]==a3[2]:
        tmp+=1
if tmp==3:
    flag=True
tmp=0
for i in range(N):
    if b[i]==a1[2]:
        tmp+=1
    if b[i]==a2[1]:
        tmp+=1
    if b[i]==a3[0]:
        tmp+=1
if tmp==3:
    flag=True
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
for i in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
b = []
flag = 0
for i in range(n):
    b.append(int(input()))
for i in range(n):
    if b[i] in a[0]:
        a[0][a[0].index(b[i])]=0
    elif b[i] in a[1]:
        a[1][a[1].index(b[i])]=0
    elif b[i] in a[2]:
        a[2][a[2].index(b[i])]=0
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[0][2] == a[1][1] == a[2][0] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
list1 = []
for x in range(3):
    list1.append([int(i)for i in input().split()])
n = int(input())
indices = []
for x in range(n):
    val = int(input())
    if val in list1[0]:
        indices.append([list1[0].index(val),0])
    elif val in list1[1]:
        indices.append([list1[1].index(val),1])
    elif val in list1[2]:
        indices.append([list1[2].index(val),2])
    else:
        indices.append(-1)
if [0,0] in indices and [0,1] in indices and [0,2] in indices:
    print("Yes")
elif [1,0] in indices and [1,1] in indices and [1,2] in indices:
    print("Yes")
elif [2,0] in indices and [2,1] in indices and [2,2] in indices:
    print("Yes")
elif [0,0] in indices and [1,0] in indices and [2,0] in indices:
    print("Yes")
elif [0,1] in indices and [1,1] in indices and [2,1] in indices:
    print("Yes")
elif [0,2] in indices and [1,2] in indices and [2,2] in indices:
    print("Yes")
elif [0,0] in indices and [1,1] in indices and [2,2] in indices:
    print("Yes")
elif [0,2] in indices and [1,1] in indices and [2,0] in indices:
    print("Yes")
else:
    print("No")

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

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -100:
        print("Yes")
        exit(0)
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == -100:
        print("Yes")
        exit(0)

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

print("No")

Solution (Python):
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
han=[]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j]==B[k]:
                A[i][j]=0
if A[0][0]==A[0][1]==A[0][2]==0 or A[1][0]==A[1][1]==A[1][2]==0 or A[2][0]==A[2][1]==A[2][2]==0:
    print("Yes")
    exit()
if A[0][0]==A[1][0]==A[2][0]==0 or A[0][1]==A[1][1]==A[2][1]==0 or A[0][2]==A[1][2]==A[2][2]==0:
    print("Yes")
    exit()
if A[0][0]==A[1][1]==A[2][2]==0 or A[0][2]==A[1][1]==A[2][0]:
    print("Yes") 
    exit()
print("No")

Solution (Python):



from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe




def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)






def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

def pin(type=int):
    return map(type,input().split())
     

"""
def resolve():
    N,M=pin()
    ans=[1]+[0]*(N-1)
    check=[False]*3
    for i in range(M):
        p,m=pin()
        if p==1 and m!=0:
            if check[p-1]==False:
                ans[0]=m
                check[p-1]=True
            else:
                if ans[0]!=m:
                    print(-1)
                    return
        elif p==1 and m==0:
            print(-1)
            return
        elif p!=1:
            if check[p-1]==False:
                ans[p-1]=m
                check[p-1]=True
            else:
                if ans[p-1]!=m:
                    print(-1)
                    return
    a=""
    for i in range (M):
        a+=str(ans[i])
    print(int(a))
    
    
    

"""
def resolve():
    bingo=[list(pin()) for i in range(3)]
    check=[[0]*3 for j in range(3)]
    N=int(input())
    for i in range(N):
        b=int(input())
        for h in range(3):
            for w in range(3):
                if bingo[h][w]==b:
                    check[h][w]=1
    for i in range(3):
        a=check[i][0]*check[i][1]*check[i][2]
        b=check[0][i]*check[1][i]*check[2][i]
        if a or b:
            print("Yes")
            return
    c,d=1,1
    for i in range(3):
        c*=check[i][i]
        d*=check[i][2-i]
    if c or d:
        print("Yes")
        return
    print("No")
    return
"""


"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """41 7 46
26 89 2
78 92 8
5
6
45
16
57
17"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Solution (Python):
a11,a12,a13=(int(x) for x in input().split())
a21,a22,a23=(int(x) for x in input().split())
a31,a32,a33=(int(x) for x in input().split())
n=int(input())
list=[]
for i in range(n):
	list.append(int(input()))
s=set(list)

def ch(a,b,c,s):
	k=0
	if a in s:
		if b in s:
			if c in s:
				k=1
	return k
co=0
co+=ch(a11,a12,a13,s)
co+=ch(a21,a22,a23,s)
co+=ch(a31,a32,a33,s)
co+=ch(a11,a21,a31,s)
co+=ch(a12,a22,a32,s)
co+=ch(a13,a23,a33,s)
co+=ch(a11,a22,a33,s)
co+=ch(a13,a22,a31,s)
if co>0:
	print("Yes")
else:
	print("No")

Solution (Python):
b1 = list(map(int, input().split()))
b2 = list(map(int, input().split()))
b3 = list(map(int, input().split()))
b4 = [b1[0],b2[0],b3[0]]
b5 = [b1[1],b2[1],b3[1]]
b6 = [b1[2],b2[2],b3[2]]
b7 = [b1[0],b2[1],b3[2]]
b8 = [b1[2],b2[1],b3[0]]

N = int(input())
num = []
for i in range(N):
  num += [int(input())]

if set(b1) <= set(num) or set(b2) <= set(num) or set(b3) <= set(num) or set(b4) <= set(num) or set(b5) <= set(num) or set(b6) <= set(num) or set(b7) <= set(num) or set(b8) <= set(num):
  print("Yes")
else:
  print("No")

Solution (Python):


a = [list(map(int,input().split())) for _ in range(3)]
c = [a[0][0],a[0][1],a[0][2],a[1][0],a[1][1],a[1][2],a[2][0],a[2][1],a[2][2]]
n = int(input())
b = [int(input()) for _ in range(n)]


for i in range(n):
    if b[i] in c:
        c[c.index(b[i])] = 0

p = sum(c[:3])*sum(c[3:6])*sum(c[6:9])*sum(c[::3])*sum(c[1::3])*sum(c[2::3])*(c[0]+c[4]+c[8])*(c[2]+c[4]+c[6])
if p == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
card = []
for i in range(3):
    card.append(list(map(int,input().split())))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if card[j][k] == b[i]:
                card[j][k] = 0
flag = 'No'
if card[0][0] == card[0][1] == card[0][2] == 0:
    flag = 'Yes'
if card[1][0] == card[1][1] == card[1][2] == 0:
    flag = 'Yes'
if card[2][0] == card[2][1] == card[2][2] == 0:
    flag = 'Yes'
if card[0][0] == card[1][0] == card[2][0] == 0:
    flag = 'Yes'
if card[0][1] == card[1][1] == card[2][1] == 0:
    flag = 'Yes'
if card[0][2] == card[1][2] == card[2][2] == 0:
    flag = 'Yes'
if card[0][0] == card[1][1] == card[2][2] == 0:
    flag = 'Yes'
if card[0][2] == card[1][1] == card[2][0] == 0:
    flag = 'Yes'
print(flag)

Solution (Python):
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
b = []
for j in range(N):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                A[i][j] = 0
Answer = []
for i in range(3):
    if A[i][0:3] == [0,0,0]:
        Answer.append('Yes')
        break
    elif A[0][i] == A[1][i] and A[1][i] == A[2][i]:
        Answer.append('Yes')
        break
    elif A[0][0] == A[1][1] and A[1][1] == A[2][2]:
        Answer.append('Yes')
        break
    elif A[0][2] == A[1][1] and A[1][1] == A[2][0]:
        Answer.append('Yes')
        break
if len(set(Answer)) == 1:
    print('Yes')
else:
    print('No')

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

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

for p in range(3):
    for q in range(3):
        if card[p][q] in ls:
            card[p][q] = -1
        else:
            continue

flag = [0, 0, 0]

for j in range(3):
    if card[j] == [-1, -1, -1]:
        flag[0] = 1

for k in range(3):
    if card[0][k] == card[1][k] == card[2][k] == -1:
        flag[1] = 1

if card[0][0] == card[1][1] == card[2][2] == -1:
    flag[2] = 1

if card[0][2] == card[1][1] == card[2][0] == -1:
    flag[2] = 1

if sum(flag) == 0:
    print("No")
elif sum(flag) > 0:
    print("Yes")

Solution (Python):
A0 = list(map(int, input().split(" ")))
A1 = list(map(int, input().split(" ")))
A2 = list(map(int, input().split(" ")))

A = [A0, A1, A2]

M = [
    [False, False, False],
    [False, False, False],
    [False, False, False],
]

N = int(input())
for _ in range(N):
    b = int(input())
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if col == b:
                M[i][j] = True

flag = False
for row in M:
    if all(row):
        flag = True

for i in range(3):
    col = []
    for j in range(3):
        col.append(M[j][i])

    if all(col):
        flag = True

dia0 = []
dia1 = []
for i in range(3):
    dia0.append(M[i][i])
    dia1.append(M[i][2 - i])

if all(dia0):
    flag = True

if all(dia1):
    flag = True

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

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

B1 = [0,0,0]
B2 = [0,0,0]
B3 = [0,0,0]

n = input()
N = int(n)

for i in range(N):
  B = input()
  b = int(B)
  if b == A1[0]:
    B1[0] = 1
  elif b == A1[1]:
    B1[1] = 1
  elif b == A1[2]:
    B1[2] = 1
  elif b == A2[0]:
    B2[0] = 1
  elif b == A2[1]:
    B2[1] = 1
  elif b == A2[2]:
    B2[2] = 1
  elif b == A3[0]:
    B3[0] = 1
  elif b == A3[1]:
    B3[1] = 1
  elif b == A3[2]:
    B3[2] = 1




    
ans="No"

if B1[0]==1:
  if B1[1]==1:
    if B1[2]==1:
      ans = "Yes"
if B2[0]==1:
  if B2[1]==1:
    if B2[2]==1:
      ans = "Yes"
if B3[0]==1:
  if B3[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[0]==1:
    if B3[0]==1:
      ans = "Yes"
if B1[1]==1:
  if B2[1]==1:
    if B3[1]==1:
      ans = "Yes"
if B1[2]==1:
  if B2[2]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[2]==1:
  if B2[1]==1:
    if B3[0]==1:
      ans = "Yes"

print(ans)

Solution (Python):

import sys
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())
card = []
card.append(a11)
card.append(a12)
card.append(a13)
card.append(a21)
card.append(a22)
card.append(a23)
card.append(a31)
card.append(a32)
card.append(a33)
x = 'x'
inputs = [input() for i in range(n)]
for j in inputs:
    if(int(j) in card):
        index = card.index(int(j))
        card[index] = 'x'
if(card[0] == x and card[1] == x and card[2] == x):
    print('Yes')
    sys.exit()
if(card[3] == x and card[4] == x and card[5] == x):
    print('Yes')
    sys.exit()
if(card[6] == x and card[7] == x and card[8] == x):
    print('Yes')
    sys.exit()
if(card[0] == x and card[3] == x and card[6] == x):
    print('Yes')
    sys.exit()
if(card[1] == x and card[4] == x and card[7] == x):
    print('Yes')
    sys.exit()
if(card[2] == x and card[5] == x and card[8] == x):
    print('Yes')
    sys.exit()
if(card[0] == x and card[4] == x and card[8] == x):
    print('Yes')
    sys.exit()
if(card[2] == x and card[4] == x and card[6] == x):
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
import sys

A = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

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

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

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

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



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


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


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

for i in range(3):
    if A[i][0]==-1 and A[i][1]==-1 and A[i][2]==-1:
        print("Yes")
        sys.exit()
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()))


for j in range(len(a)):
    for k in range(len(a)):
        for u in range(len(b)):
            if a[j][k] == b[u]:
                a[j][k] = 0


if (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):
    print("Yes")
    exit()
elif (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):
    print("Yes")
    exit()

for y in range(len(a)):
    if a[y].count(0) == 3:
        print("Yes")
        exit()

print("No")

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A4 = [A1[0], A2[0], A3[0]]
A5 = [A1[1], A2[1], A3[1]]
A6 = [A1[2], A2[2], A3[2]]
A7 = [A1[0], A2[1], A3[2]]
A8 = [A1[2], A2[1], A3[0]]




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

flag = False
if len(b&set(A1)) == 3: flag = True
if len(b&set(A2)) == 3: flag = True
if len(b&set(A3)) == 3: flag = True
if len(b&set(A4)) == 3: flag = True
if len(b&set(A5)) == 3: flag = True
if len(b&set(A6)) == 3: flag = True
if len(b&set(A7)) == 3: flag = True
if len(b&set(A8)) == 3: flag = True
  
print('Yes' if flag else 'No')

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

def check():
    for b in b_n:
        for i in range(3):
            for j in range(3):
                if a[i][j] == b:
                    result[i][j] = 1
    yoko = [0]*3
    tate = [0]*3

    for i in range(3):
        for j in range(3):
            yoko[i] += result[i][j]
            tate[j] += result[i][j]
    for i in range(3):
        if yoko[i] == 3 or tate[i] == 3:
            print('Yes')
            return 0
    if result[0][0] + result[1][1] + result[2][2] ==3:
        print('Yes')
        return 0
    elif result[0][2] + result[1][1] + result[2][0] ==3:
        print('Yes')
        return 0
    print('No')
    return 0
check()

Solution (Python):
def bingo(C):
    if C[0]==C[1]==C[2] and C[0]==1:
        return True
    elif C[3]==C[4]==C[5] and C[3]==1:
        return True
    elif C[6]==C[7]==C[8] and C[6]==1:
        return True
    elif C[0]==C[3]==C[6] and C[0]==1:
        return True
    elif C[1]==C[4]==C[7] and C[1]==1:
        return True
    elif C[2]==C[5]==C[8] and C[2]==1:
        return True
    elif C[0]==C[4]==C[8] and C[0]==1:
        return True
    elif C[2]==C[4]==C[6] and C[2]==1:
        return True   
    else:
        return False

A=[]
for _ in range(3):
    x1,x2,x3=map(int, raw_input().split())
    A.append(x1)
    A.append(x2)
    A.append(x3)

B=[ 0 for _ in range(9) ]

N=input()

for _ in range(N):
    b=input()
    for i,x in enumerate(A):
        if b==x:
            B[i]=1
        

if bingo(B):
    print "Yes"
else:
    print "No"

Solution (Python):
ue = list(map(int, input().split()))
naka = list(map(int, input().split()))
sita = list(map(int, input().split()))
n = int(input())
b = [0] * n
for i in range(n):
    b[i] = int(input())

for i in b:
    ue = ['ok' if j == i else j for j in ue]
    naka = ['ok' if j == i else j for j in naka]
    sita = ['ok' if j == i else j for j in sita]

if ue[0]==ue[1]==ue[2] \
    or naka[0]==naka[1]==naka[2] \
    or sita[0]==sita[1]==sita[2] \
    or ue[0]==naka[0]==sita[0] \
    or ue[1]==naka[1]==sita[1] \
    or ue[2]==naka[2]==sita[2] \
    or ue[0]==naka[1]==sita[2] \
    or ue[2]==naka[1]==sita[0]:
    print('Yes')
else:
    print('No')

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

flag = False

for i in range(3):
    for i in range(3):
        if all([True if a_list[j][i] in b else False for j in range(3)]):
            if flag == False:
                print('Yes')
            flag = True
            break

if flag == False:
    for i in range(3):
        if all([True if a_list[i][j] in b else False for j in range(3)]):
            if flag == False:
                print('Yes')
            flag = True
            break

if flag == False:
    temp1 = [(0,0), (1,1), (2,2)]
    if all([True if a_list[i][j] in b else False for (i,j) in temp1]):
        print('Yes')
        flag = True

if flag == False:
    temp2 = [(0,2), (1,1), (2,0)]
    if all([True if a_list[i][j] in b else False for (i,j) in temp2]):
        print('Yes')
        flag = True
    
if flag == False:
    print('No')

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

aListCheck = []
for i in range(3):
  aListCheckRow = []
  for j in range(3):
    aListCheckRow.append(aList[i][j] in bList)
  aListCheck.append(aListCheckRow)

for i in range(3):
  if aListCheck[i][0] and aListCheck[i][1] and aListCheck[i][2]:
    print('Yes')
    exit()
  if aListCheck[0][i] and aListCheck[1][i] and aListCheck[2][i]:
    print('Yes')
    exit()
if aListCheck[0][0] and aListCheck[1][1] and aListCheck[2][2]:
  print('Yes')
  exit()
if aListCheck[0][2] and aListCheck[1][1] and aListCheck[2][0]:
  print('Yes')
  exit()

print('No')

Solution (Python):
N1=list(map(int,input().split()))
N2=list(map(int,input().split()))
N3=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
if b.count(N1[0])==b.count(N1[1])==b.count(N1[2])==1:
    print("Yes")
elif b.count(N2[0])==b.count(N2[1])==b.count(N2[2])==1 or b.count(N3[0])==b.count(N3[1])==b.count(N3[2])==1:
    print("Yes")
elif b.count(N1[0])==b.count(N2[0])==b.count(N3[0])==1 or  b.count(N1[1])==b.count(N2[1])==b.count(N3[1])==1 or b.count(N1[2])==b.count(N2[2])==b.count(N3[2])==1:
    print("Yes")
elif b.count(N1[0])==b.count(N2[1])==b.count(N3[2])==1 or b.count(N3[0])==b.count(N2[1])==b.count(N1[2])==1:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    YES="Yes"
    NO="No"

    A = []
    B = [[0]*3 for i in range(3)]
    for _ in range(3):
        l = list(map(int, input().split()))
        A.append(l)
    N = int(input())
    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    B[i][j] = 1
    for i in range(3):
        isBingoRow = True
        isBingoCol = True
        for j in range(3):
            isBingoRow = isBingoRow and (B[i][j] == 1)
            isBingoCol = isBingoCol and (B[j][i] == 1)
        if isBingoRow or isBingoCol:
            print(YES)
            return
    if B[0][0]==1 and B[1][1]==1 and B[2][2]==1:
        print(YES)
        return
    if B[0][2]==1 and B[1][1]==1 and B[2][0]==1:
        print(YES)
        return
    print(NO)

if __name__ == '__main__':
    main()

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

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

    if sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[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[0][2] == A[1][1] == A[2][0] == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):

import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    from collections import defaultdict
    A = XLMIIS(3)

    exists = defaultdict(lambda : False)

    N = II()
    for _ in range(N):
        exists[II()] = True
    

    
    for i in range(3):
        if exists[A[i][0]] and exists[A[i][1]] and exists[A[i][2]]:
            print('Yes')
            return
    
    for i in range(3):
        if exists[A[0][i]] and exists[A[1][i]] and exists[A[2][i]]:
            print('Yes')
            return
    
    if exists[A[0][0]] and exists[A[1][1]] and exists[A[2][2]]:
        print('Yes')
        return
    if exists[A[0][2]] and exists[A[1][1]] and exists[A[2][0]]:
        print('Yes')
        return
    print('No')
    return 
    

if __name__ == '__main__':
    main()

Solution (Python):
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))

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

for i in range(n):
  for j in range(3):
    if x[j] == a[i]:
      x[j] = 0
    if y[j] == a[i]:
      y[j] = 0
    if z[j] == a[i]:
      z[j] = 0
      

bingo = False

if max(x) == 0 or max(y) == 0 or max(z) == 0:
  bingo = True

for i in range(3):
  if x[i] == 0 and y[i] == 0 and z[i] == 0:
    bingo = True
    break

if x[0] == 0 and y[1] == 0 and z[2] == 0:
  bingo = True

if x[2] == 0 and y[1] == 0 and z[0] == 0:
  bingo = True


if bingo:
  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()))

check=[]
for i in range(3):
    for k,number in enumerate(a[i]):
        if number in b:
            check.append(1)
        else:
            check.append(0)

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

if check[6]==1:
    if check[7]==1 and check[8]==1:
        bingo_check=1


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

Solution (Python):
from itertools import product
data = [list(map(int, input().split())) for i in range(3)]
n = int(input())
bl = [int(input()) for _ in range(n)]
ok = [[0]*3 for _ in range(3)]

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



if sum(ok[0][:]) == 3 or sum(ok[1][:]) == 3 or sum(ok[2][:]) == 3 or (ok[0][0]+ok[1][0]+ok[2][0]) == 3 or (ok[0][1]+ok[1][1]+ok[2][1]) == 3 or (ok[0][2]+ok[1][2]+ok[2][2]) == 3 or (ok[0][0]+ok[1][1]+ok[2][2]) == 3 or (ok[0][2]+ok[1][1]+ok[2][0]) == 3:
    print('Yes')
else:
    print('No')

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

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            C[i][j]=1
if C[0][0]*C[0][1]*C[0][2]==1:
    print("Yes")
elif C[1][0]*C[1][1]*C[1][2]==1:
    print("Yes")
elif C[2][0]*C[2][1]*C[2][2]==1:
    print("Yes")
elif C[0][0]*C[1][0]*C[2][0]==1:
    print("Yes")
elif C[0][1]*C[1][1]*C[2][1]==1:
    print("Yes")
elif C[0][2]*C[1][2]*C[2][2]==1:
    print("Yes")
elif C[0][0]*C[1][1]*C[2][2]==1:
    print("Yes")
elif C[0][2]*C[1][1]*C[2][0]==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

bingo = np.zeros((3,3))
bin_bingo = np.zeros((3,3))

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



N = int(input())

for _ in range(N):
    num = int(input())
    bin_bingo = np.logical_or(bin_bingo, bingo == num)


lin1 = np.array([[True, True, True], [False, False, False], [False, False, False]])
lin2 = np.array([[False, False, False],[True, True, True], [False, False, False]])
lin3 = np.array([[False, False, False], [False, False, False], [True, True, True]])
col1 = lin1.T
col2 = lin2.T
col3 = lin3.T

sla1 = np.array([[True, False, False], [False, True, False], [False, False, True]])
sla2 = np.array([[False, False, True], [False, True, False], [True, False, False]])

def is_bingo(src, tmp):
    return (np.logical_and(src, tmp) == tmp).all()

flg = False
if is_bingo(bin_bingo, lin1):
    flg = True
elif is_bingo(bin_bingo, lin2):
    flg = True
elif is_bingo(bin_bingo, lin3):
    flg = True
elif is_bingo(bin_bingo, col1):
    flg = True
elif is_bingo(bin_bingo, col2):
    flg = True
elif is_bingo(bin_bingo, col3):
    flg = True
elif is_bingo(bin_bingo, sla1):
    flg = True
elif is_bingo(bin_bingo, sla2):
    flg = True

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

Solution (Python):
def resolve():
    A_list = []

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


    N = int(input())

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

    for i in b_list:
        for j in range(len(A_list)):
            for k in range(len(A_list[j])):
                if A_list[j][k] == i:
                    A_list[j][k] = 0 


    if A_list[0][0] == 0 and A_list[0][1] == 0 and A_list[0][2] == 0:
        print("Yes")
        return

    if A_list[1][0] == 0 and A_list[1][1] == 0 and A_list[1][2] == 0:
        print("Yes")
        return

 
    if A_list[2][0] == 0 and A_list[2][1] == 0 and A_list[2][2] == 0:
        print("Yes")
        return

    if A_list[0][0] == 0 and A_list[1][0] == 0 and A_list[2][0] == 0:
        print("Yes")
        return

    if A_list[0][1] == 0 and A_list[1][1] == 0 and A_list[2][1] == 0:
        print("Yes")
        return

    if A_list[0][2] == 0 and A_list[1][2] == 0 and A_list[2][2] == 0:
        print("Yes")
        return

    if A_list[0][0] == 0 and A_list[1][1] == 0 and A_list[2][2] == 0:
        print("Yes")
        return

    if A_list[0][2] == 0 and A_list[1][1] == 0 and A_list[2][0] == 0:
        print("Yes")
        return


    print("No")
    return

if __name__ == "__main__":
    resolve()