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):
Aa = list(map(int, input().split()))
Ab = list(map(int, input().split()))
Ac = list(map(int, input().split()))
At = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N = int(input())

for i in range(N):
    tmp = int(input())
    if tmp in Aa:
        At[0][Aa.index(tmp)] = 1
    if tmp in Ab:
        At[1][Ab.index(tmp)] = 1
    if tmp in Ac:
        At[2][Ac.index(tmp)] = 1

if all(At[0]) or all(At[1]) or all(At[2]):
    print('Yes')
    exit()

if At[0][0] and At[1][0] and At[2][0] \
   or At[0][1] and At[1][1] and At[2][1] \
   or At[0][2] and At[1][2] and At[2][2]:
    print('Yes')
    exit()

if At[0][0] and At[1][1] and At[2][2] \
   or At[0][2] and At[1][1] and At[2][0]:
    print('Yes')
    exit()

print('No')

Solution (Python):
a1 = [int(i) for i in input().split()]
a2 = [int(j) for j in input().split()]
a3 = [int(k) for k in input().split()]
b1 = set([a1[0], a2[0], a3[0]])
b2 = set([a1[1], a2[1], a3[1]])
b3 = set([a1[2], a2[2], a3[2]])
c1 = set([a1[0], a2[1], a3[2]])
c2 = set([a1[2], a2[1], a3[0]])
a1 = set(a1)
a2 = set(a2)
a3 = set(a3)
n = int(input())
for l in range(n) :
    num = int(input())
    if num in a1 :
        a1.remove(num)
    if num in a2 :
        a2.remove(num)
    if num in a3 :
        a3.remove(num)
    if num in b1 :
        b1.remove(num)
    if num in b2 :
        b2.remove(num)
    if num in b3 :
        b3.remove(num)
    if num in c1 :
        c1.remove(num)
    if num in c2 :
        c2.remove(num)
if len(a1) == 0 or len(a2) == 0 or len(a3) == 0 or len(b1) == 0 or len(b2) == 0 or len(b3) == 0 or len(c1) == 0 or len(c2) == 0 :
    print("Yes")
else :
    print("No")

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

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

for i in range(n):
    for j in range(3):
        if b[i] in bingo[j]:
            result[j][bingo[j].index(b[i])] = True


for i in result:
    if all(i):
        print('Yes')
        exit()

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

if all([result[0][0], result[1][1], result[2][2]]) or all([result[0][2], result[1][1], result[2][0]]):
    print('Yes')
    exit()

print('No')

Solution (Python):
a = [[int(i) for i in input().split()] for j in range(3)]
ans = [[0 for i in range(3)] for j in range(3)]

n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b==a[i][j]:
                ans[i][j] += 1
text ="No"

for i in range(3):
    if sum(ans[i])==3:
        text ="Yes"
    if sum([j[i] for j in ans])==3:
        text ="Yes"
    if sum([ans[j][j] for j in range(3)])==3:
        text ="Yes"
    if sum([ans[j][2-j] for j in range(3)])==3:
        text ="Yes"

print(text)

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
C = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
  b = B[i]
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        C[j][k] = 1
c = 0
for i in range(3):
  if C[i][0] == 1 and C[i][1] == 1 and C[i][2] == 1:
    c += 1
  if C[0][i] == 1 and C[1][i] == 1 and C[2][i] == 1:
    c += 1
if C[0][0] == 1 and C[1][1] == 1 and C[2][2] == 1:
  c += 1
if C[2][0] == 1 and C[1][1] == 1 and C[0][2] == 1:
  c += 1
if c > 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)]

F = [0]*101
for b in B:
  F[b]=1

ans = 'No'  
for i in range(3):
  c = 0
  d = 0
  for j in range(3):    
    c += F[A[i][j]]
    d += F[A[j][i]]
  if c==3 or d==3:
    ans ='Yes'
if F[A[0][0]]+F[A[1][1]]+F[A[2][2]] == 3 or F[A[0][2]]+F[A[1][1]]+F[A[2][0]] == 3:
  ans ='Yes'
  
print(ans)

