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


lst_empty=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(3):
    for j in range(3):
        for k in b:
            if lst[i][j]==k:
                lst_empty[i][j]="x"
ans="No"
for i in lst_empty:
    if i[0]==i[1]==i[2]=="x":
        ans="Yes"
for j in list(zip(*lst_empty)):
    if j[0]==j[1]==j[2]=="x":
        ans="Yes"
if lst_empty[0][0]==lst_empty[1][1]==lst_empty[2][2]=="x" or lst_empty[0][2]==lst_empty[1][1]==lst_empty[2][0]=="x":
    ans="Yes"
print(ans)

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

for i in range(N):
    b = int(input())
    for row in card:
        if b in row:
            row[row.index(b)] = 0

def f():
    for row in card:
        if sum(row) == 0:
            return True
    
    for x in range(3):
        if sum([card[0][x], card[1][x], card[2][x]]) == 0:
            return True
    
    if sum([card[0][0], card[1][1], card[2][2]]) == 0:
        return True
    
    if sum([card[2][0], card[1][1], card[0][2]]) == 0:
        return True

    return False

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

Solution (Python):
card=[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 card[j][k]==b[i]:
                card[j][k]=0
if (card[0][0]==card[0][1]==card[0][2]==0) or (card[1][0]==card[1][1]==card[1][2]==0) or (card[2][0]==card[2][1]==card[2][2]==0) or (card[0][0]==card[1][0]==card[2][0]==0) or (card[0][1]==card[1][1]==card[2][1]==0)  or (card[0][2]==card[1][2]==card[2][2]==0) or (card[0][0] == card[1][1] == card[2][2] == 0) or (card[2][0]==card[1][1]==card[0][2]==0):
    print('Yes')
else:
    print('No')

Solution (Python):
a = [list(input().split()) for _ in range(3)]
check = [[0,0,0] for _ in range(3)]
n = int(input())
b = [] * n
for _ in range(n):
    c = input()
    b.append(c)

for i in range(n):
    for y in range(3):
        if b[i] in a[y]:
            check[y][a[y].index(b[i])] = 1
ans = 'No'
for k in range(3):
    if check[k][0] * check[k][1] * check[k][2] == 1:
        ans = 'Yes'
        break
    elif check[0][k] * check[1][k] * check [2][k] ==1:
        ans = 'Yes'
        break
if check[0][0] * check[1][1] * check[2][2] == 1 or check[0][2] * check[1][1] * check[2][0] == 1:
    ans = 'Yes'
print(ans)

Solution (Python):
Bingo=[0]*9
correct=[]
A=list(map(int,input().split()))
for i in range(3):
    correct.append(A[i])
A=list(map(int,input().split()))
for i in range(3):
    correct.append(A[i])
A=list(map(int,input().split()))
for i in range(3):
    correct.append(A[i])
N=int(input())
for i in range(N):
    a=int(input())
    for j in range(9):
        if a==correct[j]:
            Bingo[j]=1
            break
if Bingo[0]==Bingo[1]==Bingo[2]==1:
    print("Yes")
elif Bingo[3]==Bingo[4]==Bingo[5]==1:
    print("Yes")
elif Bingo[6]==Bingo[7]==Bingo[8]==1:
    print("Yes")
elif Bingo[0]==Bingo[3]==Bingo[6]==1:
    print("Yes")
elif Bingo[1]==Bingo[4]==Bingo[7]==1:
    print("Yes")
elif Bingo[2]==Bingo[5]==Bingo[8]==1:
    print("Yes")
elif Bingo[0]==Bingo[4]==Bingo[8]==1:
    print("Yes")
elif Bingo[2]==Bingo[4]==Bingo[6]==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import math
A = list(map(int,"\n".join([input() for i in range(3)]).strip().split()))
N = int(input())
B = [int(input()) for i in range(N)]
size = 3
punched = set()

corrects = []

corrects += [{i + size*j for i in range(size)} for j in range(size)]

corrects += [{j + size*i for i in range(size)} for j in range(size)]

corrects += [{i + size*i for i in range(size)}]
corrects += [{(size - 1 - i) + size*i for i in range(size)}]

def punch(b, A, punched):
    for i in range(len(A)):
        if b == A[i]: punched.add(i)
          
for b in B:
    punch(b, A, punched)
    
for correct in corrects:
    if correct.issubset(punched):
        print("Yes")
        break
else:
  	print("No")

Solution (Python):
import itertools as it
dic={}
bing=[[0 for i in range(3)] for j in range(3)]
for i in range(3):
    f=list(map(int,input().split()))
    for each in f:
        dic.update({each:(i,f.index(each))})
n=int(input())
for i in range(n):
    m=int(input())
    if m in dic.keys():
        place=dic[m]
        bing[place[0]][place[1]]=1
flag=False
code="000102101112202122"
code=code+code[::-1]
code=code+"001122021120"

for i in range(8):
    code_sep=code[6*i:6*i+6]
    p=1
    for j in range(3):
        cords=code_sep[2*j:2*j+2]
        p*=bing[int(cords[0])][int(cords[1])]
    if p==1:
        flag=True
        break
    
print("Yes")if flag else print("No")

Solution (Python):

def evalList(a, b):
    try:
        i = a.index(b)
        a[i] = 0
    except ValueError:
        pass


def evalBingo(i, j, k):
    return True if sum([i, j, k]) == 0 else False


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())
    evalList(a1, b)
    evalList(a2, b)
    evalList(a3, b)

