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()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

n = int(input())

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

for i in range(3):
    if a[i] in x:
        a[i] = True
    else:
        a[i] = False
    if b[i] in x:
        b[i] = True
    else:
        b[i] = False
    if c[i] in x:
        c[i] = True
    else:
        c[i] = False

flag = False

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

for i in range(3):
    if a[i] and b[i] and c[i]:
        flag = True

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

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

Solution (Python):
a = [0 for i in range(9)]
c = [0 for i in range(9)]
a[0],a[1],a[2] = map(int,input().split())
a[3],a[4],a[5] = map(int,input().split())
a[6],a[7],a[8] = map(int,input().split())

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



ans = 'No'
for i in range(3):
    if c[3*i]+c[3*i+1]+c[3*i+2] == 3:
        ans = 'Yes'

for i in range(3):
    if c[i]+c[3+i]+c[6+i] == 3:
        ans = 'Yes'

if c[0]+c[4]+c[8] == 3:
    ans = 'Yes'
if c[2]+c[4]+c[6] == 3:
    ans = 'Yes'

print(ans)

Solution (Python):
import sys

def judge(p, numList):
    for n in numList:
        if p[n] == False:
            return False
    return True

board = []
bingo = [False] * 9
for i in range(0, 3):
    board += list(map(int, input().split()))

N = int(input())
for i in range(0, N):
    n = int(input())
    for j in range(len(board)):
        if n == board[j]:
            bingo[j] = True

row = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
for r in row:
    if judge(bingo, r):
        print("Yes")
        sys.exit()
print("No")

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

for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a[j][k] = "o"

for i in range(3):
    tmp1 = ""
    tmp2 = ""
    for j in range(3):
        tmp1 += a[i][j]
        tmp2 += a[j][i]
    if tmp1 == "ooo" or tmp2 == "ooo":
        print("Yes")
        exit()

if a[0][0] + a[1][1] + a[2][2] == "ooo" or a[0][2] + a[1][1] + a[2][0] == "ooo":
    print("Yes")
else:
    print("No")

Solution (Python):


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

N = int(input())

for i in range(N):
    value = int(input())
    for j in range(len(A)):
        if value == A[j]:
            A[j] = 101
            break

msg = "No"
if (A[0] == 101 and A[1] == 101 and A[2] == 101):
    msg = "Yes"
elif (A[3] == 101 and A[4] == 101 and A[5] == 101):
    msg = "Yes"
elif (A[6] == 101 and A[7] == 101 and A[8] == 101):
    msg = "Yes"
elif (A[0] == 101 and A[3] == 101 and A[6] == 101):
    msg = "Yes"
elif (A[1] == 101 and A[4] == 101 and A[7] == 101):
    msg = "Yes"
elif (A[2] == 101 and A[5] == 101 and A[8] == 101):
    msg = "Yes"
elif (A[0] == 101 and A[4] == 101 and A[8] == 101):
    msg = "Yes"
elif (A[2] == 101 and A[4] == 101 and A[6] == 101):
    msg = "Yes"
print(msg)

Solution (Python):
bing1 = list(map(int, input().split()))
bing2 = list(map(int, input().split()))
bing3 = list(map(int, input().split()))

bingo = [bing1,bing2,bing3]
res = [[0,0,0],[0,0,0],[0,0,0]]

n = int(input())

for i in range(n):
    c = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == c:
                res[j][k] = 1
                break
                
ress = "No"
if sum(res[0]) == 3 or sum(res[1]) == 3 or sum(res[2]) == 3:
    ress = "Yes"
elif res[0][0] + res[1][0] + res[2][0] == 3 or res[0][1] + res[1][1] + res[2][1] == 3 or res[0][2] + res[1][2] + res[2][2] == 3:
    ress = "Yes"
elif res[0][0] + res[1][1] + res[2][2] == 3 or res[0][2] + res[1][1] + res[2][0] == 3:
    ress = "Yes"
print(ress)

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())
bj = [int(input()) for i in range(N)]

