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):
l=[[]]*3
for k in range(3):
  l[k]=list(map(int,input().split()))
n=int(input())
ll=[[0]*3 for i in range(3)]
for k in range(n):
  i=int(input())
  for j in range(3):
    if i in l[j]:
      ll[j][l[j].index(i)]=1
a=0
if ll[0][0]==1:
  if ll[0][1]==1 and ll[0][2]==1:
    a=1
  if ll[1][1]==1 and ll[2][2]==1:
    a=1
  if ll[1][0]==1 and ll[2][0]==1:
    a=1
if ll[0][1]==1 and ll[1][1]==1 and ll[2][1]==1:
  a=1
if ll[0][2]==1:
  if ll[1][1]==1 and ll[2][0]==1:
    a=1
  if ll[1][2]==1 and ll[2][2]==1:
    a=1
if ll[1][0]==1:
  if ll[1][1]==1 and ll[1][2]==1:
    a=1
if ll[2][0]==1:
  if ll[2][1]==1 and ll[2][2]==1:
    a=1
if a==0:
  print("No")
else:
  print("Yes")

Solution (Python):









































































A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    x = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == x:
                A[i][j] = 0
flg = 0
for i in range(3):
    for j in range(3):
        if sum(A[i]) == 0:
            flg = 1
for j in range(3):
    s = 0
    for i in range(3):
        s += A[i][j]
    if s == 0:
        flg = 1
flg |= 0 == sum([A[i][i] for i in range(3)])
flg |= 0 == sum([A[2-i][i] for i in range(3)])
if flg:
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
for i in range(3):
         a.append( list(map(int,input().split())))
n = int(input())
b = [int(input()) for j in range(n)]
for k in range(3):
         for l in range(3):
                  for m in range(n):
                           if a[k][l] == b[m]:
                                    a[k][l] = -1
if a[0][0] == a[0][1] == a[0][2] == -1 or  a[1][0] == a[1][1] == a[1][2] == -1 or  a[2][0] == a[2][1] == a[2][2] == -1 or  a[0][0] == a[1][0] == a[2][0] == -1 or  a[0][1] == a[1][1] == a[2][1] == -1 or  a[0][2] == a[1][2] == a[2][2] == -1 or  a[0][0] == a[1][1] == a[2][2] == -1 or  a[0][2] == a[1][1] == a[2][0] == -1 :
         print("Yes")
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())
b = []
for _ in range(N):
    b.append(int(input()))

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

Solution (Python):
b = []
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
b.append(a1)
b.append(a2)
b.append(a3)
n = int(input())
c = [int(input()) for i in range(n)]
a = []
d = [[0 for i in range(3)] for j in range(3)]
flg = False
for i in c:
	for j in range(3):
		for k in range(3):
			if b[j][k] == i:
				d[j][k] = 1
	for l in range(3):
		if d[l][0] == 1 and d[l][1] == 1 and d[l][2] == 1:
			flg = True
		if d[0][l] == 1 and d[1][l] == 1 and d[2][l] == 1:
			flg = True
	if d[0][0] == 1 and d[1][1] == 1 and d[2][2] == 1:
		flg = True
	if d[0][2] == 1 and d[1][1] == 1 and d[2][0] == 1:
		flg = True
	if flg == True:
		print ("Yes")
		exit()
print ("No")

Solution (Python):

s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
s3 = list(map(int, input().split()))

n = (int)(input())
result = [[False, False, False], [False, False, False], [False, False, False]]

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

    if s1[0] == b:
        result[0][0] = True
    elif s1[1] == b:
        result[0][1] = True
    elif s1[2] == b:
        result[0][2] = True

    if s2[0] == b:
        result[1][0] = True
    elif s2[1] == b:
        result[1][1] = True
    elif s2[2] == b:
        result[1][2] = True

    if s3[0] == b:
        result[2][0] = True
    elif s3[1] == b:
        result[2][1] = True
    elif s3[2] == b:
        result[2][2] = True

if result[0][0] & result[0][1] & result[0][2]:
    print('Yes')