isBingo = (
    evalBingo(a1[0], a1[1], a1[2]) or
    evalBingo(a2[0], a2[1], a2[2]) or
    evalBingo(a3[0], a3[1], a3[2]) or
    evalBingo(a1[0], a2[1], a3[2]) or
    evalBingo(a3[0], a2[1], a1[2]) or
    evalBingo(a1[0], a2[0], a3[0]) or
    evalBingo(a1[1], a2[1], a3[1]) or
    evalBingo(a1[2], a2[2], a3[2])
)

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7


def bingo(c):
    for i in range(3):
        flag = [False for _ in range(3)]
        for j in range(3):
            if c[i][j]:
                flag[j] = True
        if flag[0] and flag[1] and flag[2]:
            return True
    for i in range(3):
        flag = [False for _ in range(3)]
        for j in range(3):
            if c[j][i]:
                flag[j] = True
        if flag[0] and flag[1] and flag[2]:
            return True
    flag = [False for _ in range(3)]
    for i in range(3):
        if c[i][i]:
            flag[i] = True
    if flag[0] and flag[1] and flag[2]:
        return True
    flag = [False for _ in range(3)]
    for i in range(3):
        if c[i][2-i]:
            flag[i] = True
    if flag[0] and flag[1] and flag[2]:
        return True
    return False


a = [LIST() for _ in range(3)]
c = [[0 for _ in range(3)] for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    d = -1
    e = -1
    for i in range(3):
        if b in a[i]:
            d = i
            e = a[i].index(b)
    if d != -1:
        c[d][e] = 1
    if bingo(c):
        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()))
a = a1 + a2 + a3

n = int(input())

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

l = []
for x in a:
    if x in b:
        l.append('o')
    else:
        l.append('x')

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

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a1.extend(a2)
a3 = list(map(int, input().split()))
a1.extend(a3)

n = int(input())

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

l = []
for x in a1:
    if x in b:
        l.append('o')
    else:
        l.append('x')

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

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

box = [[0] * 3 for _ in range(3)]

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

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

Solution (Python):
A=[]
b=[]
c=[[0,0,0],[0,0,0],[0,0,0]]
d=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    x,y,z=map(int,input().split())
    A.append([x,y,z])

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
            d[j][i] = 1

