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):
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = {int(input()) for _ in range(N)}

h1 = {A11, A12, A13}
h2 = {A21, A22, A23}
h3 = {A31, A32, A33}
v1 = {A11, A21, A31}
v2 = {A12, A22, A32}
v3 = {A13, A23, A33}
c1 = {A11, A22, A33}
c2 = {A13, A22, A31}

if len(h1 & B)==3 or len(h2 & B)==3 or len(h3 & B)==3 or len(v1 & B)==3 or len(v2 & B)==3 or len(v3 & B)==3 or len(c1 & B)==3 or len(c2 & B)==3:
    print("Yes")
else:
    print("No")

Solution (Python):

A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(input())
for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = -1
        

diag = (sum(A[0::4]) == -3) | (sum(A[2:8:2]) == -3)
rows = (sum(A[:3]) == -3) | (sum(A[3:6]) == -3) | (sum(A[6:]) == -3)
cols = (sum(A[:7:3]) == -3) | (sum(A[1:8:3]) == -3) | (sum(A[2::3]) == -3)
ans = diag | rows | cols
print(['No', 'Yes'][ans])

Solution (Python):
Aij = []
c = 0
for i in range(3):
    Aij += list(map(int, input().split()))
    
N = int(input())
for i in range(N):
    b = int(input())
    if b in Aij:
        Aij[Aij.index(b)] = 0

for i in range(3):
    if Aij[3*i] == Aij[3*i+1] and Aij[3*i] == Aij[3*i+2]:
        c = -1
        break

    if Aij[i] == Aij[i+3] and Aij[i] == Aij[i+6]:
        c = -1
        break

if c == Aij[4]:
    if Aij[0] == Aij[4] and Aij[4] == Aij[8]:
        c = -1
    elif Aij[2] == Aij[4] and Aij[4] == Aij[6]:
        c = -1
    else:
        pass

print(['No', 'Yes'][c])

Solution (Python):
Aij = []
c = 0
for i in range(3):
    A = list(map(int, input().split()))
    Aij.append(A[0])
    Aij.append(A[1])
    Aij.append(A[2])

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

for i in range(3):
    if Aij[3*i] == Aij[3*i+1] and Aij[3*i] == Aij[3*i+2]:
        c = -1
        break

    if Aij[i] == Aij[i+3] and Aij[i] == Aij[i+6]:
        c = -1
        break

if c == Aij[4]:
    if Aij[0] == Aij[4] and Aij[4] == Aij[8]:
        c = -1
    elif Aij[2] == Aij[4] and Aij[4] == Aij[6]:
        c = -1
    else:
        pass

print(['No', 'Yes'][c])

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())
s=set()
for _ in range(N):
  b=int(input())
  if b in A:
    s|={A.index(b)}
bingo=[{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,5,8},{2,4,6},{3,4,5},{6,7,8}]
print(['No','Yes'][any(s>=b for b in bingo)])

Solution (Python):
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))
n = int(input())
for i in range(n):
    b = int(input())
    if b in x:
        x[x.index(b)] = 'T'
    if b in y:
        y[y.index(b)] = 'T'
    if b in z:
        z[z.index(b)] = 'T'
if x[0] == 'T' and x[1] == 'T' and x[2] == 'T':
    print('Yes')
elif y[0] == 'T' and y[1] == 'T' and y[2] == 'T':
    print('Yes')