elif result[1][0] & result[1][1] & result[1][2]:
    print('Yes')
elif result[2][0] & result[2][1] & result[2][2]:
    print('Yes')
elif result[0][0] & result[1][0] & result[2][0]:
    print('Yes')
elif result[0][1] & result[1][1] & result[2][1]:
    print('Yes')
elif result[0][2] & result[1][2] & result[2][2]:
    print('Yes')
elif result[0][0] & result[1][1] & result[2][2]:
    print('Yes')
elif result[0][2] & result[1][1] & result[2][0]:
    print('Yes')
else:
    print('No')

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

N=int(input())

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

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

for i in range(3):
    temp=0
    for item in ans:
        temp+=item[i]
    if temp==3:
        print("Yes")
        exit()

if ans[0][0]+ans[1][1]+ans[2][2]==3 or ans[0][2]+ans[1][1]+ans[2][0]==3:
    print("Yes")
    exit()

print("No")

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

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

    flag = False
    for i in range(3):
        for j in range(3):
                if(j+2 < 3 and A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j+2 < 3 and A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
                if(i-2 >= 0 and j-2 >= 0 and A[i][j] == 0 and A[i-1][j-1] == 0 and A[i-2][j-2] == 0):
                    flag = True
                    break
                if(i-2 >= 0 and j+2 < 3 and A[i][j] == 0 and A[i-1][j+1] == 0 and A[i-2][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j-2 >= 0 and A[i][j] == 0 and A[i+1][j-1] == 0 and A[i+2][j-2] == 0):
                    flag = True
                    break
        if(flag):
            break

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

if __name__ == "__main__":
    main()

Solution (Python):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
r1 = {a11, a12, a13}
r2 = {a21, a22, a23}
r3 = {a31, a32, a33}
c1 = {a11, a21, a31}
c2 = {a12, a22, a32}
c3 = {a13, a23, a33}
cr1 = {a11, a22, a33}
cr2 = {a31, a22, a13}
A = [r1, r2, r3, c1, c2, c3, cr1, cr2]

n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
B = set(b)


for C in A:
    if C.issubset(B):
        print('Yes')
        quit()

print('No')

Solution (Python):
bingo = list(map(int, input().split()))
bingo.extend(list(map(int, input().split())))
bingo.extend(list(map(int, input().split())))

N = int(input())

res = "No"

for _ in range(N):
  num = int(input())

  for (index, value) in enumerate(bingo):
    if value == num:
      bingo[index] = 0



if bingo[0] == bingo[4] == bingo[8] == 0 or bingo[2] == bingo[4] == bingo[6] == 0:
  res = "Yes"

else:
  
  for i in range(3):
    if (bingo[i] == bingo[i+3] == bingo[i+6] == 0 or bingo[3 * i] == bingo[3 * i + 1] == bingo[3 * i + 2] == 0):
      res = "Yes"
      break
  
print(res)

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

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


for i in range(3):
    for j in range(3):
        if l[i][j] in bingo:
            l[i].pop(j)
            l[i].insert(j,0)


if len(set(l[0])) == 1 or len(set(l[1])) == 1 or len(set(l[2])) == 1:
    print('Yes')
    exit()

if l[0][0] == l[1][0] == l[2][0] or l[0][1] == l[1][1] == l[2][1] or l[0][2] == l[1][2] == l[2][2]:
    print('Yes')
    exit()

if l[0][0] == l[1][1] == l[2][2] or l[0][2] == l[1][1] == l[2][0]:
    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()))
N=int(input())
for i in range(N):
    b=int(input())
    if b in A1:
        x=A1.index(b)
        A1[x]=0
    elif b in A2:
        x=A2.index(b)
        A2[x]=0
    elif b in A3:
        x=A3.index(b)
        A3[x]=0
D=[sum(A1),sum(A2),sum(A3)]
D.append(A1[0]+A2[0]+A3[0])
D.append(A1[1]+A2[1]+A3[1])
D.append(A1[2]+A2[2]+A3[2])
D.append(A1[0]+A2[1]+A3[2])
D.append(A1[2]+A2[1]+A3[0])
if 0 in D:
    print("Yes")
