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):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
ans = [[0,0,0] for i in range(3)]



for i in range(3):
  for j in range(3):
    for k in b:
      if(a[i][j] == k):
        ans[i][j] = 1
        break
if(ans[0][0] + ans[0][1] + ans[0][2] == 3 or ans[0][0] + ans[1][0] + ans[2][0] == 3 or ans[1][0] + ans[1][1] + ans[1][2] == 3 or ans[2][0] + ans[2][1] + ans[2][2] == 3 or ans[0][2] + ans[1][2] + ans[2][2] == 3 or ans[0][1] + ans[1][1] + ans[2][1] == 3 or ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3):
  print("Yes")
else:
  print("No")

Solution (Python):
r1 = list(map(int,input().split()))
r2 = list(map(int,input().split()))
r3 = list(map(int,input().split()))
c1 = [r1[0],r2[0],r3[0]]
c2 = [r1[1],r2[1],r3[1]]
c3 = [r1[2],r2[2],r3[2]]
d1 = [r1[0],r2[1],r3[2]]
d2 = [r1[2],r2[1],r3[0]]
l = [r1,r2,r3,c1,c2,c3,d1,d2]

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

def bingo(num):
    for i in l:
        try:
            i.remove(num)
        except:
            pass

        for j in l:
            if j == []:
                return True
    return False

for i in b:
    if bingo(i):
        print("Yes")
        exit()
else:
    print("No")

Solution (Python):
import itertools
def main():
    A=[list(map(int,input().split())) for _ in range(3)]
    n=int(input())
    B=list(int(input()) for _ in range(n))
    B=sorted(B)
    C=itertools.combinations(B,3)
    if n<3:
        print('No')
        return
    
    ans=[]
    ans.append(sorted(A[0]))
    ans.append(sorted(A[1]))
    ans.append(sorted(A[2]))
    ans.append(sorted([a[0] for a in A]))
    ans.append(sorted([a[1] for a in A]))
    ans.append(sorted([a[2] for a in A]))
    ans.append(sorted([A[0][0],A[1][1],A[2][2]]))
    ans.append(sorted([A[0][2],A[1][1],A[2][0]]))
    for c in C:
        if list(c) in ans:
            print('Yes')
            return
    print('No')
    
main()

Solution (Python):
line1 = input().split(" ")
line2 = input().split(" ")
line3 = input().split(" ")

result1 = []
result2 = []
result3 = []

for i in range(3):
  result1.append("0")
  result2.append("0")
  result3.append("0")

call_sum = int(input())

for j in range(call_sum):
  call_num = int(input())
  for i in range(3):
    if call_num == int(line1[i]):
      result1[i] = "1"
      break
    if call_num == int(line2[i]):
      result2[i] = "1"
      break
    if call_num == int(line3[i]):
      result3[i] = "1"
      break
while(1):
  if result1[0] == result1[1] == result1[2] == "1" or result2[0] == result2[1] == result2[2] == "1" or result3[0] == result3[1] == result3[2] == "1":
    print("Yes")
    break
  elif result1[0] == result2[1] == result3[2] == "1" or result1[2] == result2[1] == result3[0] == "1":
    print("Yes")
    break
  for j in range(3):
    end_flg = False
    if result1[j] == result2[j] == result3[j] == "1":
      print("Yes")
      end_flg = True
      break
  if end_flg:
    break
  print("No")
  break

Solution (Python):
X = []
Y = []
Z = []
for i in range(3):
    x, y, z = map(int, input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)
N = int(input())

b = list(map(int, [input() for i in range(N)]))

for i in range(N):
    
    if X[0] == b[i]:
        X[0] = 'OK'
    if X[1] == b[i]:
        X[1] = 'OK'
    if X[2] == b[i]:
        X[2] = 'OK'
    if Y[0] == b[i]:
        Y[0] = 'OK'
    if Y[1] == b[i]:
        Y[1] = 'OK'
    if Y[2] == b[i]:
        Y[2] = 'OK'
    if Z[0] == b[i]:
        Z[0] = 'OK'
    if Z[1] == b[i]:
        Z[1] = 'OK'
    if Z[2] == b[i]:
        Z[2] = 'OK'