Solution (Python):
a = []
for _ in range(3):
    n = input().split()
    for i in range(len(n)):
        a.append(n[i])

ans = [0 for _ in range(9)]

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

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

Solution (Python):
def main():
    row1 = list(map(int, input().split()))
    row2 = list(map(int, input().split()))
    row3 = list(map(int, input().split()))
    n = int(input())
    nums = []
    for _ in range(n):
        nums.append(int(input()))

    result = 'No'
    for num in nums:
        for i in range(3):
            if num == row1[i]:
                row1[i] = 0
        for i in range(3):
            if num == row2[i]:
                row2[i] = 0
        for i in range(3):
            if num == row3[i]:
                row3[i] = 0

    if row1.count(0) == 3:
        result = 'Yes'
    elif row2.count(0) == 3:
        result = 'Yes'
    elif row3.count(0) == 3:
        result = 'Yes'
    elif row1[0] == 0 and row2[0] == 0 and row3[0] == 0:
        result = 'Yes'
    elif row1[1] == 0 and row2[1] == 0 and row3[1] == 0:
        result = 'Yes'
    elif row1[2] == 0 and row2[2] == 0 and row3[2] == 0:
        result = 'Yes'
    elif row1[0] == 0 and row2[1] == 0 and row3[2] == 0:
        result = 'Yes'
    elif row1[2] == 0 and row2[1] == 0 and row3[0] == 0:
        result = 'Yes'
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):
def input_int_list():
    return [int(thing) for thing in input().split(" ")]


A = [input_int_list() for i in range(3)]
N = int(input())
B_set = set([int(input()) for i in range(N)])
matrix = [[0,0,0] for _ in range(3) ]
for i in range(3):
    for j in range(3):
        if A[i][j] not in B_set:
            matrix[i][j] = A[i][j]
        else:
            matrix[i][j] = 0


def Yes():
    print("Yes")
    exit()


for i in matrix:
    if sum(i) == 0:
        Yes()
    else:
        pass
A=matrix
for i in range(3):
    if sum([A[j][i] for j in range(3)]) == 0:
        Yes()
if A[0][0]+A[1][1]+A[2][2]==0:
    Yes()

if A[0][2]+A[1][1]+A[2][0] == 0:
    Yes()

print("No")

Solution (Python):
import numpy as np
card = np.array([list(map(int,input().split())) for i in range(3)])
N = int(input())
nums = np.array([int(input()) for i in range(N)])

res = np.ones((3, 3), dtype=int)
for y in range(3):
    for x in range(3):
        if card[y, x] in nums:
            res[y, x] = 0

lis = [\
    np.multiply.reduce(res.sum(axis=0)), \
    np.multiply.reduce(res.sum(axis=1)), \
    np.trace(res),\
    np.trace(np.rot90(res.T))]
print("Yes" if 0 in lis else "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 B:
  for j in range(3):
    for k in range(3):
      if A[j][k]==i:
        A[j][k]=0
D=list(zip(*A))
for i in range(3):
  if A[i]==[0,0,0]:
    print('Yes')
    exit()
  if D[i]==(0,0,0):
    print('Yes')
    exit()
if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
  print('Yes')
  exit()
if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print('Yes')
  exit()  
print('No')

Solution (Python):
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]]

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

C = [0 for _ in range(9)]
for bb in B:
	for i, aa in enumerate(A):
		if aa == bb:
			C[i] = 1

for bi in bingo:
	if C[bi[0]] == C[bi[1]] == C[bi[2]] == 1:
		print("Yes")
		exit(0)
print("No")

Solution (Python):
row1 = map(int, input().split())
row2 = map(int, input().split())
row3 = map(int, input().split())
row = list(row1) + list(row2) + list(row3)

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