else:print("No")

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

for k in b:
	for i in range(len(A)):
		for j in range(len(A[i])):
			if A[i][j] == k:
				A[i][j]=0

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

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

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            ans[i][j] = 1



if ans[0][0] + ans[0][1] + ans[0][2] == 3:
    print('Yes')
elif ans[0][0] + ans[1][0] + ans[2][0] == 3:
    print('Yes')
elif ans[0][0] + ans[1][1] + ans[2][2] == 3:
    print('Yes')
elif ans[1][0] + ans[1][1] + ans[1][2] == 3:
    print('Yes')
elif ans[2][0] + ans[2][1] + ans[2][2] == 3:
    print('Yes')
elif ans[0][1] + ans[1][1] + ans[2][1] == 3:
    print('Yes')
elif ans[0][2] + ans[1][2] + ans[2][2] == 3:
    print('Yes')
elif ans[0][2] + ans[1][1] + ans[2][0] == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
up = list(input().split())
mid = list(input().split())
down = list(input().split())

table = [up, mid, down]

nums = []
while True:
    try:
        nums.append(input())
    except EOFError:
        break

for i in range(3):
  for j in range(3):
    if table[i][j] in nums:
      table[i][j] = 'T'

flag = False

for i in range(3):
  if table[i].count('T') == 3:
    print('Yes')
    flag = True
    if flag == True:
      break

if flag == False:
  if table[0][0]=='T' and table[1][0]=='T' and table[2][0]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][1]=='T' and table[1][1]=='T' and table[2][1]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][2]=='T' and table[1][2]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True

if flag == False:
  if table[0][0]=='T' and table[1][1]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][2]=='T' and table[1][1]=='T' and table[2][0]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  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 = [int(input()) for i in range(N)]

flag = True
for i in range(3):
    if (A1[0] in B) and (A1[1] in B) and (A1[2] in B):
        print('Yes')
        flag = False
        break
    elif (A2[0] in B) and (A2[1] in B) and (A2[2] in B):
        print('Yes')
        flag = False
        break
    elif (A3[0] in B) and (A3[1] in B) and (A3[2] in B):
        print('Yes')
        flag = False
        break
    elif (A1[i] in B) and (A2[i] in B) and (A3[i] in B):
        print('Yes')
        flag = False
        break 
    elif (A1[0] in B) and (A2[1] in B) and (A3[2] in B):
        print('Yes')
        flag = False
        break 
    elif (A1[2] in B) and (A2[1] in B) and (A3[0] in B):
        print('Yes')
        flag = False
        break 
if flag == True:
    print('No')

Solution (Python):
A1=input().split()
A2=input().split()
A3=input().split()
N = int(input())
b = list(input() for i in range(N))

ListA = [A1,A2,A3]
for i in range(3):
  if set(ListA[i]).issubset(b):
      print("Yes")
      exit()

B1 = [A1[0],A2[0],A3[0]]
B2 = [A1[1],A2[1],A3[1]]
B3 = [A1[2],A2[2],A3[2]]
ListB = [B1,B2,B3]

for i in range(3):
    if set(ListB[i]).issubset(b):
      print("Yes")
      exit()
    
C1 = [A1[0],A2[1],A3[2]]
C2 = [A1[2],A2[1],A3[0]]
ListC = [C1,C2]

for i in range(2):
    if set(ListC[i]).issubset(b):
      print("Yes")
      exit()

print("No")

Solution (Python):
a = [int(j) for i in range(3) for j in input().split(' ')]
n = int(input())
nn = [int(input()) for i in range(n)]

cnt = 0
for ni in nn:
  if ni in a:
    cnt += 1
    a[a.index(ni)] = 0

judge = "No"
for i in range(3):
  if sum(a[i::3])==0 or sum(a[i*3:i*3+3])==0:
    judge = "Yes"
    