if (X[0] == X[1] == X[2]
    or Y[0] == Y[1] == Y[2]
    or Z[0] == Z[1] == Z[2]
    or X[0] == Y[0] == Z[0]
    or X[1] == Y[1] == Z[1]
    or X[2] == Y[2] == Z[2]
    or X[0] == Y[1] == Z[2]
    or X[2] == Y[1] == Z[0]):
    print('Yes')
else:
    print('No')

Solution (Python):
A = []
check = []

for i in range(3):
	a, b, c = map(int, input().split())
	A.append(a)
	check.append(False)
	A.append(b)
	check.append(False)
	A.append(c)
	check.append(False)

N = int(input())

for i in range(N):
	b = int(input())
	for j in range(len(A)):
		if A[j] == b:
			check[j] = True

c = False
for i in range(3):
	if check[i*3] and check[i*3+1] and check[i*3+2]:
		c = True

for i in range(3):
	if check[i] and check[i+3] and check[i+6]:
		c = True

if check[0] and check[4] and check[8]:
	c = True

if check[2] and check[4] and check[6]:
	c = True

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

Solution (Python):
import itertools

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

A = list(itertools.chain.from_iterable(A))

X = []

for c in b:
    if c in A:
        X.append(A.index(c))

if (0 in X and 1 in X and 2 in X) or \
        (3 in X and 4 in X and 5 in X) or \
        (6 in X and 7 in X and 8 in X) or \
        (0 in X and 3 in X and 6 in X) or \
        (1 in X and 4 in X and 7 in X) or \
        (2 in X and 5 in X and 8 in X) or \
        (0 in X and 4 in X and 8 in X) or \
        (2 in X and 4 in X and 6 in X):
    print('Yes')
else:
    print('No')

Solution (Python):


import numpy as np


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

    result = np.zeros((3, 3))

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

    for i in range(3):
        if all(result[i, :]):
            print('Yes')
            exit(0)
    for i in range(3):
        if all(result[:, i]):
            print('Yes')
            exit(0)
    if all([result[0, 0], result[1, 1], result[2, 2]]):
        print('Yes')
        exit(0)
    if all([result[0, 2], result[1, 1], result[2, 0]]):
        print('Yes')
        exit(0)
    print('No')


if __name__ == "__main__":
    main()

Solution (Python):

def yoko(bingo,b):
    i,j = 0,0
    isbingo = False
    for i in [0,1,2]:
        for j in [0,1,2]:
            if bingo[i][j] in b:
                if j==2:
                    return True
            else:
                break
    return False

def tate(bingo,b):
    i,j = 0,0
    isbingo = False
    for j in [0,1,2]:
        for i in [0,1,2]:
            if bingo[i][j] in b:
                if i==2:
                    return True
            else:
                break
    return False

def naname(bingo,b):
    i,j = 0,0
    isbingo = False
    for i,j in zip([0,1,2],[0,1,2]):
        if bingo[i][j] in b:
            if i==2:
                return True
        else:
            break
    for i,j in zip([0,1,2],[2,1,0]):
        if bingo[i][j] in b:
            if i==2:
                return True
        else:
        	break
    return False

row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))
n = int(input())
i = 0
b = []
while(i < n):
  b.append(int(input()))
  i += 1

bingo = []
bingo.append(row1)
bingo.append(row2)
bingo.append(row3)
if (tate(bingo,b))|(yoko(bingo,b))|(naname(bingo,b)):
    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 j in range(N):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 0

col1 = A[0][0]+A[1][0]+A[2][0]
col2 = A[0][1]+A[1][1]+A[2][1]
col3 = A[0][2]+A[1][2]+A[2][2]
dig1 = A[0][0]+A[1][1]+A[2][2]
dig2 = A[2][0]+A[1][1]+A[0][2]
if sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 or col1==0 or col2==0 or col3==0 or dig1==0 or dig2==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(" ")))
N=int(input())
b=[]

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

allnum=[]
allnum.append(a1)
allnum.append(a2)
allnum.append(a3)


bingo=[[0,0,0],[0,0,0],[0,0,0]]

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

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

if(bingo[2][0] and bingo[1][1] and bingo[0][2]):
    print("Yes")
    exit()
print("No")

Solution (Python):
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
maru=111
flag=0
n=int(input())
for k in range(0,n):
    e=int(input())
    for i in range(0,3):    
        if e==a[i]:
            a[i]=maru
        if e==b[i]:
            b[i]=maru
        if e==c[i]:
            c[i]=maru