comb = [
    [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 lst in comb:
    if len([1 for num in lst if row[num] in bs]) == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):

maze = []
for i in range(3):
    a_row = list(map(int,input().split()))
    maze.append(a_row)
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        row = maze[j]
        for k in range(3):
            if row[k] == b:
                row[k] = 0
for i in range(3):
    if sum(maze[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    if maze[0][i] + maze[1][i] + maze[2][i] == 0:
        print("Yes")
        exit()
if maze[0][0] + maze[1][1] + maze[2][2] == 0 or maze[0][2] + maze[1][1] + maze[2][0] == 0:
    print("Yes")
    exit()
print("No")

Solution (Python):

def main():
    import sys
    input = sys.stdin.readline
    ans = "No"
    A = [list(map(int,input().split())) for i in range(3)]
    N = int(input())
    B = [int(input()) for i in range(N)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    A[i][j] = False
    for a in A:
        if not any(a):
            ans = "Yes"
    for a_c in zip(*A):
        if not any(a_c):
            ans = "Yes"
    if A[0][0] == False and A[1][1] == False and A[2][2] == False:
        ans = "Yes"
    if A[0][2] == False and A[1][1] == False and A[2][0] == False:
        ans = "Yes"

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
bingocard = []
bingo = False
for _ in range(3):
    bingocard += input().split()

punch_data = [0]*9
n = int(input())

for _ in range(n):
    num = input()
    if num in bingocard:
        punch_data[bingocard.index(num)] = 1

for i in range(3):
    if not 0 in punch_data[3*i: 3*(i+1)]:
        bingo = True
        break
    
    if punch_data[i] == punch_data[i+3] == punch_data[i+6] == 1:
        bingo = True
        break

if punch_data[0] == punch_data[4] == punch_data[8] == 1:
    bingo = True

if punch_data[2] == punch_data[4] == punch_data[6] == 1:
    bingo = True

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a=[lmis() for i in range(3)]
    n=ii()
    b=[ii() for i in range(n)]
    for s in b:
        for i in range(3):
            for j in range(3):
                if a[i][j]==s: a[i][j]=0
    flag=0
    for i in range(3):
        if sum(a[i])==0 or a[0][i]+a[1][i]+a[2][i]==0: flag=1
    if a[1][1]==0:
        if a[0][0]+a[2][2]==0 or a[0][2]+a[2][0]==0: flag=1
    print('Yes' if flag==1 else 'No')
    





if __name__ == "__main__":
    main()

Solution (Python):
a = [i for i in map(int, input().split())]
b = [i for i in map(int, input().split())]
c = [i for i in map(int, input().split())]

n = int(input())

for i in range(n):
    num = int(input())
    for j in range(3):
        if a[j] == num:
            a[j] = 0
        if b[j] == num:
            b[j] = 0
        if c[j] == num:
            c[j] = 0

ans = "No"
if max(a) == 0:
    ans = "Yes"
if max(b) == 0:
    ans = "Yes"
if max(c) == 0:
    ans = "Yes"

if (a[0] == 0) and (b[1] == 0) and (c[2] == 0):
    ans = "Yes"
if (a[2] == 0) and (b[1] == 0) and (c[0] == 0):
    ans = "Yes"
if (a[0] == 0) and (b[0] == 0) and (c[0] == 0):
    ans = "Yes"
if (a[1] == 0) and (b[1] == 0) and (c[1] == 0):
    ans = "Yes"
if (a[2] == 0) and (b[2] == 0) and (c[2] == 0):
    ans = "Yes"
print(ans)

Solution (Python):
l=[int(s) for s in input().split()]
for i in range(2):
  ls=[int(s) for s in input().split()]
  for j in ls:
    l.append(j)
n=int(input())
for i in range(n):
  num=int(input())
  if num in l:
    l[l.index(num)]=0
    
if l[0]+l[1]+l[2]==0 or l[3]+l[4]+l[5]==0 or l[6]+l[7]+l[8]==0:
  print("Yes")
elif l[0]+l[3]+l[6]==0 or l[1]+l[4]+l[7]==0 or l[2]+l[5]+l[8]==0:
  print("Yes")
elif l[0]+l[4]+l[8]==0 or l[2]+l[4]+l[6]==0:
  print("Yes")
else:
  print("No")

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

List_C = [[0,0,0] for i in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if List_B[i] == List_A[j][k]:
                List_C[j][k] = 1
                
result = 'No'

for i in range(3):
    if List_C[i][0] * List_C[i][1] * List_C[i][2] == 1:
        result = 'Yes'
    if List_C[0][i] * List_C[1][i] * List_C[2][i] == 1:
        result = 'Yes'
    if List_C[0][0] * List_C[1][1] * List_C[2][2] == 1:
        result = 'Yes'
    if List_C[0][2] * List_C[1][1] * List_C[2][0] == 1:
        result = 'Yes'

print(result)

Solution (Python):
arr = []
for i in range(3):
	te = list(map(int,input().split()))
	arr.append(te)
n = int(input())
check = []
for i in range(n):
	x = int(input())
	for j in range(3):
		for k in range(3):
			if arr[j][k]==x:
				arr[j][k] = 0
yes = False
for j in range(3):
	c = 0
	for k in range(3):
		if arr[j][k]==0:
			c+=1
	if c==3:
		yes = True
		break
	
if yes==False:
	for j in range(3):
		c = 0
		for k in range(3):
			if arr[k][j]==0:
				c+=1
		if c==3:
			yes = True
			break
if yes==False:
	c = 0
	for j in range(3):		
		if arr[j][j]==0:
			c+=1
	if c==3:
		yes = True
if yes==False:
	c = 0
	for j in range(3):		
		if arr[j][2-j]==0:
			c+=1
	if c==3:
		yes = True
if yes:
	print("Yes")
else:
	print("No")

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


for bi in b:
    if bi in A:
        ind = A.index(bi)
        if bi:
            A[ind] = 0

zeros = [0, 0, 0]
if (
    A[::4] == zeros
    or A[2:7:2] == zeros
    or A[0:3] == zeros
    or A[3:6] == zeros
    or A[6:9] == zeros
    or A[0::3] == zeros
    or A[1::3] == zeros
    or A[2::3] == zeros
):
    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)] 

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

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == A[j][k]:
                bingo[j][k] = 1
                
import sys

if bingo[0][0] == bingo[0][1] and bingo[0][1] == bingo[0][2] and bingo[0][0] == 1:
    print('Yes')
    sys.exit()
if bingo[1][0] == bingo[1][1] and bingo[1][1] == bingo[1][2] and bingo[1][0] == 1:
    print('Yes')
    sys.exit()
if bingo[2][0] == bingo[2][1] and bingo[2][1] == bingo[2][2] and bingo[2][0] == 1:
    print('Yes')
    sys.exit()
if bingo[0][0] == bingo[1][0] and bingo[1][0] == bingo[2][0] and bingo[0][0] == 1:
    print('Yes')
    sys.exit()
if bingo[0][1] == bingo[1][1] and bingo[1][1] == bingo[2][1] and bingo[0][1] == 1:
    print('Yes')
    sys.exit()
if bingo[0][2] == bingo[1][2] and bingo[1][2] == bingo[2][2] and bingo[0][2] == 1:
    print('Yes')
    sys.exit()
if bingo[0][0] == bingo[1][1] and bingo[1][1] == bingo[2][2] and bingo[0][0] == 1:
    print('Yes')
    sys.exit()
if bingo[0][2] == bingo[1][1] and bingo[1][1] == bingo[2][0] and bingo[0][2] == 1:
    print('Yes')
    sys.exit()
    
print('No')

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

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

ans = "No"
for i in range(3):
    if sum(A[i]) == 0:
        ans = "Yes"

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

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

print(ans)

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

ans=0

cands =[]
for i in range(3):
    cand = a[i]
    cands.append(cand) 

for i in range(3):
    cand=[a[j][i] for j in range(3)]
    cands.append(cand) 

        
cand = [ a[i][i] for i in range(3)]
cands.append(cand) 

cand = [ a[i][2-i] for i in range(3)]
cands.append(cand) 

ans=0
for c in cands:
    ans0=[(cc in b) for cc in c]
    if sum(ans0) ==3:
        ans=1
    
if ans==1:
    print("Yes")
else:
    print("No")

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

    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],
    ]
    
    
    l = []
    for i in range(3):
        for j in range(3):
            l.append(A[i][j])

    for i in range(9):
        for b in B:
            if l[i] == b:
                l[i] = 0
                    
        
    ans = 'No'
    for a, b, c in lines:
        if l[a] == 0 and l[b] == 0 and l[c] == 0:
            ans = 'Yes'
            break

    return ans

print(solve())

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
for x in b:
    for i in range(3):
        for j in range(3):
            if x == A[i][j]:
                A[i][j] = '*'
if ( A[0][0]==A[0][1]==A[0][2]=='*'
        or A[1][0]==A[1][1]==A[1][2]=='*'
        or A[2][0]==A[2][1]==A[2][2]=='*'
        or A[0][0]==A[1][0]==A[2][0]=='*'
        or A[0][1]==A[1][1]==A[2][1]=='*'
        or A[0][2]==A[1][2]==A[2][2]=='*'
        or A[0][0]==A[1][1]==A[2][2]=='*'
        or A[0][2]==A[1][1]==A[2][0]=='*' ):
            print('Yes')
else:
    print('No')

Solution (Python):
flags = [False for i in range(9)]
rows = []
for i in range(3):
    rows += list(map(int, input().split()))
N = int(input())
for ii in range(N):
    b = int(input())
    for i in range(9):
        if b == rows[i]:
            flags[i] = True
ans = False

for r in range(3):
    base = r*3
    
    if sum(flags[base:base+3:1]) == 3:
        ans = True
    
    if sum(flags[r::3]) == 3:
        ans = True

if sum(flags[0::4]) == 3:
    ans = True

if sum(flags[2:7:2]) == 3:
    ans = True
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):