if sum(a[::4])==0 or (a[2]+a[4]+a[6])==0:
  judge = "Yes"
  
print(judge)

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

A = [a11,a12,a13,a21,a22,a23,a31,a32,a33]


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

if \
(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])  == 0:
  print("Yes")
else:
  print("No")

Solution (Python):



yoko_1 = [int(i) for i in input().split()]
yoko_2 = [int(i) for i in input().split()]
yoko_3 = [int(i) for i in input().split()]
tate_1 = [yoko_1[0], yoko_2[0], yoko_3[0]]
tate_2 = [yoko_1[1], yoko_2[1], yoko_3[1]]
tate_3 = [yoko_1[2], yoko_2[2], yoko_3[2]]
naname_1 = [yoko_1[0], yoko_2[1], yoko_3[2]]
naname_2 = [yoko_1[2], yoko_2[1], yoko_3[0]]

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

def bingo(card, call):
    cnt = 0
    for i in card:
        for j in call:
            if i == j:
                cnt += 1
                break
    if cnt == 3:
        return 1
    else:
        return 0

if bingo(yoko_1, bs) + \
bingo(yoko_2, bs) + \
bingo(yoko_3, bs) + \
bingo(tate_1, bs) + \
bingo(tate_2, bs) + \
bingo(tate_3, bs) + \
bingo(naname_1, bs) + \
bingo(naname_2, bs) > 0:
    print("Yes")
else:
    print("No")

Solution (Python):
ans="No"
A=3
t=[0]*A
x=[0]*A
y=[0]*A
for i in range(A):
    t[i], x[i], y[i] = map(int, input().split())


N=int(input())
S=[]
for _ in range(N):
  S.append(input())

S1=[int(s) for  s in S]
for i in range(A):
  if t[i] in S1:
    t[i]=0
  if x[i] in S1:
    x[i]=0
  if y[i] in S1:
    y[i]=0

if t.count(0)==3:
  ans="Yes"
if x.count(0)==3:
  ans="Yes"
if y.count(0)==3:
  ans="Yes"
if t[0]==0 and x[1]==0 and y[2]==0:
  ans="Yes"
if t[2]==0 and x[1]==0 and y[0]==0:
  ans="Yes"
if t[0]==0 and x[0]==0 and y[0]==0:
  ans="Yes"
if t[1]==0 and x[1]==0 and y[1]==0:
  ans="Yes"
if t[2]==0 and x[2]==0 and y[2]==0:
  ans="Yes"
print(ans)

Solution (Python):
a = [input().split() for l in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans = 'No'
for i in range(3):
        for j in range(3):
                a[i][j] = int(a[i][j])
                for k in range(N):
                        if a[i][j] == b[k]:
                                a[i][j] = 0
for i in range(3):
        if a[i][0] + a[i][1] + a[i][2] == 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):
def haha():    
    A=[]
    for i in range(3):
        A.extend(list(map(int, input().split())))
    N = int(input())
    n=[]
    while N>0:
        inp = int(input())
        if inp in A:
            n.append(inp)
        N-=1

    A = [A[:3],A[3:6],A[6:9], [A[0], A[4], A[8]], [A[2], A[4], A[6]], [A[0], A[3], A[6]], [A[1], A[4], A[7]], [A[2], A[5], A[8]]]

    for ele in A:
        if ele[0] in n and ele[1]in n and ele[2]in n:
            return 'Yes'
    return 'No'

print(haha())

Solution (Python):
a = [list(map(int,input().split())) for i in range(3)]
for i in range(int(input())):
  i = int(input())
  bo = True
  while(bo):
    for k,a_1 in enumerate(a[0]):
      if a_1 == i:
        a[0][k] = None
        bo = False
    for k,a_2 in enumerate(a[1]):
      if a_2 == i:
        a[1][k] = None
        bo = False
    for k,a_3 in enumerate(a[2]):
      if a_3 == i:
        a[2][k] = None
        bo = False
    bo = False