for j in range(0,3):
    if a[j]==b[j] and b[j]==c[j]:
        if c[j]==maru:
            flag=1
            
if a[0]==a[1] and a[1]==a[2]:
    if a[0]==maru:
        flag=1
if b[0]==b[1] and b[1]==b[2]:
    if b[0]==maru:
        flag=1
if c[0]==c[1] and c[1]==c[2]:
    if c[0]==maru:
        flag=1

if a[0]==b[1] and b[1]==c[2]:
    if c[2]==maru:
        flag=1

if a[2]==b[1] and b[1]==c[0]:
    if c[0]==maru:
        flag=1



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

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

check = sum([[False, False, False] for _ in range(3)], [])

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

N = int(input())

result = "No"

for i in range(N):
    b = int(input())
    if b in card:
        check[card.index(b)] = True
    for e in ls:
        if all([check[el] for el in e]):
            result = "Yes"
            break

print(result)

Solution (Python):

import numpy as np

A_list = []
for i in range(3):
    A, B, C = map(int, input().split())
    A_list.append([A, B, C])
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A_list[j][k] == b:
                A_list[j][k] = 0

A_array = np.array(A_list)

ans = "No"
if 0 in np.sum(A_array, axis=0):
    ans = "Yes"

if 0 in np.sum(A_array, axis=1):
    ans = "Yes"

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

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

print(ans)

Solution (Python):
def main():
    lst = []
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    n = int(input())


    for _ in range(n):
        temp = int(input())
        if temp in lst:
            i = lst.index(temp)
            lst[i] = False
    answer = "No"
    if (all((not lst[0],not lst[1],not lst[2]))) or (all(( not lst[3],not lst[4],not lst[5]))) or (all((not lst[6],not lst[7],not lst[8]))):
        answer = "Yes"
    if (all((not lst[0],not lst[3], not lst[6]))) or (all((not lst[1],not lst[4],not lst[7]))) or (all((not lst[2],not lst[5],not lst[8]))):
        answer = "Yes"
    if (all((not lst[0],not lst[4],not lst[8]))) or (all((not lst[2],not lst[4],not lst[6]))):
        answer = "Yes"
    print(answer)










if __name__ == '__main__':
    main()

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

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

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

ans = False
if A[0][0] == A[1][1] == A[2][2] == 0:
    ans = True

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


for i in range(3):
    cnt = 0
    for j in range(3):
        if A[j][i] == 0:
            cnt += 1
    if cnt == 3:
        ans = True


for i in range(3):
    cnt = 0
    for j in range(3):
        if A[i][j] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

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

Solution (Python):
import math

def main():
    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 _ in range(n)]

    bingo = [[0]*3]+[[0]*3]+[[0]*3]

    A = [A1, A2, A3]
    row_sum1 = 0
    row_sum2 = 0
    row_sum3 = 0
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if B[i]==A[j][k]:
                    bingo[j][k] = 1
    for i in range(len(bingo)):
        if sum(bingo[i])==3:
            print('Yes')
            return
        row_sum1 += bingo[i][0]
        row_sum2 += bingo[i][1]
        row_sum3 += bingo[i][2]

    if bingo[0][0] == bingo[1][1] == bingo[2][2] == 1 or bingo[0][2] == bingo[1][1] == bingo[2][0] == 1:
        print('Yes')
        return
    if row_sum1==3 or row_sum2==3 or row_sum3==3:
        print('Yes')
        return
    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
def inputs(): return [int(x) for x in input().split()]
a1 = inputs()
a2= inputs()
a3=inputs()
n = int(input())
N = []
for i in range(n):
  N.append(int(input()))
cnt= [0]*8
for j in range(3):
  if a1[j] in N:
    cnt[0] +=1
for j in range(3):
  if a2[j] in N:
    cnt[1] +=1
for j in range(3):
  if a3[j] in N:
    cnt[2] +=1
for j in range(3):
  if a1[j] in N and a2[j] in N and a3[j] in N:
    cnt[3+j] +=3
if a1[0] in N and a2[1] in N and a3[2] in N:
  cnt[6] +=3
if a1[2] in N and a2[1] in N and a3[0] in N:
  cnt[7] +=3
if 3 in cnt:
  print("Yes")
else:
  print("No")

Solution (Python):

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