result = []
result.append([A11, A12, A13])
result.append([A13, A23, A33])
result.append([A33, A32, A31])
result.append([A31, A21, A11])
result.append([A12, A22, A32])
result.append([A21, A22, A23])
result.append([A11, A22, A33])
result.append([A31, A22, A13])

flg = 'No'
for cmb in result:
	count = 0
	for i in bj:
		if i in cmb:
			count += 1
	if count == 3:
		flg = 'Yes'
print(flg)

Solution (Python):
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
bingo=[[False]*3 for i in range(3)]
for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if(A[j][k]==b):
                bingo[j][k]=True
for i in range(3):
    if(bingo[i]==[True]*3):
        print("Yes")
        exit()
for j in range(3):
    if(bingo[0][j]==True and bingo[1][j]==True and bingo[2][j]==True):
        print("Yes")
        exit()
if(bingo[0][0]==True and bingo[1][1]==True and bingo[2][2] ==True):
    print("Yes")
    exit()
elif(bingo[0][2]==True and bingo[1][1]==True and bingo[2][0]==True):
    print("Yes")
    exit()
print("No")

Solution (Python):
import itertools

def initBingoCard():
    bingoCard = []
    for i in range(3):
        row = [int(i) for i in input().split()]
        bingoCard.append(row)
    return bingoCard

def generateBingoPatterns(bingo_card):
    bingo_patterns = []
    for row in bingo_card:
        bingo_patterns.append(row)
        
    for column in range(3):
        column_pattern = []
        for row in range(3):
            column_pattern.append(bingo_card[row][column])
            
        bingo_patterns.append(column_pattern)
        
    bingo_patterns.append([bingo_card[0][0],bingo_card[1][1],bingo_card[2][2]])
    bingo_patterns.append([bingo_card[2][0],bingo_card[1][1],bingo_card[0][2]])
    
    return bingo_patterns

bingo_card = initBingoCard()

bingo_patterns = generateBingoPatterns(bingo_card)
    
N = int(input())

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

combi = itertools.combinations(nums, 3)

flag = False
for c in combi:
    c = sorted(c)
    for pattern in bingo_patterns:
        if c == sorted(pattern):
            flag = True
            break
if flag :
    print('Yes')
else :
    print('No')

Solution (Python):
import sys 
x=[]
for i in range(3):
  a,b,c=map(int,input().split())
  x.append(a)
  x.append(b)
  x.append(c)
n=int(input())
p=[int(input()) for i in range(n)]
for i in range(9):
  if x[i] in p:
    x[i]=0
def ch(s,d):
  global x
  if x[s]==0 and x[s+d]==0 and x[s+d+d]==0:
    print('Yes')
    sys.exit()
d=1
ch(0,d)
ch(3,d)
ch(6,d)
d=3
for i in range(3):
  ch(i,d)
ch(2,2)
ch(0,4)
print('No')

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

s = 0

for i in range(3):
    if r[i][0] == r[i][1] == r[i][2] == 1:
        s += 1
        break
    elif r[0][i] == r[1][i] == r[2][i] == 1:
        s += 1
        break

if r[0][0] == r[1][1] == r[2][2] == 1:
    s += 1
elif r[2][0] == r[1][1] == r[0][2] == 1:
    s += 1

if s > 0:
    print('Yes')
else:
    print('No')

Solution (Python):
l1 = input().split()
l2 = input().split()
l3 = input().split()
l = [l1,l2,l3]
n = int(input())
b = [input() for i in range(n)]
for i in range(3):
    for j in range(3):
        if l[i][j] in b:
            l[i][j] = -1
if l[0] == [-1,-1,-1] or l[1] == [-1,-1,-1] or l[2] == [-1,-1,-1] or (l[0][0] == -1 and l[1][0] == -1 and l[2][0] == -1) or (l[0][1] == -1 and l[1][1] == -1 and l[2][1] == -1) or (l[0][2] == -1 and l[1][2] == -1 and l[2][2] == -1) or (l[0][0] == -1 and l[1][1] == -1 and l[2][2] == -1) or (l[2][0] == -1 and l[1][1] == -1 and l[0][2] == -1):
    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)]