s = "No"
while(s == "No"):
  if (a[0][0] == a[1][1]) and (a[1][1] == a[2][2]):
    s = "Yes"
  if (a[2][0] == a[1][1]) and (a[1][1] == a[0][2]):
    s = "Yes"
  for l in a:
    if len(set(l)) == 1:
      s = "Yes"
  for i in range(3):
    if len(set([a[0][i], a[1][i], a[2][i]])) == 1:
      s = "Yes"
  break
print(s)

Solution (Python):
def b():
    a = {}
    for i in range(3):
        arr = list(map(int, input().split()))
        for j in range(3):
            a[i, j] = arr[j]

    N = int(input())
    for n in range(N):
        b = int(input())
        keys = [k for k, v in a.items() if v == b]
        
        for l in keys:
            a[l] = 0

    
    for i in range(3):
        if (
            (a[i, 0] + a[i, 1] + a[i, 2] == 0)
            or (a[0, i] + a[1, i] + a[2, i] == 0)
        ):
            print('Yes')
            return
    if (
        (a[0, 0] + a[1, 1] + a[2, 2] == 0)
        or (a[0, 2] + a[1, 1] + a[2, 0] == 0)
    ):
        print('Yes')
        return

    print('No')
    return



b()

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


x = int(input())
for i in range(x):
  n = int(input())
  for x in range(3):
    for y in range(3):
      if l[x][y] == n:
        l[x][y] = -1

isBingo = False
if l[0][0] * l[0][1] * l[0][2] == -1:
  isBingo = True
if l[1][0] * l[1][1] * l[1][2] == -1:
  isBingo = True
if l[2][0] * l[2][1] * l[2][2] == -1:
  isBingo = True
if l[0][0] * l[1][0] * l[2][0] == -1:
  isBingo = True
if l[0][1] * l[1][1] * l[2][1] == -1:
  isBingo = True
if l[0][2] * l[1][2] * l[2][2] == -1:
  isBingo = True
if l[0][0] * l[1][1] * l[2][2] == -1:
  isBingo = True
if l[2][0] * l[1][1] * l[0][2] == -1:
  isBingo = True
if isBingo:
  print("Yes")
else:
  print("No")

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

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:
                bingo[j][k] = 0
flag = False
for i in range(3):
    tmp = 0
    for j in range(3):
        tmp += bingo[i][j]
    if tmp == 0:
        flag = True
for j in range(3):
    tmp = 0
    for i in range(3):
        tmp += bingo[i][j]
    if tmp == 0:
        flag = True
if bingo[0][0] + bingo[1][1] + bingo[2][2] == 0:
    flag = True
if bingo[0][2] + bingo[1][1] + bingo[2][0] == 0:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
a=[]
for t in range(3):
    d,e,f=map(int,input('').split(' '))
    a.append([d,e,f])

n=int(input(''))
b=[]
for t in range(n):
    r=int(input(''))
    b.append(r)

hit=[[0,0,0],[0,0,0],[0,0,0]]

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

h=0
if hit[0][0]==1 and hit[0][1]==1 and hit[0][2]==1:
    h=1
elif hit[1][0]==1 and hit[1][1]==1 and hit[1][2]==1:
    h=1
elif hit[2][0]==1 and hit[2][1]==1 and hit[2][2]==1:
    h=1
elif hit[0][0]==1 and hit[1][0]==1 and hit[2][0]==1:
    h=1
elif hit[0][1]==1 and hit[1][1]==1 and hit[2][1]==1:
    h=1
elif hit[0][2]==1 and hit[1][2]==1 and hit[2][2]==1:
    h=1
elif hit[0][0]==1 and hit[1][1]==1 and hit[2][2]==1:
    h=1
elif hit[0][2]==1 and hit[1][1]==1 and hit[2][0]==1:
    h=1
else:
    h=0