N = int(input())


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


for i in range(0, len(bingoArr)):
    for y in range(0, len(bingoArr[i])):
        for t in target:
            if bingoArr[i][y] == t:
                bingoArr[i][y] = -1
res = 'No'
if bingoArr[0][0] == -1 and bingoArr[0][1] == -1 and bingoArr[0][2] == -1:
    res = 'Yes'

if bingoArr[1][0] == -1 and bingoArr[1][1] == -1 and bingoArr[1][2] == -1:
    res = 'Yes'

if bingoArr[2][0] == -1 and bingoArr[2][1] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][0] == -1 and bingoArr[1][0] == -1 and bingoArr[2][0] == -1:
    res = 'Yes'

if bingoArr[0][1] == -1 and bingoArr[1][1] == -1 and bingoArr[2][1] == -1:
    res = 'Yes'

if bingoArr[0][2] == -1 and bingoArr[1][2] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][0] == -1 and bingoArr[1][1] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][2] == -1 and bingoArr[1][1] == -1 and bingoArr[2][0] == -1:
    res = 'Yes'

print(res)

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

def bingo():
    tA = A
    for i in range(S):
        for j in range(S):
            if(tA[i][j] in b):
                tA[i][j] = True
            else:
                tA[i][j] = False

    TA = list(zip(*tA))
    for i in range(S):
        if(tA[i].count(True)==S):return True
        if(TA[i].count(True)==S):return True
    
    if([tA[i][i] for i in range(S)].count(True)==S): return True
    if([tA[i][S-i-1] for i in range(S)].count(True)==S): return True
    return False

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

Solution (Python):
import numpy as np

A = [ list(map(int,input().split(" "))) for i in range(3)]
N = int(input())
X = np.ones((3,3))
for num in range(N):
  b_num = int(input())
  for i in range(3):
    for j in range(3):
      X[i,j] = X[i,j] * ( A[i][j] - b_num )
      
sum = 1
for n in range(3):
  sum = sum * ( X[n,0]**2 + X[n,1]**2 + X[n,2]**2 )
  sum = sum * ( X[0,n]**2 + X[1,n]**2 + X[2,n]**2 )
sum = sum * ( X[0,0]**2 + X[1,1]**2 + X[2,2]**2 )
sum = sum * ( X[0,2]**2 + X[1,1]**2 + X[2,0]**2 )

if sum == 0:
  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()]
n=int(input())
b=set()
for c in range(n):
    b.add(int(input()))
t=list(range(8))
t[1]=set(a1)
t[2]=set(a2)
t[3]=set(a3)
t[4]={a1[0],a2[0],a3[0]}
t[5]={a1[1],a2[1],a3[1]}
t[6]={a1[2],a2[2],a3[2]}
t[7]={a1[0],a2[1],a3[2]}
t[0]={a1[2],a2[1],a3[0]}

k=0
for c in range(8):
    if t[c]<=b:
        k=1
if k==1:
    print('Yes')
else:
    print('No')

Solution (Python):
import itertools

a=[]

for i in range(3):
    a.append(list(map(int,input().split())))

temp=[]
temp.append((a[0][0],a[0][1],a[0][2]))
temp.append((a[1][0],a[1][1],a[1][2]))
temp.append((a[2][0],a[2][1],a[2][2]))
temp.append((a[0][0],a[1][0],a[2][0]))
temp.append((a[0][1],a[1][1],a[2][1]))
temp.append((a[0][2],a[1][2],a[2][2]))
temp.append((a[0][0],a[1][1],a[2][2]))
temp.append((a[0][2],a[1][1],a[2][0]))

n=int(input())

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

res=list(itertools.permutations(num,3))
flag=0
for i in range(len(temp)):
    for j in range(len(res)):
        if temp[i] == res[j]:
            flag=1
            break
        else:
            continue

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

Solution (Python):
A = []
for i in range(3):
  A += list(map(int, input().split()))
N = int(input())
b = []
for i in range(N):
  b += [int(input())]