ans=[set([a[0][0],a[0][1],a[0][2]]),set([a[1][0],a[1][1],a[1][2]]),set([a[2][0],a[2][1],a[2][2]]),set([a[0][0],a[1][0],a[2][0]]),set([a[0][1],a[1][1],a[2][1]]),set([a[0][2],a[1][2],a[2][2]]),set([a[0][0],a[1][1],a[2][2]]),set([a[0][2],a[1][1],a[2][0]])]
from itertools import combinations


for i in combinations(b, 3):
    if set(i) in ans:
        print('Yes')
        exit()
print('No')

Solution (Python):
a = []

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

n = int(input())

b = []

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

ans = "No"
flag = 0


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


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


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


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

print(ans)

Solution (Python):

def main():
    A = [list(map(int,input().split())) for i in range(3)]
    N = int(input())
    B = [int(input()) for i in range(N)]
    
    for j in B:
        for k in range(3):
            for l in range(3):
                if j == A[k][l]:
                    A[k][l] = -1
    A1 = A[0]
    A2 = A[1]
    A3 = A[2]
    if A1.count(-1)==3 or A2.count(-1)==3 or A3.count(-1)==3:
        print('Yes')
        return
    for m in range(3):
        if A1[m] ==-1 and A2[m] == -1 and A3[m] == -1:
            print('Yes')
            return
    if A1[0]==-1 and A2[1]==-1 and A3[2]==-1:
        print('Yes')
        return
    if A1[2]==-1 and A2[1]==-1 and A3[0]==-1:
        print('Yes')
        return
    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin

a = []
a1 = [int(x) for x in stdin.readline().rstrip().split()]
a2 = [int(x) for x in stdin.readline().rstrip().split()]
a3 = [int(x) for x in stdin.readline().rstrip().split()]
a4 = [a1[0], a2[0], a3[0]]
a5 = [a1[1], a2[1], a3[1]]
a6 = [a1[2], a2[2], a3[2]]
a7 = [a1[0], a2[1], a3[2]]
a8 = [a1[2], a2[1], a3[0]]
a.append(a1)
a.append(a2)
a.append(a3)
a.append(a4)
a.append(a5)
a.append(a6)
a.append(a7)
a.append(a8)

n = int(stdin.readline().rstrip())
b = []
for i in range(n):
    b.append(int(stdin.readline().rstrip()))

result = "No"
for aa in a:
    if (aa[0] in b and aa[1] in b and aa[2] in b):
        result = "Yes"

print(result)

Solution (Python):
import math as M
A=[]
for i in range(3):
    X=list(int(i) for i in input().split())
    A.append(X)
D=[[0 for i in range(3)]for j 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:
                D[i][j]=1


bool=False
for i in range(3):
    sum=0
    for j in range(3):
        if D[i][j]==1:
            sum+=D[i][j]
    if sum==3:
        bool=True
        break
if bool is True:
    print("Yes")
elif bool is False:
    for i in range(3):
        sum=0
        for j in range(3):
            if D[j][i]==1:
                sum+=D[j][i]
        if sum==3:
            bool=True
            break
    if bool is True:
        print("Yes")
    else:
        if D[1][1]+D[2][2]+D[0][0]==3:
            print("Yes")
        elif D[1][1]+D[0][2]+D[2][0]==3:
            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 j in range(N)]
A_n = [[0 for a in range(3)] for c in range(3)]

for k in range(3):
    for l in range(3):
        for m in range(N):
            if A[k][l] == b[m]:
                A_n[k][l] = 1
            else:
                pass

if A_n[0][0]+A_n[0][1]+A_n[0][2]==3 or A_n[1][0]+A_n[1][1]+A_n[1][2] == 3 or A_n[2][0]+A_n[2][1]+A_n[2][2] == 3:
    print("Yes")
elif A_n[0][0]+A_n[1][0]+A_n[2][0]==3 or A_n[0][1]+A_n[1][1]+A_n[2][1] == 3 or A_n[0][2]+A_n[1][2]+A_n[2][2] == 3:
    print("Yes")