elif z[0] == 'T' and z[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[0] == 'T' and z[0] == 'T':
    print('Yes')
elif x[1] == 'T' and y[1] == 'T' and z[1] == 'T':
    print('Yes')
elif x[2] == 'T' and y[2] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[2] == 'T' and y[1] == 'T' and z[0] == 'T':
    print('Yes')
else:
    print('No')

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

    for i in range(N):
        B.append(int(input())) 
    
    for i in range(3):
        cnt = 0
        for j in range(3):
            if A[i][j] in B:
                cnt += 1
        if cnt==3:
            print('Yes')
            quit()
            
    for i in range(3):
        cnt = 0
        for j in range(3):
            if A[j][i] in B:
                cnt += 1
        if cnt==3:
            print('Yes')
            quit()

    if A[0][0] in B and A[1][1] in B and A[2][2] in B:
        print('Yes')
        quit()
    
    if A[0][2] in B and A[1][1] in B and A[2][0] in B:
        print('Yes')
        quit()
    
    print('No')

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

N = int(input())

for n 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

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

    elif (A[0][i] == 0 and A[1][i] == 0) and A[2][i] == 0:
        print("Yes")
        exit()

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

elif (A[0][2] == 0 and A[1][1] == 0) and A[2][0] == 0:
    print("Yes")

else:
    print("No")

Solution (Python):
def check(A):
    """ check bingo or not
    :param A: 3*3 matrix, 1 or 0
    :return: is_bingo bool
    """
    for row_id in range(3):
        if sum(A[row_id])==3:
            return True
    
    for column_id in range(3):
        column_sum = 0
        for row_id in range(3):
            column_sum += A[row_id][column_id]
        if column_sum == 3:
            return True

    lr_sum = 0
    rl_sum = 0
    for rc_id in range(3):
        lr_sum += A[rc_id][rc_id]
        rl_sum += A[rc_id][2-rc_id]
    if lr_sum == 3 or rl_sum == 3:
        return True
        
    return False


def search(query, A):
    for row_id in range(3):
        for column_id in range(3):
            if query == A[row_id][column_id]:
                return column_id, row_id 
    return None, None


if __name__ == '__main__':
    A = [list(map(int, input().split())) for _ in range(3)]
    B = [[0, 0, 0] for _ in range(3)]

    N = int(input())

    for _ in range(N):
        query = int(input())
        i, j = search(query, A)
        if i != None and j != None:
            B[i][j] = 1

    if check(B):
        print('Yes')
    else:
        print('No')

Solution (Python):
def check(a):
    m = [-1, -1, -1]
    if [a[0][0], a[1][1],a[2][2]] == m:
        print("Yes")
        return
    if [a[0][2], a[1][1], a[2][0]] == m:
        print("Yes")
        return
    for i in range(3):
        if a[i] == m:
            print("Yes")
            return
        elif [r[i] for r in a] == m:
            print("Yes")
            return
    print("No")
    return

a=[list(map(int,input().split()))for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
for i in range(n):
    for y,row in enumerate(a):
        try:
            x=row.index(b[i])
            a[y][x]=-1
        except ValueError:
            pass
check(a)

Solution (Python):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
a = [[False] * 3 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:
                a[i][j] = True
ans = False
for i in range(3):
    if a[i][0] and a[i][1] and a[i][2] or a[0][i] and a[1][i] and a[2][i]:
        print('Yes')
        exit()
if a[0][0] and a[1][1] and a[2][2] or a[2][0] and a[1][1] and a[0][2]:
        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())
s=set()
for _ in range(N):
  b=int(input())
  if b in A:
    s|={A.index(b)}
bingo=[{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}]
print(["No","Yes"][any(s>=b for b in bingo)])

Solution (Python):
import sys
import itertools

def resolve(in_):
    A = tuple(map(int, itertools.chain.from_iterable(line.split() for line in itertools.islice(in_, 3))))
    assert len(A) == 9
    C = [False] * 9
    N = int(next(in_))
    
    B = frozenset(map(int, itertools.islice(in_, N)))

    for i, a in enumerate(A):
        if a in B:
            C[i] = True
    

    b = any(all(line) for line in itertools.chain(
        ((C[i * 3], C[i * 3 + 1], C[i * 3 + 2]) for i in range(3)),
        ((C[i], C[i + 3], C[i + 6]) for i in range(3)),
        ((C[0], C[4], C[8]), (C[2], C[4], C[6])),
    ))
    return 'Yes' if b else 'No'


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):

"""
Created on Sun Aug  9 20:50:35 2020

@author: akros
"""


"""
Created on Sun Aug  9 16:51:42 2020

@author: akros
"""

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

N = int(input())
a = []

for i in range(N):
    a.append(int(input()))
   
    if A1[0] == a[i]:
        A1[0] = True
    elif a[i] == A1[1]:
        A1[1] = True
    elif a[i] == A1[2]:
        A1[2] = True
    elif a[i] == A2[0]:
        A2[0] = True
    elif a[i] == A2[1]:
        A2[1] = True
    elif a[i] == A2[2]:
        A2[2] = True
    elif a[i] == A3[0]:
        A3[0] = True
    elif a[i] == A3[1]:
        A3[1] = True
    elif a[i] == A3[2]:
        A3[2] = True


if A1[0] == True and A1[1] == True and A1[2] == True:
    print("Yes")
elif A1[0] == True and A2[0] == True and A3[0] == True:
    print("Yes")
elif A1[0] == True and A2[1] == True and A3[2] == True:
    print("Yes")
elif A1[1] == True and A2[1] == True and A3[1] == True:
    print("Yes")
elif A1[2] == True and A2[2] == True and A3[2] == True:
    print("Yes")
elif A2[0] == True and A2[1] == True and A2[2] == True:
    print("Yes")
elif A3[0] == True and A3[1] == True and A3[2] == True:
    print("Yes")
elif A1[2] == True and A2[1] == True and A3[0] == True:
    print("Yes")
    
else:             
    print("No")

Solution (Python):
A = [[j for j in list(map(int, input().split()))] for i in range(3)]
N = int(input())
B = []
for _ in range(N):
	b = int(input())
	for r in A:
		for i in range(len(r)):
			if r[i] == b:
				r[i] = 0
ans = False
for i in range(3):
	if sum(A[i]) == 0:
		ans = True
if not ans:
	for i in range(3):
		if A[0][i] + A[1][i] + A[2][i] == 0:
			ans = True
if not ans:
	if A[0][0] + A[1][1] + A[2][2] == 0:
		ans = True
	elif A[0][2] + A[1][1] + A[2][0] == 0:
		ans = True
if ans:
	print('Yes')
else:
	print('No')

Solution (Python):
def bingo(appear):
	for j in range(3):
		if appear[0][j] and appear[1][j] and appear[2][j]:
			return "Yes"
	for i in range(3):
		if appear[i][0] and appear[i][1] and appear[i][2]:
			return "Yes"
	if appear[0][0] and appear[1][1] and appear[2][2]:
		return "Yes"
	if appear[0][2] and appear[1][1] and appear[2][0]:
		return "Yes"
	return "No"


card = []
for _ in range(3):
	arr = list(map(int, input().split()))
	card.append(arr)
appear = [[False for _ in range(3)] for _ in range(3)]
n = int(input())
for _ in range(n):
	a = int(input())
	for i in range(3):
		for j in range(3):
			if a == card[i][j]:
				appear[i][j] = True

print(bingo(appear))

Solution (Python):
def mark(n):
    for i in range(n):
        num = int(input())
        if num in A:
            A[A.index(num)]=0

def tate():
    for i in range(3):
        if A[i]==A[i+3] and A[i]==A[i+6]:
            return 1
    return 0

def yoko():
    for i in range(0,7,3):
        if A[i]==A[i+1] and A[i]==A[i+2]:
            return 1
    return 0

def naname():
    if A[4]==A[0] and A[4]==A[8]:
        return 1
    elif A[4]==A[2] and A[4]==A[6]:
        return 1
    else:
        return 0

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())
mark(n)
if tate()+yoko()+naname()>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()))
A = A1 + A2 + A3
N = int(input())
s = set() 
for _ in range(N):
  b = int(input())
  if b in A:
    s |= {A.index(b)}