from sys import stdin,setrecursionlimit










setrecursionlimit(10**6+1)
input=stdin.readline

def s(l,t):
    for i in range(3):
        for j in range(3):
            if l[i][j]==t:
                return True
    return False

a=[list(map(int,input().split())) for _ in range(3)]
n=int(input().rstrip())
ans="No"
res=[[False]*3 for _ in range(3)]
for _ in range(n):
    b=int(input().rstrip())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                res[i][j]=True
                break

for i in range(3):
    if False not in res[i]:
        print("Yes")
        exit()

for i in range(3):
    cnt=0
    for j in range(3):
        if res[j][i]:
            cnt+=1
    if cnt==3:
        print("Yes")
        exit()
cnt=0
for i in range(3):
    cnt+=int(res[i][i])
if cnt==3:
    print("Yes")
    exit()

cnt=0
cnt+=int(res[0][2])+int(res[1][1])+res[2][0]
if cnt==3:
    print("Yes")
else:
    print("No")

Solution (Python):
a_11, a_12, a_13 = map(int, input().split())
a_21, a_22, a_23 = map(int, input().split())
a_31, a_32, a_33 = map(int, input().split())
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))

_1 = [a_11, a_12, a_13]
_2 = [a_21, a_22, a_23]
_3 = [a_31, a_32, a_33]
_4 = [a_11, a_21, a_31]
_5 = [a_12, a_22, a_32]
_6 = [a_13, a_23, a_33]
_7 = [a_11, a_22, a_33]
_8 = [a_31, a_22, a_13]