if [1,1,1] in c:
    print('Yes')
elif [1,1,1] in d:
    print('Yes')
elif (c[0][0]+c[1][1]+c[2][2] == 3) or (c[0][2]+c[1][1]+c[2][0] == 3):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a = [list(map(int, input().rstrip('\n').split())) for _ in range(3)]
    n = int(input().rstrip('\n'))
    for _ in range(n):
        b = int(input().rstrip('\n'))
        for i in range(3):
            for j in range(3):
                if a[i][j] == b:
                    a[i][j] = -1
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == -1:
            print("Yes")
            exit()
        elif a[0][i] == a[1][i] == a[2][i] == -1:
            print("Yes")
            exit()
    if a[0][0] == a[1][1] == a[2][2] == -1:
        print("Yes")
        exit()
    elif a[0][2] == a[1][1] == a[2][0] == -1:
        print("Yes")
        exit()
    print("No")


if __name__ == '__main__':
    solve()

Solution (Python):
def bingo_check():
    from collections import defaultdict
    import sys
    A = []
    pos = {}
    for i in range(3):
        a1, a2, a3 = list(map(int, input().split()))
        A += [[a1, a2, a3]]
        pos[a1] = (i+1, 1)
        pos[a2] = (i+1, 2)
        pos[a3] = (i+1, 3)

    checked = defaultdict(lambda: False)
    N = int(input())
    for _ in range(N):
        b = int(input())
        if pos.get(b):
            checked[pos[b]] = True
    
    
    for i in range(1, 4):
        
        if checked[(i, 1)] and checked[(i, 2)] and checked[(i, 3)]:
            return "Yes"
        
        if checked[(1, i)] and checked[(2, i)] and checked[(3, i)]:
            return "Yes"
            

    
    if checked[(1, 1)] and checked[(2, 2)] and checked[(3, 3)]:
        return "Yes"
    if checked[(1, 3)] and checked[(2, 2)] and checked[(3, 1)]:
        return "Yes"
    
    return "No"

print(bingo_check())

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

flg = 0
for i in range(3):
    if (a[i][0] in b) and (a[i][1] in b) and (a[i][2] in b):
        print('Yes')
        flg = 1
        break
    elif (a[0][i] in b) and (a[1][i] in b) and (a[2][i] in b):
        print('Yes')
        flg = 1
        break
    
if flg == 1:
    pass
elif (a[0][0] in b) and (a[1][1] in b) and (a[2][2] in b):
    print('Yes')
elif (a[0][2] in b) and (a[1][1] in b) and (a[2][0] in b):
    print('Yes')
else:
    print('No')

Solution (Python):
A=[]
for i in range(3):
  a=list(map(int,input().split()))
  A+=a
n=int(input())
C=[0]*9
for i in range(n):
  b=int(input())
  for j in range(9):
    if b==A[j]:
         C[j]+=1
if min(C[0:3])>0:
  print('Yes')
elif min(C[3:6])>0:
  print('Yes')
elif min(C[6:9])>0:
  print('Yes')
elif min(C[0::3])>0:
  print('Yes')
elif min(C[1::3])>0:
  print('Yes')
elif min(C[2::3])>0:
  print('Yes')
elif min(C[::4])>0:
  print('Yes')
elif min(C[2],C[4],C[6])>0:
  print('Yes')