elif A_n[0][0]+A_n[1][1]+A_n[2][2]==3 or A_n[0][2]+A_n[1][1]+A_n[2][0]==3:
    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

check = False
r0 = [r[0] for r in a]
r1 = [r[1] for r in a]
r2 = [r[2] for r in a]
if a[0].count(0) == 3 or a[1].count(0) == 3 or a[2].count(0) == 3:
    check = True
elif r0.count(0) == 3 or r1.count(0) == 3 or r2.count(0) == 3:
    check = True
elif (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):
    check = True

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

Solution (Python):
card = [[],[],[]]

isBingo = False

for n in range(3):
    rawInput = input().split()
    for m in rawInput:
        card[n].append(int(m))

N = int(input())

shirushi = []

for n in range(N):
    shirushi.append(int(input()))

markedhairetu = [[False,False,False],[False,False,False],[False,False,False]]

for p in range(3):
    for q in range(3):
        for r in range(N):
            if shirushi[r] == card[p][q]:
                markedhairetu[p][q] = True

for n in range(3):
    if markedhairetu[n].count(True) == 3:
        isBingo = True

for n in range(3):
        if markedhairetu[0][n] == True and markedhairetu[1][n] == True and markedhairetu[2][n] == True:
            isBingo = True

if markedhairetu[0][0] == True and markedhairetu[1][1] == True and markedhairetu[2][2] == True:
    isBingo = True

if markedhairetu[2][0] == True and markedhairetu[1][1] == True and markedhairetu[0][2] == True:
    isBingo = True

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

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

def judge(a):
    if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
        return True
    elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
        return True
    elif a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0:
        return True
    elif a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
        return True
    elif a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
        return True
    elif a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0:
        return True
    elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        return True
    elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
        return True
    return False
    

for i in range(n):
    num = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == num:
                a[x][y] = 0

if judge(a):
    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())
l = [list(map(int, input().split())) for _ in range(n)]
import numpy as np
y=np.zeros(9).reshape(3,3)
for i in range(n):
    for x in range(3):
        if a[x]==l[i][0]:
            y[0][x]=1
for i in range(n):
    for x in range(3):
        if b[x]==l[i][0]:
            y[1][x]=1
for i in range(n):
    for x in range(3):
        if c[x]==l[i][0]:
            y[2][x]=1
if sum(y[0])==3:
    print('Yes')
elif sum(y[1])==3:
    print('Yes')
elif sum(y[2])==3:
    print('Yes')
elif sum(y[1])==3:
    print('Yes')
elif y[0][0]+y[1][0]+y[2][0]==3:
    print('Yes')
elif y[0][1]+y[1][1]+y[2][1]==3:
    print('Yes')
elif y[0][2]+y[1][2]+y[2][2]==3:
    print('Yes')
elif y[0][0]+y[1][1]+y[2][2]==3:
    print('Yes')
elif y[0][2]+y[1][1]+y[2][0]==3:
    print('Yes')
else:
    print('No')

Solution (Python):
ok=True
a1=[int(x) for x in input().split()]
a2=[int(x) for x in input().split()]
a3=[int(x) for x in input().split()]
b1=[a1[0]]+[a2[0]]+[a3[0]]
b2=[a1[1]]+[a2[1]]+[a3[1]]
b3=[a1[2]]+[a2[2]]+[a3[2]]
c1=[a1[0]]+[a2[1]]+[a3[2]]
c2=[a1[2]]+[a2[1]]+[a3[0]]
alle=[a1,a2,a3,b1,b2,b3,c1,c2]
val=int(input())
d=[]
for i in range(val):
    d=int(input())
    for i1 in alle:
        if d in i1:
            i1.remove(d)
for i in alle:
    if i==[]:
        print("Yes")
        ok=False
        break
if ok:
    print("No")

Solution (Python):
import sys