if h==1:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    ans=[[1,2,3],[4,5,6],[7,8,9]]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i]==A[j][k]:
                    ans[j][k]="."
    for i in range(3):
        if len(set(ans[i]))==1:
            print(YES)
            exit()
        if ans[0][i]==ans[1][i]==ans[2][i]:
            print(YES)
            exit()
    if ans[0][0]==ans[1][1]==ans[2][2]:
        print(YES)
        exit()
    if ans[0][2]==ans[1][1]==ans[2][0]:
        print(YES)
        exit()
    print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):
arr = []
ans = []
for i in range(3):
  arr.extend(list(map(int,input().split())))
N = int(input())
for j in range(N):
  num = int(input())
  if num in arr:
    ans.append(arr.index(num))
ans = set(ans)
if (set([0,1,2])<=ans)or(set([3,4,5])<=ans)or(set([6,7,8])<=ans)or(set([0,3,6])<=ans)or(set([1,4,7])<=ans)or(set([2,5,8])<=ans)or(set([0,4,8])<=ans)or(set([2,4,6])<=ans):
  print('Yes')
else:
  print('No')

Solution (Python):
def main():
    A=[]
    for _ in range(3):
        a1,a2,a3=map(int,input().split())
        A.append(a1); A.append(a2); A.append(a3)
    Flag=[False]*9
    n=int(input())
    B=[int(input().strip()) for _ in range(n)]
    for b in B:
        for i,a in enumerate(A):
            if b==a:
                Flag[i]=True
    if Flag[0] and Flag[1] and Flag[2]:
        return 'Yes'
    if Flag[3] and Flag[4] and Flag[5]:
        return 'Yes'
    if Flag[6] and Flag[7] and Flag[8]:
        return 'Yes'
    if Flag[0] and Flag[3] and Flag[6]:
        return 'Yes'
    if Flag[1] and Flag[4] and Flag[7]:
        return 'Yes'
    if Flag[2] and Flag[5] and Flag[8]:
        return 'Yes'
    if Flag[0] and Flag[4] and Flag[8]:
        return 'Yes'
    if Flag[2] and Flag[4] and Flag[6]:
        return 'Yes'
    return 'No'

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

Solution (Python):
import numpy as np

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

N = int(input())
s = [int(input()) for i in range(N)]

for i in s:
    grid = np.where(grid==i,0,grid)
    

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

Solution (Python):


def main():
    a = []
    for _ in range(3):
        x, y, z = map(int, input().split())
        a.append((x, y, z))
    n = int(input())
    b = []
    for _ in range(n):
        b.append(int(input()))

    g = [[0 for _ in range(3)] for _ in range(3)]

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


    bingo = False
    
    for i in range(3):
        if sum(g[i]) == 3:
            bingo = True
    
    if g[0][0]+g[1][0]+g[2][0] == 3:
        bingo = True
    if g[0][1]+g[1][1]+g[2][1] == 3:
        bingo = True
    if g[0][2]+g[1][2]+g[2][2] == 3:
        bingo = True 
    
    if g[0][0]+g[1][1]+g[2][2] == 3:
        bingo = True
    if g[0][2]+g[1][1]+g[2][0] == 3:
        bingo = True
    
    if bingo:
        print('Yes')
    else:
        print('No')
main()