else:
  print('No')

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(9):
        if b == a[i // 3][i % 3]:
            a[i // 3][i % 3] = 0
flag = True
if a[0][0] == a[0][1] == a[0][2] == 0:
    flag = False
if a[1][0] == a[1][1] == a[1][2] == 0:
    flag = False
if a[2][0] == a[2][1] == a[2][2] == 0:
    flag = False
if a[0][0] == a[1][0] == a[2][0] == 0:
    flag = False
if a[0][1] == a[1][1] == a[2][1] == 0:
    flag = False
if a[0][2] == a[1][2] == a[2][2] == 0:
    flag = False
if a[0][0] == a[1][1] == a[2][2] == 0:
    flag = False
if a[0][2] == a[1][1] == a[2][0] == 0:
    flag = False
print('YNeos' [flag::2])

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(9):
        if b == a[i // 3][i % 3]:
            a[i // 3][i % 3] = 0
flag = False
if a[0][0] == a[0][1] == a[0][2] == 0:
    flag = True
if a[1][0] == a[1][1] == a[1][2] == 0:
    flag = True
if a[2][0] == a[2][1] == a[2][2] == 0:
    flag = True
if a[0][0] == a[1][0] == a[2][0] == 0:
    flag = True
if a[0][1] == a[1][1] == a[2][1] == 0:
    flag = True
if a[0][2] == a[1][2] == a[2][2] == 0:
    flag = True
if a[0][0] == a[1][1] == a[2][2] == 0:
    flag = True
if a[0][2] == a[1][1] == a[2][0] == 0:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

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

    N = int(input())
    for _ in range(N):
        a = int(input())
        for i in range(9):
            if B[i] == a:
                B[i] = 0

    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],
        ]
    
    ans = 'No'
    
    for a, b, c in bingo:
        if B[a] == 0 and B[b] == 0 and B[c] == 0:
            ans = 'Yes'

    return ans

print(solve())

Solution (Python):
def check_bng(t):
	c = 0
	for i in range(3):
		if t[i][0] + t[i][1] + t[i][2] == -3:
			c = 1
		if t[0][i] + t[1][i] + t[2][i] == -3:
			c = 1
	if t[0][0] + t[1][1] + t[2][2] == -3 or t[2][0] + t[1][1] + t[0][2] == -3:
		c = 1

	return c

def check(b,t):
	for i in range(3):
		if t[i].count(b) == 1:
			t[i][t[i].index(b)] = -1
	return t

if __name__ == '__main__':
	A1 = [int(a) for a in input().split()]
	A2 = [int(a) for a in input().split()]
	A3 = [int(a) for a in input().split()]
	N = int(input())

	t = [A1, A2, A3]

	nlst = []
	for i in range(N):
		check(int(input()),t)

	if check_bng(t) == 1:
		print('Yes')
	else:
		print('No')

Solution (Python):
def main():
    A = []
    for _ in range(3):
        a = map(int,input().split())
        A += a
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for i in range(N):
        for j in range(9):
            if A[j] == B[i]:
                A[j] = -1
    ans = False
    
    for i in range(3):
        if A[i] == -1 and A[i + 3] == -1 and A[i + 6] == -1 :
            ans = True
    
    for i in range(3):
        if A[3 * i] == - 1 and A[3 * i + 1] == -1 and A[3 * i + 2] == -1 :
            ans = True
    
    for i in [2, 4]:
        if A[4] == -1 and A[4 - i] == -1 and A[4 + i] == -1 :
            ans = True
    if ans :
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1, A2, A3]
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))

AA = [[False, False, False],
[False, False, False],
[False, False, False]]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            AA[i][j] = True

if AA[0][0] and AA[0][1] and AA[0][2]:
    print('Yes')
elif AA[1][0] and AA[1][1] and AA[1][2]:
    print('Yes')
elif AA[2][0] and AA[2][1] and AA[2][2]:
    print('Yes')
elif AA[0][0] and AA[1][0] and AA[2][0]:
    print('Yes')
elif AA[0][1] and AA[1][1] and AA[2][1]:
    print('Yes')
elif AA[0][2] and AA[1][2] and AA[2][2]:
    print('Yes')
elif AA[0][0] and AA[1][1] and AA[2][2]:
    print('Yes')
elif AA[0][2] and AA[1][1] and AA[2][0]:
    print('Yes')
else:
    print('No')

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