def list_check2(list1, list2):
    return set(list1).issubset(list2)

is_contain = False
for i in [_1, _2, _3, _4, _5, _6, _7, _8]:
    if list_check2(i, b):
        is_contain = True
        break

if is_contain:
    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)]

for i in range(3):
    if all(a[i][j] in b for j in range(3)):
        print("Yes")
        quit()
    if all(a[j][i] in b for j in range(3)):
        print("Yes")
        quit()
if all(a[i][i] in b for i in range(3)):
    print("Yes")
    quit()
if all(a[i][2-i] in b for i in range(3)):
    print("Yes")
    quit()

print("No")

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

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

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

bingmap = list(map(lambda x:x in nl,bingo))

for bing_index in bing_indexs:
    for i,num in enumerate(bing_index):
        if(not bingmap[num]):
            break
        if(i==2):
            print("Yes")
            exit(0)

print("No")

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

for _ in range(n):
    b=int(input())
    if b in a:
        c=a.index(b)
        sheet[c]=1
bingo=[[0,3,6],[1,4,7],[2,5,8],[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6]]
flg=0
for bb in bingo:
    if sheet[bb[0]]==1:
        if sheet[bb[1]]==1:
            if sheet[bb[2]]==1:
                flg=1
if flg==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    A = [list(map(int,input().split())) for _ in range(3)]
    hit = [['n'] * 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 A[i][j] == b:
                    hit[i][j] = 'y'

    correct = ['y'] * 3
    for i in range(3):
        row = hit[i]

        if row == correct:
            print('Yes')
            quit()

        vert = [hit[x][i] for x in range(3)]
        if vert == correct:
            print('Yes')
            quit()

    ri = [hit[0][0], hit[1][1], hit[2][2]]
    if ri == correct:
        print('Yes')
        quit()

    le = [hit[2][0], hit[1][1], hit[2][0]]
    if le == correct:
        print('Yes')
        quit()
    print('No')


if __name__ == "__main__":
    main()

Solution (Python):
import itertools
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
m = a + b + c
ok = []
tg = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
n = int(input())
bng = []
for _ in range(n):
    bng.append(int(input()))
for i in range(9):
    if m[i] in bng:
        ok.append(i)
ok = sorted(ok)
ans = itertools.permutations(ok, 3)
flag = 0
for i in ans:
    if list(i) in tg:
        flag += 1
if flag > 0:
    print("Yes")
else:
    print("No")

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

flg = False

for i in range(3):
    if a[0][i] in b:
        if a[1][i] in b:
            if a[2][i] in b:
                flg = True
                break

for i in range(3):
    if a[i][0] in b:
        if a[i][1] in b:
            if a[i][2] in b:
                flg = True
                break


if a[0][0] in b:
    if a[1][1] in b:
        if a[2][2] in b:
            flg = True

if a[0][2] in b:
    if a[1][1] in b:
        if a[2][0] in b:
            flg = True

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

Solution (Python):
bingo=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for _ in range(N)]
for i in range(3):
  for b in B:
    if bingo[i][0]==b:
      bingo[i][0]="!"
    if bingo[i][1]==b:
      bingo[i][1]="!"
    if bingo[i][2]==b:
      bingo[i][2]="!"