bingo = [{0, 1, 2}, {0, 3, 6}, {0, 4, 8}, {1, 4, 7}, {2, 4, 6}, {2, 5, 8}, {3, 4, 5}, {6, 7, 8}]
print(['No','Yes'][any(b <= s for b in bingo)])

Solution (Python):
def solve():
    card = []
    num_pos = {}
    for i in range(3):
        row = [int(num) for num in input().split()]
        card.append(row)
        for j,num in enumerate(row):
            num_pos[num] = (i,j)

    N = int(input())
    for i in range(N):
        target = int(input())
        
        if target in num_pos:
            pos_i, pos_j = num_pos[target]
            card[pos_i][pos_j] = 0

    ans = False
    for row in card:
        if not any(row):
            ans = True
    for column in range(3):
        column_flag = True
        for i in range(3):
            if card[i][column]:
                column_flag = False
        if column_flag:
            ans = True
    diagonal_flag = True
    for i in range(3):
        if card[i][i]:
            diagonal_flag = False
    if diagonal_flag:
        ans = True
    diagonal_flag = True
    for i in range(3):
        if card[2-i][i]:
            diagonal_flag = False
    if diagonal_flag:
        ans = True
    if ans:
        print("Yes")
    else:
        print("No")
    
    

if __name__ == "__main__":
    solve()

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