for i in range(N):
    inp=input()
    for j in range(3):
        for h in range(3):
            if bingo[j][h]==inp:
                bingo[j][h]=0

Ans = "No"
for i in range(3):
    if sum([int(x) for x in bingo[i]])==0:
        Ans ="Yes"

for i in range(3):
    if sum([int(row[i]) for row in bingo])==0:
        Ans="Yes"

if int(bingo[0][0])+int(bingo[1][1])+int(bingo[2][2])==0:
    Ans="Yes"
    
if int(bingo[2][0])+int(bingo[1][1])+int(bingo[0][2])==0:
    Ans="Yes"
print(Ans)

Solution (Python):
import numpy as np
A = []
C = []
counts = [0]*8
for i in range(3):
  inp = input().split()
  A.append(inp)
  C.append(inp)
A = np.array(A)
for i in range(3):
  C.append(list(A[:,i]))
C.append([A[0,0],A[1,1],A[2,2]])
C.append([A[0,2],A[1,1],A[2,0]])

N = int(input())
for i in range(N):
  b = input()
  for i, c in enumerate(C):
    if b in c:
      counts[i] += 1
if max(counts)==3:
  print('Yes')
else:
  print('No')

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

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 0
        if A2[j] == i:
            A2[j] = 0
        if A3[j] == i:
            A3[j] = 0

flag = False
A = [A1,A2,A3]
for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    sum_ = 0
    for j in range(3):
        sum_ += A[j][i]
    if sum_ == 0:
        flag = True

if A1[0] + A2[1] + A3[2] == 0:
    flag = True
if A1[2] + A2[1] + A3[0] == 0:
    flag = True
print('Yes' if flag else 'No')

Solution (Python):
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=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j in range(len(a_list)):
    for k in range(len(a_list[j])):
      if a_list[j][k] == b_i:
        a_list[j][k] = -1
    
if ((a_list[0][0]==-1 and a_list[0][1] == -1 and a_list[0][2] == -1) or
    (a_list[1][0]==-1 and a_list[1][1] == -1 and a_list[1][2] == -1) or
    (a_list[2][0]==-1 and a_list[2][1] == -1 and a_list[2][2] == -1) or
    (a_list[0][0]==-1 and a_list[1][0] == -1 and a_list[2][0] == -1) or
    (a_list[0][1]==-1 and a_list[1][1] == -1 and a_list[2][1] == -1) or
    (a_list[0][2]==-1 and a_list[1][2] == -1 and a_list[2][2] == -1) or
    (a_list[0][0]==-1 and a_list[1][1] == -1 and a_list[2][2] == -1) or
    (a_list[0][2]==-1 and a_list[1][1] == -1 and a_list[2][0] == -1)):

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

Solution (Python):
import numpy as np
a = []
a.append(input().split())
a.append(input().split())
a.append(input().split())
a = np.array(a).astype(int)

N = int(input())
for i in range(N):
    a[a == int(input())] = -1
    
def check(a):
    if a.max(axis=0).min() == -1:
        return "Yes"
    if a.max(axis=1).min() == -1:
        return "Yes"
    if a[0,0] + a[1,1] + a[2,2] == -3:
        return "Yes"
    if a[2,0] + a[1,1] + a[0,2] == -3:
        return "Yes"
    return "No"
print(check(a))

Solution (Python):
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j, a_j in enumerate(a_list):
    if a_j == b_i:
      a_list[j] = -1
    
if ((a_list[0]==-1 and a_list[1] == -1 and a_list[2] == -1) or
    (a_list[3]==-1 and a_list[4] == -1 and a_list[5] == -1) or
    (a_list[6]==-1 and a_list[7] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[4] == -1 and a_list[8] == -1) or
	(a_list[2]==-1 and a_list[4] == -1 and a_list[6] == -1)):
  print("Yes")
else:
  print("No")

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

N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if l[i][j]==b:
                used[i][j]=True