S1 = {A[0], A[1], A[2]}
S2 = {A[3], A[4], A[5]}
S3 = {A[6], A[7], A[8]}
S4 = {A[0], A[3], A[6]}
S5 = {A[1], A[4], A[7]}
S6 = {A[2], A[5], A[8]}
S7 = {A[0], A[4], A[8]}
S8 = {A[2], A[4], A[6]}
flg = 0
if S1 < set(b): flg = 1
if S2 < set(b): flg = 1
if S3 < set(b): flg = 1
if S4 < set(b): flg = 1
if S5 < set(b): flg = 1
if S6 < set(b): flg = 1
if S7 < set(b): flg = 1
if S8 < set(b): flg = 1
print('Yes' if flg == 1 else 'No')

Solution (Python):
yoko1 = list(map(int,input().split()))
yoko2 = list(map(int,input().split()))
yoko3 = list(map(int,input().split()))
n = int(input())
bingono = []
for _ in range(n):
    bingono.append(int(input()))
for num in bingono:
    for i in range(0,3):
        if yoko1[i] == num:
            yoko1[i] = True
        if yoko2[i] == num:
            yoko2[i] = True
        if yoko3[i] == num:
            yoko3[i] = True
if yoko1.count(True)==3 or yoko2.count(True)==3 or yoko3.count(True)==3:
    print("Yes")
    exit()
for i in range(0,3):
    if yoko1[i] == True and yoko2[i] == True and yoko3[i] == True:
        print("Yes")
        exit()
if yoko1[0] == True and yoko2[1] == True and yoko3[2] == True:
    print("Yes")
    exit()
if yoko1[2] == True and yoko2[1] == True and yoko3[0] == True:
    print("Yes")
    exit()
print("No")

Solution (Python):


bingo = []
for count in range(0,3):
    A = list(map(int,input().split()))
    bingo.append(A)

bingo1 = [0] * 3
bingo2 = [0] * 3
bingo3 = [0] * 3
N = int(input())

for count in range(0,N):
    inp = int(input())
    for count3 in range(3):
        bi = bingo[count3]
        for count2 in range(3):
            if bi[count2] == inp:
                if count3 == 0:
                    bingo1[count2] = 1
                if count3 == 1:
                    bingo2[count2] = 1
                if count3 ==2 :
                    bingo3[count2] = 1
bingF = False

for count in range(3):
    
    if bingo1[count] == 1 and bingo2[count] == 1 and bingo3[count] == 1:
        bingF = True


if bingo1[0] == 1 and bingo1[1] == 1 and bingo1[2] == 1:
    bingF = True