for b in B:
    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] == [-1,-1,-1]:
        print("Yes")
        exit()

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

if [A[0][0],A[1][1],A[2][2]] == [-1,-1,-1]:
    print("Yes")
    exit()
if [A[0][2],A[1][1],A[2][0]] == [-1,-1,-1]:
    print("Yes")
    exit()
print("No")

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

for b in B:
    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] == [-1,-1,-1]:
        print("Yes")
        exit()

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

if [A[0][0],A[1][1],A[2][2]] == [-1,-1,-1]:
    print("Yes")
    exit()
if [A[0][2],A[1][1],A[2][0]] == [-1,-1,-1]:
    print("Yes")
    exit()
print("No")

Solution (Python):
import numpy as np

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

a = np.array(A)

for i in b:
    a = np.where(a == i, 0, a)

for i in range(3):
    if sum(a[i]) == 0:
        print('Yes')
        exit()
    if sum(a[:,i]) == 0:
        print('Yes')
        exit()

if a[0,0] + a[1,1] + a[2,2] == 0:
    print('Yes')
    exit()

if a[0,2] + a[1,1] + a[2,0] == 0:
    print('Yes')
    exit()

print('No')

Solution (Python):
import sys

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

card = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
]

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

if card[0].count(1) == 3:
    print("Yes")
    sys.exit()

if card[1].count(1) == 3:
    print("Yes")
    sys.exit()

if card[2].count(1) == 3:
    print("Yes")
    sys.exit()

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

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

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

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

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

print("No")

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
  d = int(input())
  for i in range(3):
    if d in a[i]:
      a[i][a[i].index(d)] = -1

for i in range(3):
  if sum(a[i])==-3:
    print('Yes')
    exit()
  s = 0
  for j in range(3):
    s += a[j][i]
  if s==-3:
    print('Yes')
    exit()
if a[0][0]+a[1][1]+a[2][2]==-3:
  print('Yes')
  exit()
if a[0][2]+a[1][1]+a[2][0]==-3:
  print('Yes')
  exit()

print('No')

Solution (Python):


def checkBingo(A,c):
    for i in range(3):
        for j in range(3):
            if A[i][j]==c:
                A[i][j]=0

    for i in range(3):
        if max(A[i])==0 :
            return 1
    for i in range(3):
        if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
            return 1
    if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
        return 1
    if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
        return 1
    return 0

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


n = int(input())

res=0
for i in range(n):
    b = (int(input()))
    
    res += checkBingo(A,b)

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

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

for i in range(3):
    for j in range(3):
        for k in range(n):
            if card[i][j] == check[k]:
                card[i][j] = 0

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

if card[0][0] + card[1][1] + card[2][2] == 0:
    ans = "Yes"
if card[0][2] + card[1][1] + card[2][0] == 0:
    ans = "Yes"
print(ans)

Solution (Python):
import math


def resolve():
    import sys
    input = sys.stdin.readline
    a = []
    a1 = [int(x) for x in input().rstrip().split(" ")]
    a2 = [int(x) for x in input().rstrip().split(" ")]
    a3 = [int(x) for x in input().rstrip().split(" ")]


    a += a1 + a2 + a3

    opened = set()

    n = int(input().rstrip())
    for _ in range(n):
        b = int(input().rstrip())
        if b in a:
            opened.add(a.index(b))

    
    if all([x in opened for x in {0,3,6}]) or all([x in opened for x in {1,4,7}]) or all([x in opened for x in {2,5,8}]):
        print("Yes")
    elif all([x in opened for x in {0,1,2}]) or all([x in opened for x in {3,4,5}]) or all([x in opened for x in {6,7,8}]):
        print("Yes")
    elif all([x in opened for x in {0,4,8}]) or all([x in opened for x in {2,4,6}]):
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    resolve()

Solution (Python):
import sys

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

card = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
]

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

if card[0].count(1) == 3:
    print("Yes")
    sys.exit()

if card[1].count(1) == 3:
    print("Yes")
    sys.exit()

if card[2].count(1) == 3:
    print("Yes")
    sys.exit()

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

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

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

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

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

print("No")

Solution (Python):
A_lists = [map(int, input().split()) for _ in range(3)]
num_dict = {}
for n1, A_list in enumerate(A_lists):
    for n2, a in enumerate(A_list):
        num_dict[a] = (n1, n2)