for j in range(3):
  if bingo[j][0]==bingo[j][1]==bingo[j][2]=="!":
    print("Yes")
    exit()
  if bingo[0][j]==bingo[1][j]==bingo[2][j]=="!":
    print("Yes")
    exit()
  if bingo[0][0]==bingo[1][1]==bingo[2][2]=="!":
    print("Yes")
    exit()
  if bingo[0][2]==bingo[1][1]==bingo[2][0]=="!":
    print("Yes")
    exit()
print("No")

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A = [[int(i) for i in input().split()] for j in range(3)]
    N = int(readline())

    ans = [[0]*3 for _ in range(3)]
    for i in range(N):
        b = int(readline())
        for j, a in enumerate(A):
            for k, a_ in enumerate(a):
                if b == a_:
                    ans[j][k] = 1

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

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

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


for i in range(3):
    if A1[i] == -1 and A2[i] == -1 and A3[i] == -1:
        print("Yes")
        exit()


if A1[0] == -1 and A1[1] == -1 and A1[2] == -1:
    print("Yes")
    exit()
if A2[0] == -1 and A2[1] == -1 and A2[2] == -1:
    print("Yes")
    exit()
if A3[0] == -1 and A3[1] == -1 and A3[2] == -1:
    print("Yes")
    exit()


if A1[0] == -1 and A2[1] == -1 and A3[2] == -1:
    print("Yes")
    exit()

if A1[2] == -1 and A2[1] == -1 and A3[0] == -1:
    print("Yes")
    exit()

print("No")

Solution (Python):
row1 = list(map(int, input().split(" ")))
row2 = list(map(int, input().split(" ")))
row3 = list(map(int, input().split(" ")))
col1 = [row1[0]] + [row2[0]] + [row3[0]] 
col2 = [row1[1]] + [row2[1]] + [row3[1]] 
col3 = [row1[2]] + [row2[2]] + [row3[2]]
cr_r = [row1[0]] + [row2[1]] + [row3[2]]
cr_l = [row1[2]] + [row2[1]] + [row3[0]]