def main():
    a=[]
    b=[]
    c=[]
    for i in range(3):
        tmp = input().replace('\n','').split(' ')
        tmp = list(map(int, tmp))
        a.append([tmp[0],False])
        a.append([tmp[1],False])
        a.append([tmp[2],False])
        c.append(tmp[0])
        c.append(tmp[1])
        c.append(tmp[2])
    n = int(input().replace('\n',''))
    for i in range(n):
        try:
            tmp = c.index(int(input().replace('\n','')))
            a[tmp][1] = True
        except ValueError:
            pass
    for i in range(3):
        if a[i][1] and a[i+3][1] and a[i+6][1]:
            res = 'Yes'
            break
        elif a[i*3][1] and a[i*3+1][1] and a[i*3+2][1]:
            res = 'Yes'
            break
        elif a[0][1] and a[4][1] and a[8][1] or a[2][1] and a[4][1] and a[6][1]:
            res = 'Yes'
            break
        else:
            res = 'No'
    print(res)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

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

N = int(input())
for _ in range(N):
    is_matched = False
    b = int(input())
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                is_matched = True
                A[row][col] = True
                if A[row][0] == True and A[row][1] == True and A[row][2] == True:
                    print('Yes')
                    exit()
                elif A[0][col] == True and A[1][col] == True and A[2][col] == True:
                    print('Yes')
                    exit()
                elif A[0][0] == True and A[1][1] == True and A[2][2] == True:
                    print('Yes')
                    exit()
                elif A[0][2] == True and A[1][1] == True and A[2][0] == True:
                    print('Yes')
                    exit()
                break
        if is_matched:
            break
print('No')

Solution (Python):
import sys
ans = [
    {0, 1, 2},
    {3, 4, 5},
    {6, 7, 8},
    {0, 4, 8},
    {2, 4, 6},
    {0, 3, 6},
    {1, 4, 7},
    {2, 5, 8}
]

input_list = []
for i in range(3):
    input_list += input().split(" ")

n = int(input())
call = set()
for i in range(n):
    call_num = input()
    if call_num in input_list:
        call.add(input_list.index(call_num))
        for j in ans:
            if len(call & j) == 3:
                print("Yes")
                sys.exit()
print("No")

Solution (Python):
bingo_card = [list(map(int,input().split())) for _ in range(3)] 
bingo_card_series = bingo_card[0] + bingo_card[1] + bingo_card[2]
n = int(input())
nums = [int(input()) for _ in range(n)]

for i,x in enumerate(bingo_card_series):
    if x in nums:
        bingo_card_series[i] = -1

if bingo_card_series[0] == bingo_card_series[1] == bingo_card_series[2]:
    print("Yes")
elif bingo_card_series[3] == bingo_card_series[4] == bingo_card_series[5]:
    print("Yes")
elif bingo_card_series[6] == bingo_card_series[7] == bingo_card_series[8]:
    print("Yes")
elif bingo_card_series[0] == bingo_card_series[3] == bingo_card_series[6]:
    print("Yes")
elif bingo_card_series[1] == bingo_card_series[4] == bingo_card_series[7]:
    print("Yes")
elif bingo_card_series[2] == bingo_card_series[5] == bingo_card_series[8]:
    print("Yes")
elif bingo_card_series[0] == bingo_card_series[4] == bingo_card_series[8]:
    print("Yes")
elif bingo_card_series[2] == bingo_card_series[4] == bingo_card_series[6]:
    print("Yes")
else:
    print("No")

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
x = False
for i in range(3):
    count = 0
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                count += 1
    if count == 3:
        x = True
        break
if not x:
    for i in range(3):
        count = 0
        for j in range(3):
            for k in range(N):
                if A[j][i] == b[k]:
                    count += 1
        if count == 3:
            x = True
            break
if not x:
    count = 0
    for i in range(3):
        for k in range(N):

            if A[i][i] == b[k]:
                count += 1
    if count == 3:
        x = True
if not x:
    count = 0
    for i in range(3):
        for k in range(N):
            if A[2-i][i] == b[k]:
                count += 1
    if count == 3:
        x = True

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

Solution (Python):
A11,A12,A13=list(map(lambda i:int(i),input().split()))
A21,A22,A23=list(map(lambda i:int(i),input().split()))
A31,A32,A33=list(map(lambda i:int(i),input().split()))

N=int(input())

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

if A11 in b and A12 in b and A13 in b:
    bingo =True