N = int(input())
B_list = [int(input()) for _ in range(N)]
bing_ar = [[False, False, False] for _ in range(3)]

keys = num_dict.keys()
for b in B_list:
    if b in num_dict:
        n1, n2 = num_dict[b]
        bing_ar[n1][n2] = True

if ((sum(bing_ar[0]) == 3) or (sum(bing_ar[1]) == 3) or (sum(bing_ar[2]) == 3)) or \
    ((bing_ar[0][0] == True) and (bing_ar[1][0] == True) and (bing_ar[2][0] == True)) or \
    ((bing_ar[0][1] == True) and (bing_ar[1][1] == True) and (bing_ar[2][1] == True)) or \
    ((bing_ar[0][2] == True) and (bing_ar[1][2] == True) and (bing_ar[2][2] == True)) or \
    ((bing_ar[0][0] == True) and (bing_ar[1][1] == True) and (bing_ar[2][2] == True)) or \
    ((bing_ar[0][2] == True) and (bing_ar[1][1] == True) and (bing_ar[2][0] == True)):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a = inpll(3)
n = inp()
B = inplm(n)

tmp = np.zeros((3,3),dtype=np.int)

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

ans = 'No'
if np.any(np.all(tmp == 1,axis=0) == True) or np.any(np.all(tmp == 1,axis=1) == True) or (tmp[0][0] == 1 and tmp[1][1] == 1 and tmp[2][2] == 1) or (tmp[0][2] == 1 and tmp[1][1] == 1 and tmp[2][0] == 1):
    ans = 'Yes'

print(ans)

Solution (Python):
import sys
numbers = []

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

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

lines = [
    [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 line in lines:
    a, b, c = line
    if numbers[a] in hits and numbers[b] in hits and numbers[c] in hits:
        print('Yes')
        sys.exit()
        
print('No')

Solution (Python):

import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))

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

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))

result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'

print(result)

Solution (Python):
A = []
A += map(int, input().split())
A += map(int, input().split())
A += map(int, input().split())
N = int(input())
for _ in range(N):
    b = int(input())
    try:
        A[A.index(b)] = 0
    except ValueError:
        pass
res = (
    (A[0]+A[1]+A[2])*(A[3]+A[4]+A[5])*(A[6]+A[7]+A[8])*
    (A[0]+A[3]+A[6])*(A[1]+A[4]+A[7])*(A[2]+A[5]+A[8])*
    (A[0]+A[4]+A[8])*(A[2]+A[4]+A[6])
)
print("Yes" if res == 0 else "No")

Solution (Python):
a = []
for _ in range(3):
    a += list(map(int, input().split()))
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a:
        i = a.index(b)
        a[i] = 0
if sum(a[0:3]) == 0 or sum(a[3:6]) == 0 or sum(a[6:]) == 0 \
    or sum(a[0::3]) == 0 or sum(a[1::3]) == 0 or sum(a[2::3]) == 0 \
    or sum(a[0::4]) == 0 or sum(a[2:7:2]) == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for _ in range(N)]
S=[[0,0,0] for _ in range(3)]
for b in B:
  for i in range(3):
    if b in A[i]:
      S[i][A[i].index(b)] = 1
      break
p = False
for a in S:
  if sum(a)==3:
    p = True
    break
if not p:
  for i in range(3):
    if S[0][i]+S[1][i]+S[2][i]==3:
      p = True
      break
if not p:
  if S[0][0]+S[1][1]+S[2][2]==3 or S[2][0]+S[1][1]+S[0][2]==3:
    p=True
print("Yes" if p else "No")

Solution (Python):
def isBingo(ary):
  ret = False
  if (
    (ary[0] == ary[1] == ary[2] == 0)
    or (ary[3] == ary[4] == ary[5] == 0)
    or (ary[6] == ary[7] == ary[8] == 0)
    or (ary[0] == ary[3] == ary[6] == 0)
    or (ary[1] == ary[4] == ary[7] == 0)
    or (ary[2] == ary[5] == ary[8] == 0)
    or (ary[0] == ary[4] == ary[8] == 0)
    or (ary[2] == ary[4] == ary[6] == 0)
  ):
    ret = True

  return ret

A = []
for i in range(3):
  row = input().split(" ")
  for n in row:
    A.append(int(n))