def check():
    if used[0][0] and used[1][1] and used[2][2]:
        return True
    if used[0][2] and used[1][1] and used[2][0]:
        return True
    for i in range(3):
        if used[i][0] and used[i][1] and used[i][2]:
            return True
        if used[0][i] and used[1][i] and used[2][i]:
            return True

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

Solution (Python):
A_list = []
for i in range(3):
    A = list(map(int, input().split()))
    A_list.append(A)
N = int(input())
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A_list[i][j]==b:
                A_list[i][j]=0
ans = -1
for i in range(3):
    if A_list[i][0]==0 and A_list[i][1]==0 and A_list[i][2]==0:
        ans = 0
for i in range(3):
    if A_list[0][i]==0 and A_list[1][i]==0 and A_list[2][i]==0:
        ans = -2
if (A_list[0][0]==0 and A_list[1][1]==0 and A_list[2][2]==0) or (A_list[0][2]==0 and A_list[1][1]==0 and A_list[2][0]==0):
    ans = -3
print("No") if ans == -1 else print("Yes")

Solution (Python):
A = [ list(map(int, input().split())) for _ in range(3) ]
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] = 0
flag = False
for i in range(3):
    if sum( [ A[i][j] for j in range(3)] ) == 0:
        flag = True
    if sum( [ A[j][i] for j in range(3)] ) == 0:
        flag = True
if sum( [A[i][i] for i in range(3)] ) == 0 or sum( [A[2-i][i] for i in range(3)] ) == 0:
    flag = True
print("Yes") if flag else print("No")

Solution (Python):
import numpy as np


def main():
    As = [list(map(int, input().split())) for j in range(3)]
    As = np.array(As)
    n = int(input())
    bs = [int(input()) for i in range(n)]
    for b in bs:
        As = np.where(As == b, 0, As)

    if np.any(np.all(As == 0, axis=0)):
        print("Yes")
    elif np.any(np.all(As == 0, axis=1)):
        print("Yes")
    elif As[0][0] == 0 and As[1][1] == 0 and As[2][2] == 0:
        print("Yes")
    elif As[0][2] == 0 and As[1][1] == 0 and As[2][0] == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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

for i in range(n):
  s=int(input())
  count=-1
  for T in [A,B,C]:
    count+=1
    if s in T:
      
      ans[count][T.index(s)]=1
for i in range(3):
  if ans[i]==[1,1,1]:
    print("Yes")
    exit()
for i in range(3):
  if [ans[j][i] for j in range(3)]==[1,1,1]:
    print("Yes")
    exit()
if [ans[0][0],ans[1][1],ans[2][2]]==[1,1,1]:
  print("Yes")
  exit()
if [ans[0][2],ans[1][1],ans[2][0]]==[1,1,1]:
  print("Yes")
  exit()
print("No")

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

X = []
X += [set(A[i]) for i in range(3)]
X += [set([A[j][i] for j in range(3)]) for i in range(3)]
X += [set([A[0][2], A[1][1], A[2][0]]), set([A[2][2], A[1][1], A[0][0]])]

for x in X:
    if x <= B: 
        print('Yes')
        break
else:
    print('No')

Solution (Python):

A = [list(map(int, input().split(' '))) for  _ in range(3)]
N = int(input())
B = set([int(input()) for _ in range(N)])

X = []
X += [set(A[i]) for i in range(3)]
X += [set([A[j][i] for j in range(3)]) for i in range(3)]
X += [set([A[0][2], A[1][1], A[2][0]]), set([A[2][2], A[1][1], A[0][0]])]

for x in X:
    if x <= B:
        print('Yes')
        break
else:
    print('No')

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

n=int(input())

b=list(int(input()) for i in range(n))

c=[[0]*3 for i in range(3)]

for i in range(3):
    for j in range(3):
        c[i][j]=False
        for k in range(n):
            if a[i][j]==b[k]:
                c[i][j]=True