Solution (Python):
A = [0]*3
for i in range(0,3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
 
c = 0
while c < N:
    for i in range(0,3):
      for j in range(0,3):
        if b[c] == A[i][j]:
          A[i][j] = 0
    c += 1
            
 
hoge = [0]*3                
for i in range(0,3):
  for j in range(0,3):
    hoge[i] += A[i][j]
 
fuga = [0]*3
for i in range(0,3):
  for j in range(0,3):
    fuga[i] += A[j][i]
    
 
hogehoge = A[0][0] + A[1][1] + A[2][2]
fugafuga = A[0][2] + A[1][1] + A[0][2]
 
if hoge[0] == 0:
    print("Yes")
elif hoge[1] == 0:
    print("Yes")
elif hoge[2] == 0:
    print("Yes")
elif fuga[0] == 0:
    print("Yes") 
elif fuga[1] == 0:
    print("Yes") 
elif fuga[2] == 0:
    print("Yes") 
elif hogehoge == 0:
  print("Yes")
elif fugafuga == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
bingo=[]
for i in range(3):
    a_1,a_2,a_3=map(int,input().split())
    bingo.append(a_1)
    bingo.append(a_2)
    bingo.append(a_3)
n=int(input())
for j in range(n):
    b=int(input())
    for k in range(9):
        if(bingo[k]==b):
            bingo[k]=0
a_1=[]
a_1.append(bingo[0])
a_1.append(bingo[1])
a_1.append(bingo[2])
a_2=[]
a_2.append(bingo[3])
a_2.append(bingo[4])
a_2.append(bingo[5])
a_3=[]
a_3.append(bingo[6])
a_3.append(bingo[7])
a_3.append(bingo[8])
a_4=[]
a_4.append(bingo[0])
a_4.append(bingo[3])
a_4.append(bingo[6])
a_5=[]
a_5.append(bingo[1])
a_5.append(bingo[4])
a_5.append(bingo[7])
a_6=[]
a_6.append(bingo[2])
a_6.append(bingo[5])
a_6.append(bingo[8])
a_7=[]
a_7.append(bingo[0])
a_7.append(bingo[4])
a_7.append(bingo[8])
a_8=[]
a_8.append(bingo[2])
a_8.append(bingo[4])
a_8.append(bingo[6])
if(a_1==[0,0,0]):
    print("Yes")
elif(a_2==[0,0,0]):
    print("Yes")
elif(a_3==[0,0,0]):
    print("Yes")
elif(a_4==[0,0,0]):
    print("Yes")
elif(a_5==[0,0,0]):
    print("Yes")
elif(a_6==[0,0,0]):
    print("Yes")
elif(a_7==[0,0,0]):
    print("Yes")
elif(a_8==[0,0,0]):
    print("Yes")
else:
    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)]
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):
    yoko=0
    for j in range(3):
        if a[i][j]==0:
            yoko+=1
            if yoko == 3:
                print("Yes")
                exit()
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()
for i in range(3):
    tate=0
    for j in range(3):
        if a[j][i]==0:
            tate+=1
            if tate == 3:
                print("Yes")
                exit()
print("No")

Solution (Python):
import sys
bingo = [[],[],[]]
 
for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yes")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yes")
    sys.exit()
  else:
    print("No")
    sys.exit()
print("No")

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())

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

import numpy as np
A = np.array([A1, A2, A3])

bingo = np.zeros((3, 3), dtype=bool)
for b in B:
  bingo += (A == b)

if bingo.all(axis=0).any() or \
   bingo.all(axis=1).any() or \
   np.diag(bingo).all() or \
   np.diag(np.fliplr(bingo)).all():
  print('Yes')
else:
  print('No')

Solution (Python):

def check(A):
    for i in A:
       if i.count("x") == 3:
           return True
    for n in range(3):
        if A[0][n] == "x" and A[1][n] == "x" and  A[2][n] == "x":
            return True
    if A[0][0] == "x" and A[1][1] == "x" and A[2][2] == "x":
        return True
    if A[0][2] == "x" and A[1][1] == "x" and A[2][0] == "x":
        return True
    
    return False
    
        
        
                
     

A = []
for _ in range(3):
    A.append([int(i) for i in input().split(" ")])
N = int(input())
b = [int(input()) for _ in range(N)] 



for i in b:
    for a in A:
        if i in a:
            index = a.index(i)
            a[index] = "x"

if check(A):
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
a=[[int(j) for j in input().split()] for i in range(3)]
a=np.array(a)

N=int(input())
for n in range(N):
    s=int(input())
    a=np.where(a-s==0,0,a)

for a1 in zip(*a):
    if len(set(a1))==1:
        print("Yes")
        exit(0)
for a1 in a:
    if len(set(a1))==1:
        print("Yes")
        exit(0)
x=np.diag(a)
if len(set(x))==1:
    print("Yes")
    exit(0)
y=np.diag(np.rot90(a))

if len(set(y))==1:
    print("Yes")
    exit(0)
print("No")