elif A21 in b and A22 in b and A23 in b:
    bingo =True
elif A31 in b and A32 in b and A33 in b:
    bingo =True
elif A11 in b and A21 in b and A31 in b:
    bingo =True
elif A12 in b and A22 in b and A32 in b:
    bingo =True
elif A13 in b and A23 in b and A33 in b:
    bingo =True
elif A11 in b and A22 in b and A33 in b:
    bingo =True
elif A13 in b and A22 in b and A31 in b:
    bingo =True

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

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

ans='No'
for i in range(3):
  if x[0][i]+x[1][i]+x[2][i]==3:
    ans='Yes'

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


if x[0][0]+x[1][1]+x[2][2]==3:
  ans='Yes'
elif x[2][0]+x[1][1]+x[0][2]==3:
  ans='Yes'

print(ans)

Solution (Python):
aa=list(map(int, input().split()))
ab=list(map(int, input().split()))
ac=list(map(int, input().split()))
n=int(input())
b=[int(input()) for i in range (n)]
aaa=0
aab=0
aac=0
aba=0
abb=0
abc=0
aca=0
acb=0
acc=0
for i in range (n):
    if aa[0]==b[i]:
        aaa=aaa+1
    elif aa[1]==b[i]:
        aab=aab+1
    elif aa[2]==b[i]:
        aac=aac+1
    elif ab[0]==b[i]:
        aba=aba+1
    elif ab[1]==b[i]:
        abb=abb+1
    elif ab[2]==b[i]:
        abc=abc+1
    elif ac[0]==b[i]:
        aca=aca+1
    elif ac[1]==b[i]:
        acb=acb+1
    elif ac[2]==b[i]:
        acc=acc+1
ha=aaa*aab*aac
hb=aba*abb*abc
hc=aca*acb*acc
va=aaa*aba*aca
vb=aab*abb*acb
vc=aac*abc*acc
ca=aaa*abb*acc
cb=aac*abb*aca
if ha+hb+hc+va+vb+vc+ca+cb==0:
    print('No')
else:
    print('Yes')

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

for i in range(1):
  temp = []
  for j in range(3):
    temp.append(num[j][j])
  ans.append(temp)
  
for i in range(1):
  temp = []
  temp.append(num[0][2])
  temp.append(num[1][1])
  temp.append(num[2][0])
  ans.append(temp)
N = int(input())
for i in range(N):
  X = int(input())
  for j in range(8):
    if X in ans[j]:
      ans[j].remove(X)

f = True
for i in range(8):
  if len(ans[i]) == 0:
    print('Yes')
    f = False
    break
if f:
  print('No')

Solution (Python):
def Main(A, N, B):
    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_ind = []
    for e in B:
        if e in A:
            ans_ind.append(A.index(e))
    if len(ans_ind) <= 2:
        return "No"
    else:
        for b in BINGO:
            counter = 0
            for c in b:
                if c in ans_ind:
                    counter += 1
                if counter == 3:
                    return "Yes"
    return "No"
                    
                

def main():
    A = []
    for i in range(3):
        A += list(map(int, input().split()))
    N = int(input())
    B = []
    for i in range(N):
        B.append(int(input()))
    print(Main(A, N, B))

if __name__ == '__main__':
    main()

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


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

for m in range(3):
    for n in range(3):

        if str(A[m][n]) in B:

            hole[m][n] = "

ans = "No"

if hole[0][0] == "
    ans = "Yes"
elif hole[0][0] == "
    ans = "Yes"
elif hole[1][0] == "
    ans = "Yes"
elif hole[2][0] == "
    ans = "Yes"
elif hole[0][0] == "
    ans = "Yes"
elif hole[0][1] == "
    ans = "Yes"
elif hole[0][2] == "
    ans = "Yes"
elif hole[0][2] == "
    ans = "Yes"

print(ans)

Solution (Python):
import numpy as np
 