n = int(input())
for _ in range(n):
  b = int(input())
  if b in row1:
    row1 = [n for n in row1 if n != b]
  if b in row2:
    row2 = [n for n in row2 if n != b]
  if b in row3:
    row3 = [n for n in row3 if n != b]

  if b in col1:
    col1 = [n for n in col1 if n != b]
  if b in col2:
    col2 = [n for n in col2 if n != b]
  if b in col3:
    col3 = [n for n in col3 if n != b]

  if b in cr_r:
    cr_r = [n for n in cr_r if n != b]
  if b in cr_l:
    cr_l = [n for n in cr_l if n != b]

if not row1 or not row2 or not row3 or not col1 or not col2 or not col3 or not cr_r or not cr_l:
  print("Yes")
else:
  print("No")

Solution (Python):
def modify_flags(flags, temp):
  num_idx = temp[0]*3+temp[1]
  corr = {0:(1,6,7), 1:(2,6), 2:(3,6,8), 3:(1,5), 4:(2,5,7,8), 5:(3,5), 6:(1,4,8), 7:(2,4), 8:(3,4,7)}
  for item in corr[num_idx]:
    flags[item-1] += 1

nums = {}
for i in range(3):
  x = [int(_) for _ in input().split(" ")]
  for j in range(3):
    nums[x[j]] = (i, j)

flags = [0]*8
N = int(input())
for i in range(N):
  temp = int(input())
  if (temp not in nums.keys()):
    continue
  modify_flags(flags, nums[temp])

rst = "No"
for item in flags:
  if (item == 3):
    rst = "Yes"
    break
print(rst)

Solution (Python):
A  = [[j for j in input().split()] for i in range(3)]
N  = input()
B  = [input() for i in range(int(N))]

s1 = len(set(A[0]) - set(B))
s2 = len(set(A[1]) - set(B))
s3 = len(set(A[2]) - set(B))
s4 = len(set([A[i][0] for i in range(3)]) - set(B))
s5 = len(set([A[i][1] for i in range(3)]) - set(B))
s6 = len(set([A[i][2] for i in range(3)]) - set(B))
s7 = len(set([A[i][i] for i in range(3)]) - set(B))
s8 = len(set([A[0][2], A[1][1], A[2][0]]) - set(B))

S  = [s1, s2, s3, s4, s5, s6, s7, s8]
if 0 in S:
  print('Yes')
else:
  print('No')

Solution (Python):

import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A = []
A.extend(map(int, readline().split()))
A.extend(map(int, readline().split()))
A.extend(map(int, readline().split()))

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

N = int(readline().strip())

for _ in range(0, N):
    b = int(readline().strip())
    for i, number in enumerate(A):
        if b == number:
            bingo[i] = 1

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

Solution (Python):
import sys
input = sys.stdin.readline

a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
a3 = [int(i) for i in input().split()]

n = int(input())

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

for v in b:
    try:
        i = a1.index(v)
        a1[i] = 0
        continue
    except:
        pass
    try:
        i = a2.index(v)
        a2[i] = 0
        continue
    except:
        pass
    try:
        i = a3.index(v)
        a3[i] = 0
        continue
    except:
        pass

def cond():
    if a1[0] == 0 and a1[1] == 0 and a1[2] == 0:
        return True
    if a2[0] == 0 and a2[1] == 0 and a2[2] == 0:
        return True
    if a3[0] == 0 and a3[1] == 0 and a3[2] == 0:
        return True
    if a1[0] == 0 and a2[0] == 0 and a3[0] == 0:
        return True
    if a1[1] == 0 and a2[1] == 0 and a3[1] == 0:
        return True
    if a1[2] == 0 and a2[2] == 0 and a3[2] == 0:
        return True
    if a1[0] == 0 and a2[1] == 0 and a3[2] == 0:
        return True
    if a1[2] == 0 and a2[1] == 0 and a3[0] == 0:
        return True
    return False

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