answer="No"

for i in range(3):
    if (c[i][0] and c[i][1] and c[i][2]):
        answer="Yes"
    if (c[0][i] and c[1][i] and c[2][i]):
        answer="Yes"
if (c[0][0] and c[1][1] and c[2][2]):
    answer="Yes"
if (c[0][2] and c[1][1] and c[2][0]):
    answer="Yes"

print(answer)

Solution (Python):
import sys

mat=[]
for i in range(3):
  array=list(map(int,input().split()))
  mat.append(array)
  
N=int(input())
bset=set()
for i in range(N):
  b=int(input())
  bset.add(b)
  




for i in range(3):
  for j in range(3):
    if not mat[i][j] in bset:
      break
  else:
    print("Yes")
    sys.exit()
    

for i in range(3):
  for j in range(3):
    if not mat[j][i] in bset:
      break
  else:
    print("Yes")
    sys.exit()
    

for i in range(3):
  if not mat[i][i] in bset:
    break
else:
  print("Yes")
  sys.exit()
for i in range(3):
  if not mat[i][2-i] in bset:
    break
else:
  print("Yes")
  sys.exit()
  
print("No")

Solution (Python):

import sys

A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

a = [[0,0,0],[0,0,0],[0,0,0]]

N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            a[j][A[j].index(b)] = 1

flag = False

for i in range(3):
    if 0 not in a[i]: flag = True
    if a[0][i]*a[1][i]*a[2][i] == 1: flag = True
    
if a[0][0]*a[1][1]*a[2][2] == 1: flag = True
if a[0][2]*a[1][1]*a[2][0] == 1: flag = True

print('Yes') if flag == True else print('No')

Solution (Python):
bingo = []
tmp = input()
bingo.append(tmp.split(' '))
tmp = input()
bingo.append(tmp.split(' '))
tmp = input()
bingo.append(tmp.split(' '))
for i in range(len(bingo)):
    bingo[i] = [int(bingo[i][0]), int(bingo[i][1]), int(bingo[i][2])]

n = input()
data = []
arr = range(int(n))
arr = list(arr)
for count in arr:
    tmp = input()
    data.append(int(tmp))

ans = []
for num in data:
    for i in range(len(bingo)):
        for j in [0, 1, 2]:
            if bingo[i][j] is num:
                ans.append([i, j])












if [0, 0] in ans and [0, 1] in ans and [0, 2] in ans:
    print('Yes')
    exit(0)

if [1, 0] in ans and [1, 1] in ans and [1, 2] in ans:
    print('Yes')
    exit(0)

if [2, 0] in ans and [2, 1] in ans and [2, 2] in ans:
    print('Yes')
    exit(0)

if [0, 0] in ans and [1, 0] in ans and [2, 0] in ans:
    print('Yes')
    exit(0)

if [0, 1] in ans and [1, 1] in ans and [2, 1] in ans:
    print('Yes')
    exit(0)

if [0, 2] in ans and [1, 2] in ans and [2, 2] in ans:
    print('Yes')
    exit(0)

if [0, 0] in ans and [1, 1] in ans and [2, 2] in ans:
    print('Yes')
    exit(0)

if [0, 2] in ans and [1, 1] in ans and [2, 0] in ans:
    print('Yes')
    exit(0)

print('No')

Solution (Python):
import numpy as np
bingo = np.ndarray((3,3)).astype(np.int)
for i in range(3):
    line = list(map(int,input().split()))
    bingo[i] = line
N = int(input())

for _ in range(N):
    b = int(input())
    bingo[bingo==b] = 0

row = min(np.max(bingo,axis=1))
col = min(np.max(bingo,axis=0))
diag = min(bingo[0,0]+bingo[1,1]+bingo[2,2],bingo[0,-1]+bingo[1,-2]+bingo[2,-3])
if min(row,col,diag)==0:
    print('Yes')
else:
    print('No')