def main():
 
    A = np.zeros([3,3])
    for i in range(3):
        A[i] = list(map(int, input().split()))
 
    B = np.zeros([3,3])
 
    N = int(input())
    for i in range(N):
        b = int(input())
        B[A == b] = 1
 
 
    for i in range(3):
        if B[i,:].sum() == 3:
            print('Yes')
            return
        if B[:, i].sum() == 3:
            print('Yes')
            return
    
    if B[0,0] == B[1,1] == B[2,2] == 1:
        print('Yes')
        return
 
    if B[2,0] == B[1,1] == B[0,2] == 1:
        print('Yes')
        return
 
    print('No')
    return
 
main()

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



check=[0,0,0,0,0,0,0,0,0]
ans=0
for i in range(N):
    for j in range(3):
        for k in range(3):
            if number[i][0]==bingo[j][k]:
                check[3*j+k]=1
                
                
                
for i in range(3):
    if check[0+3*i]==check[1+3*i]==check[2+3*i]==1:
        ans=1
    if check[i]==check[i+3]==check[i+6]==1:
        ans=1
        
if check[0]==check[4]==check[8]==1:
    ans=1
if check[2]==check[4]==check[6]==1: 
    ans=1
    
if ans==1:
    print("Yes")
else:
    print("No")

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
bingo = [[False, False, False] for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                bingo[i][j] = True



for i in range(3):
    if sum(bingo[i]) == 3:
        print('Yes')
        exit()
for i in range(3):
    tmp = [bingo[0][i], bingo[1][i], bingo[2][i]]
    
    if sum(tmp) == 3:
        print('Yes')
        exit()

tmp = [bingo[0][0], bingo[1][1], bingo[2][2]]

if sum(tmp) == 3:
    print('Yes')
    exit()

tmp = [bingo[0][2], bingo[1][1], bingo[2][0]]
if sum(tmp) == 3:
    print('Yes')
    exit()

print('No')

Solution (Python):
import numpy as np

a1 = list(map(int, input().split(' ')))
a2 = list(map(int, input().split(' ')))
a3 = list(map(int, input().split(' ')))
n = int(input())

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

arr = np.array([a1, a2, a3])
mask = np.zeros_like(arr)

for num in nums:
    idx = np.where(arr == num)

    if len(idx[0]) == 0:
        pass
    else:
        mask[idx] = 1

s_v = np.sum(mask, axis=0)
s_h = np.sum(mask, axis=1)
s_diag_1 = mask[0, 0] + mask[1, 1] + mask[2, 2]
s_diag_2 = mask[0, 2] + mask[1, 1] + mask[2, 0] 
s = np.maximum(np.concatenate([s_v, s_h, [s_diag_1], [s_diag_2]]) - 2, 0)

if np.max(s) > 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

A = [[0] * 3 for i in range(3)]
A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))

N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())

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

Solution (Python):


A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1, A2, A3]
n = int(input())

for i in range(n):
    b = int(input())
    for j in range(len(A)):
        if b in A[j]:
            A[j][A[j].index(b)] = "-"

v0Count = 0
v1Count = 0
v2Count = 0
res = "No"


for k in range(len(A)):
    if A[k].count("-") == 3:
        res = "Yes"
        break
    if A[k][0] == "-":
        v0Count += 1
    if A[k][1] == "-":
        v1Count += 1
    if A[k][2] == "-":
        v2Count +=1


if res == "No":
    if 3 in [v0Count, v1Count, v2Count]:
        res = "Yes"
    
    
    if (A[0][0] == "-" and A[1][1] == "-" and A[2][2] == "-") or (A[0][2] == "-" and A[1][1] == "-" and A[2][0] == "-"):
        res = "Yes"

print(res)

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)]

a = a1+a2+a3
for i in b:
    if i in a:
        a[a.index(i)] = True

if True not in a:
    print("No")
elif a[0] == a[3] == a[6] == True or a[1] == a[4] == a[7] == True or a[2] == a[5] == a[8] == True:
    print("Yes")
elif a[0] == a[1] == a[2] == True or a[3] == a[4] == a[5] == True or a[6] == a[7] == a[8] == True:
    print("Yes")
elif a[0] == a[4] == a[8] == True or a[2] == a[4] == a[6] == True:
    print("Yes")
else:
    print("No")