if bingo2[0] == 1 and bingo2[1] == 1 and bingo2[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo3[1] == 1 and bingo3[2] == 1:
    bingF = True


if bingo1[0] == 1 and bingo2[1] == 1 and bingo3[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo2[1] == 1 and bingo1[2] == 1:
    bingF = True

if bingF == False:
    print("No")
else:
    print("Yes")

Solution (Python):
A_list = []

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

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

N = int(input())
flag=True

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

  tmp = my_index(A_list, num, -100)
  if tmp != -100:
    A_list[tmp] = -1
  
  if ((A_list[0] == A_list[3]) and (A_list[0] == A_list[6]) and (A_list[3] == A_list[6])) or \
     ((A_list[1] == A_list[4]) and (A_list[1] == A_list[7]) and (A_list[4] == A_list[7])) or \
     ((A_list[2] == A_list[5]) and (A_list[2] == A_list[8]) and (A_list[5] == A_list[8])) or \
     ((A_list[0] == A_list[4]) and (A_list[0] == A_list[8]) and (A_list[4] == A_list[8])) or \
     ((A_list[2] == A_list[4]) and (A_list[2] == A_list[6]) and (A_list[4] == A_list[6])) or \
     ((A_list[0] == A_list[1]) and (A_list[0] == A_list[2]) and (A_list[1] == A_list[2])) or \
     ((A_list[3] == A_list[4]) and (A_list[3] == A_list[5]) and (A_list[4] == A_list[5])) or \
     ((A_list[6] == A_list[7]) and (A_list[6] == A_list[8]) and (A_list[7] == A_list[8])):
    print("Yes")
    flag=False
    break

if flag:
  print("No")

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

ins = []
for i in range(n):
    b = int(input())
    if b in a:
        ins.append(a.index(b))

okp = [(0,1,2), (3,4,5), (6,7,8) ,(0,3,6), (1,4,7), (2,5 ,8), (0,4,8), (2,4,6)]
f = "No"
for x, y, z in okp:
    if x in ins and y in ins and z in ins:
        f = "Yes"
        break

print(f)

Solution (Python):
import numpy as np
import sys

A = np.zeros((3, 3), dtype=np.int64)
for i in range(3):
    l, m, n = map(int, input().split())
    A[i][0] = l
    A[i][1] = m
    A[i][2] = n
N = int(input())
b = []
for i in range(N):
    k = int(input())
    b.append(k)
for k in range(N):
    for i in range(3):
        for j in range(3):
            if b[k] == A[i][j]:
                A[i][j] = 0


row = np.sum(A, axis=1)
for i in range(3):
    if row[i] == 0:
        print('Yes')
        sys.exit()


col = np.sum(A, axis=0)
for i in range(3):
    if col[i] == 0:
        print('Yes')
        sys.exit()

c = 0
for i in range(3):
    c += A[i][i]
if c == 0:
    print('Yes')
    sys.exit()

c = 0
for i in range(3):
    c += A[3-i-1][i]
if c == 0:
    print('Yes')
    sys.exit()

print('No')

Solution (Python):
import numpy as np
A=list(list(map(int, input().split())) for _ in range(3))
N=int(input())
B=list(int(input()) for _ in range(N))
a=np.array(A)
c=a.flatten()
C=c.tolist()

for c in range(len(C)):
    for b in range(len(B)):
        if C[c]==B[b]:
            C[c]=0

if (sum(C[:3])==0) | (sum(C[3:6])==0) | (sum(C[6:9])==0):
    print("Yes")
elif (C[0]+C[3]+C[6]==0) | (C[1]+C[4]+C[7]==0) | (C[2]+C[5]+C[8]==0):
    print("Yes")
elif (C[0]+C[4]+C[8]==0) | (C[2]+C[4]+C[6]==0): 
    print("Yes")
else:
    print("No")

Solution (Python):


def solve():
    s1 = list(map(int,input().split()))
    s2 = list(map(int,input().split()))
    s3 = list(map(int,input().split()))
    s4 = [s[0] for s in [s1,s2,s3]]
    s5 = [s[1] for s in [s1,s2,s3]]
    s6 = [s[2] for s in [s1,s2,s3]]
    s7 = [s[i] for i,s in zip([0,1,2], [s1,s2,s3])]
    s8 = [s[i] for i,s in zip([2,1,0], [s1,s2,s3])]
    S = set(int(input()) for _ in range(int(input())))
    if any(set(s).issubset(S) for s in [s1,s2,s3,s4,s5,s6,s7,s8]):
        return 'Yes'
    else:
        return 'No'

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

Solution (Python):
b = [0] * 9


def hantei():
    for i in range(3):
        if b[i * 3] == 1 and b[i * 3 + 1] == 1 and b[i * 3 + 2] == 1:
            return True
    for i in range(3):
        if b[i] == 1 and b[i + 3] == 1 and b[i + 6] == 1:
            return True
    if b[0] == 1 and b[4] == 1 and b[8] == 1:
        return True
    if b[2] == 1 and b[4] == 1 and b[6] == 1:
        return True
    return False


a = [0] * 9
[a[0], a[1], a[2]] = input().split()
[a[3], a[4], a[5]] = input().split()
[a[6], a[7], a[8]] = input().split()
a = [int(i) for i in a]

n = int(input())

for i in range(n):
    c = int(input())
    for j in range(len(a)):
        if a[j] == c:
            b[j] = 1

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

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):
'''
Created on Mar 1, 2020

@author: dell
'''
arr=[]
for i in range(3):
    a=list(map(int,input().split()))
    arr.append(a)
n=int(input())
f=0
lst=[]
for i in range(n):
    a=int(input())
    lst.append(a)
if(arr[0][0] in lst and arr[1][1] in lst and arr[2][2] in lst):
    print("Yes")
elif(arr[0][2] in lst and arr[1][1] in lst and arr[2][0] in lst):
    print("Yes")
else:
    for i in range(3):
        f=0
        for j in range(3):
            if(arr[i][j] not in lst):
                f=1
        if(f==0):
            print("Yes")
            break
if(f==1):
    for i in range(3):
        f=0
        for j in range(3):
            if(arr[j][i] not in lst):
                f=1
        if(f==0):
            print("Yes")
            break
if(f==1):
    print("No")

Solution (Python):
A = []

for _ in range(3):
  tmp = map(int, input().split())
  A += tmp

N = int(input())

b = []

for _ in range(N):
  b.append(int(input()))

Bingo=[]
  
for bb in b:
  if bb not in A:
    continue;
  Bingo.append(A.index(bb)+1)

if ((1 in Bingo) and (2 in Bingo) and (3 in Bingo)) or\
((4 in Bingo) and (5 in Bingo) and (6 in Bingo)) or\
((7 in Bingo) and (8 in Bingo) and (9 in Bingo)) or\
((1 in Bingo) and (4 in Bingo) and (7 in Bingo)) or\
((2 in Bingo) and (5 in Bingo) and (8 in Bingo)) or\
((3 in Bingo) and (6 in Bingo) and (9 in Bingo)) or\
((1 in Bingo) and (5 in Bingo) and (9 in Bingo)) or\
((3 in Bingo) and (5 in Bingo) and (7 in Bingo)):
  print("Yes")
else:
  print("No")

Solution (Python):



import numpy

def main():
  card = []
  bingo = numpy.zeros((3, 3))
  for i in range(3):
    card.append(list(map(int, input().split())))
  card = numpy.array(card)
  n = int(input())
  for _ in range(n):
    b = int(input())
    for i in range(3):
      for j in range(3):
        if card[i, j] == b:
          bingo[i, j]=1

  l, r = 0, 0
  for i in range(3):
    if sum(bingo[i, :]) == 3 or sum(bingo[:, i]) == 3:
      print('Yes')
      return 
    l += bingo[i, i]
    r += bingo[i, 2-i]
  if l == 3 or r == 3:
    print('Yes')
    return 
  print('No')
  


if __name__=='__main__':
  main()

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

card = [[False for _ in range(3)] for _ in range(3)]

for b in b_array:
    for i in range(3):
        for j in range(3):
            if num_card[i][j] == b:
                card[i][j] = True

bingo = False

for i in range(3):
    if all(card[i]):
        bingo = True
        break
    if all((card[0][i], card[1][i], card[2][i])):
        bingo = True
        break

if all([card[i][i] for i in range(3)]):
    bingo = True

if all([card[i][2-i] for i in range(3)]):
    bingo = True

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

Solution (Python):
def solve():
    A = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    for b in [int(input()) for _ in range(n)]:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    A[i][j] = 0
    for i in range(3):
        if sum(A[i]) == 0:
            return "Yes"
    A = list(zip(*A[::-1]))
    for i in range(3):
        if sum(A[i]) == 0:
            return "Yes"
    if A[0][0] + A[1][1] + A[2][2] == 0 or A[2][0] + A[1][1] + A[0][2] == 0:
        return "Yes"
    return "No"
print(solve())

Solution (Python):
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

A = [read_int() for _ in range(3)]
N = read_int()[0]
B = [read_int()[0] for _ in range(N)]


bingo = [[0, 1, 2],[3,4,5], [6,7,8], [0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
def solve():
    for b in B:
        for row in A:
            pos = ind_or_f(row, b)
            if pos != -1:
                row[pos] = -1
                break
    for bb in bingo:
        flag = True
        for b in bb:
            if A[b // 3][b % 3] != -1:
                flag = False
            if not flag:
                break
        if flag == True:
            return "Yes"
    return "No"

def ind_or_f(l, x, default=-1):
    return l.index(x) if x in l else default

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

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

a = []
a.append(A1)
a.append(A2)
a.append(A3)

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

out = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for t in b:
  for m in range(3):
    for n in range(3):
      if a[m][n] == t :
        out[m][n] = 1

if (out[0][0]==out[1][1]==out[2][2] and out[0][0]== 1 )or \
(out[0][0]==out[1][0]==out[2][0] and out[0][0]== 1 ) or \
(out[0][2]==out[1][1]==out[2][0] and out[0][2]== 1 ) or \
(out[0][1]==out[1][1]==out[2][1] and out[0][1]== 1 ) or \
(out[0][2]==out[1][2]==out[2][2] and out[0][2]== 1 ) or \
(out[0][0]==out[0][1]==out[0][2] and out[0][0]== 1 ) or \
(out[1][0]==out[1][1]==out[1][2] and out[1][0]== 1 ) or \
(out[2][0]==out[2][1]==out[2][2] and out[2][0]== 1 ):
  print('Yes')
else:
  print('No')