B = []
N = int(input())
for i in range(N):
  B.append(int(input()))
  
B = list(set(B))
C = list(map(lambda a: 0 if a in B else a, A))

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

Solution (Python):
AA1 = input().split()
AA2 = input().split()
AA3 = input().split()
AA4 = [AA1[0],AA2[0],AA3[0]]
AA5 = [AA1[1],AA2[1],AA3[1]]
AA6 = [AA1[2],AA2[2],AA3[2]]
AA7 = [AA1[0],AA2[1],AA3[2]]
AA8 = [AA1[2],AA2[1],AA3[0]]
N = int(input())
list1 = []
for i in range(N):
  b = input()
  list1.append(b)
count = 0
bingo =0
for i in list1:
  if i in AA1:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
  
for i in list1:
  if i in AA2:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0

for i in list1:
  if i in AA3:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
  
for i in list1:
  if i in AA4:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0

for i in list1:
  if i in AA5:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0

for i in list1:
  if i in AA6:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
  
for i in list1:
  if i in AA7:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
for i in list1:
  if i in AA8:
    count +=1
if count ==3 :
  bingo =1
else:
  count =0
if bingo ==1:
  print('Yes')
else:
  print('No')

Solution (Python):

A1=input()

A2=input()

A3=input()



list1 = A1.split()

list1 = [int(i) for i in list1]


list2 = A2.split()

list2 = [int(i) for i in list2]


list3 = A3.split()

list3 = [int(i) for i in list3]


N = input()

N=int(N)

num=[]

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


T1 = all([(i in num ) for i in list1])

T2 = all([(i in num ) for i in list2])

T3 = all([(i in num ) for i in list3])

T4 = all([(list1[0] in num),(list2[0] in num),(list3[0] in num)])

T5 = all([(list1[1] in num),(list2[1] in num),(list3[1] in num)])

T6 = all([(list1[2] in num),(list2[2] in num),(list3[2] in num)])

T7 = all([(list1[0] in num),(list2[1] in num),(list3[2] in num)])

T8 = all([(list1[2] in num),(list2[1] in num),(list3[0] in num)])

if (any([T1,T2,T3,T4,T5,T6,T7,T8])) == True:
    print("Yes")
else:
    print("No")

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

for i in range(3):
    if sum(a[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    if sum([a[0][i], a[1][i], a[2][i]]) == 0:
        print("Yes")
        exit()
if sum([a[0][0], a[1][1], a[2][2]]) == 0 or sum([a[0][2], a[1][1], a[2][0]]) == 0:
    print("Yes")
    exit()
print("No")

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    N = int(input())
    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if d[i][j] == b:
                    d[i][j] = 0

    for i in range(3):
        if sum(d[i]) == 0:
            print("Yes")
            return

    for j in range(3):
        t = 0
        for i in range(3):
            t += d[i][j]
        if t == 0:
            print("Yes")
            return

    if d[0][0] + d[1][1] + d[2][2] == 0:
        print("Yes")
        return

    if d[0][2] + d[1][1] + d[2][0] == 0:
        print("Yes")
        return

    print("No")


def main():
    solve()


if __name__ == '__main__':
    main()

Solution (Python):
ls = []
for i in range(3):
    ls.append(list(input().split(' ')))

N = int(input())
for i in range(N):
    X = input()
    for i in range(3):
        if X in ls[i]:
            ls[i][ls[i].index(X)] = 0

result = False
for i in range(3):
    if ls[i].count(0) == 3:
        result = True
        break

if not result:
    for i in range(3):
        cnt = 0
        for j in range(3):
            if ls[j][i] == 0:
                cnt += 1
        if cnt == 3:
            result = True
            break

if not result:
    cnt = 0
    for i in range(3):
        if ls[i][i] == 0:
            cnt += 1
    if cnt == 3:
        result = True

if not result:
    cnt = 0
    for i in range(3):
        if ls[i][3-i-1] == 0:
            cnt += 1
    if cnt == 3:
        result = True

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

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


for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
tmp = 0
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0:
        tmp = 1
    elif a[0][i]+a[1][i]+a[2][i] == 0:
        tmp = 1
if a[0][0]+a[1][1]+a[2][2] ==0:
    tmp = 1
elif a[0][2]+a[1][1]+a[2][0] ==0:
    tmp = 1
if tmp == 1:
    print('Yes')
else:
    print('No')