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):
bingo = [ input().split() for j in range(3)]
N = int(input())
b = []
for n in range(N):
	b.append(input())
for x in range(N):
	for i in range(3):
		for j in range(3):
			if bingo[i][j] == b[x]:
				bingo[i][j] = 'OK'
if bingo[0][0] == 'OK' and bingo[0][1] == 'OK' and bingo[0][2] == 'OK':
	print('Yes')
elif bingo[1][0] == 'OK' and bingo[1][1] == 'OK' and bingo[1][2] == 'OK':
	print('Yes')
elif bingo[2][0] == 'OK' and bingo[2][1] == 'OK' and bingo[2][2] == 'OK':
	print('Yes')
elif bingo[0][1] == 'OK' and bingo[1][1] == 'OK' and bingo[2][1] == 'OK':
	print('Yes')
elif bingo[0][0] == 'OK' and bingo[1][0] == 'OK' and bingo[2][0] == 'OK':
	print('Yes')
elif bingo[0][2] == 'OK' and bingo[1][2] == 'OK' and bingo[2][2] == 'OK':
	print('Yes')
elif bingo[0][0] == 'OK' and bingo[1][1] == 'OK' and bingo[2][2] == 'OK':
	print('Yes')
elif bingo[0][2] == 'OK' and bingo[1][1] == 'OK' and bingo[2][0] == 'OK':
	print('Yes')
else:
	print('No')

Solution (Python):
def q2(data, num_list):
    data = [int(num) for d in data for num in d.split()]
    num_list = [int(n) for n in num_list]

    for num in num_list:
        data = [d if d != num else 0 for d in data]
        if check_bingo(data):
            return 'Yes'

    else:
        return 'No'


def check_bingo(data):
    
    if sum(data[:3]) == 0: return True
    if sum(data[3:6]) == 0: return True
    if sum(data[6:]) == 0: return True
    if sum([data[0], data[3], data[6]]) == 0: return True
    if sum([data[3*i+1] for i in range(3)]) == 0: return True
    if sum([data[3*i + 2] for i in range(3)]) == 0: return True
    if sum([data[0], data[4], data[8]]) == 0: return True
    if sum([data[2], data[4], data[6]]) == 0: return True

    return False
  

data = [input() for _ in range(3)]

num = int(input())

num_list = [int(input()) for _ in range(num)]

print(q2(data, num_list))

Solution (Python):


import sys

DEBUG = False

def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return

def printbingo(bingo):
    if not DEBUG:
        return
    for y in range(0, 3):
        for x in range(0, 3):
            print(bingo[y][x], end=" ")
        print()


def main():
    bingo = [[]] * 3
    bingo[0] = read_int_list()
    bingo[1] = read_int_list()
    bingo[2] = read_int_list()
    locs = {}
    for y in range(0, 3):
        for x in range(0, 3):
            locs[bingo[y][x]] = (y, x)
    printbingo(bingo)
            
    n = read_int()
    for _ in range(0, n):
        b = read_int()
        if b in locs:
            bingo[locs[b][0]][locs[b][1]] = -1
    printbingo(bingo)
    
    
    for y in range(0, 3):
        is_bingo = True
        for x in range(0, 3):
            if bingo[y][x] != -1:
                is_bingo = False
                break
        if is_bingo:
            print("Yes")
            return
    
    for x in range(0, 3):
        is_bingo = True
        for y in range(0, 3):
            if bingo[y][x] != -1:
                is_bingo = False
                break
        if is_bingo:
            print("Yes")
            return
    
    for (y, x), (dy, dx) in [((0, 0), (1, 1)), ((0, 2), (1, -1))]:
        is_bingo = True
        while is_bingo and 0 <= y < 3 and 0 <= x < 3:
            
            if bingo[y][x] != -1:
                is_bingo = False
                break
            y += dy
            x += dx
        if is_bingo:
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()

Solution (Python):
A11,A12,A13 = map(int, input().split())

A21,A22,A23 = map(int, input().split())

A31,A32,A33 = map(int, input().split())

A1 = [A11, A12, A13]
A2 = [A21, A22, A23]
A3 = [A31, A32, A33]

B1 = [0, 0, 0]
B2 = [0, 0, 0]
B3 = [0, 0, 0]

N = input()
N = int(N)

b = list(range(N))

for l in b:
    b[l] = input()
    b[l] = int(b[l])

for i in range(N):
    if b[i] == A1[0]:
        B1[0] = 1
    elif b[i] == A1[1]:
        B1[1] = 1
    elif b[i] == A1[2]:
        B1[2] = 1
    elif b[i] == A2[0]:
        B2[0] = 1
    elif b[i] == A2[1]:
        B2[1] = 1
    elif b[i] == A2[2]:
        B2[2] = 1
    elif b[i] == A3[0]:
        B3[0] = 1
    elif b[i] == A3[1]:
        B3[1] = 1
    elif b[i] == A3[2]:
        B3[2] = 1

Bingo = 0

if B1[0] == 1 and B1[1] == 1 and B1[2] == 1:
    Bingo = 1
elif B2[0] == 1 and B2[1] == 1 and B2[2] == 1:
    Bingo = 1
elif B3[0] == 1 and B3[1] == 1 and B3[2] == 1:
    Bingo = 1
elif B1[0] == 1 and B2[0] == 1 and B3[0] == 1:
    Bingo = 1
elif B1[1] == 1 and B2[1] == 1 and B3[1] == 1:
    Bingo = 1
elif B1[2] == 1 and B2[2] == 1 and B3[2] == 1:
    Bingo = 1
elif B1[0] == 1 and B2[1] == 1 and B3[2] == 1:
    Bingo = 1
elif B1[2] == 1 and B2[1] == 1 and B3[0] == 1:
    Bingo = 1

if Bingo == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
ary=[]
ary_=[]
num=[]
for i in range(3):
    lst=input().split()
    ary.append(lst)
n=int(input())
for i in range(n):
    num.append(input())

for i in range(3):
    for j in range(3):
        for k in num:
            if ary[i][j]==k:
                ary[i][j]=0

for i in range(3):
    if set(ary[i])=={0}:
        print('Yes')
        exit()
    elif ary[0][i]==0 and ary[0][i]==ary[1][i] and ary[2][i]==ary[0][i]:
        print('Yes')
        exit()
if ary[0][0]==0 and ary[1][1]==ary[0][0] and ary[2][2]==ary[0][0]:
    print('Yes')
    
elif ary[2][0]==0 and ary[2][0]==ary[1][1] and ary[1][1]==ary[0][2]:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
A = np.zeros((3,3), dtype = "int")
A[0,0], A[0,1], A[0,2] = map(int,input().split())
A[1,0], A[1,1], A[1,2] = map(int,input().split())
A[2,0], A[2,1], A[2,2] = map(int,input().split())
N= int(input())
b = [int(input()) for i in range(N)]
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
if (A[0,0] == 0 and A[0,1] == 0 and A[0,2] ==0) or (A[1,0] == 0 and A[1,1] == 0 and A[1,2] == 0) or (A[2,0] ==0 and A[2,1] ==0 and A[2,2] == 0) or (A[0,0] == 0 and A[1,1] == 0 and A[2,2] == 0) or (A[2,0] == 0 and A[1,1] == 0 and A[0,2] == 0) or (A[0,0] == 0 and A[1,0] == 0 and A[2,0] == 0) or (A[0,1] == 0 and A[1,1] == 0 and A[2,1] == 0) or (A[0,2] == 0 and A[1,2] == 0 and A[2,2] == 0):
	print("Yes")
else:
	print("No")

Solution (Python):
import sys

l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n = int(input())
if n < 3:
  print("No")
  sys.exit()

l = [int(input()) for i in range(n)]
if (l1[0] in l and l1[1] in l and l1[2] in l) or (l2[0] in l and l2[1] in l and l2[2] in l) or (l3[0] in l and l3[1] in l and l3[2] in l) or (l1[0] in l and l2[0] in l and l3[0] in l) or (l1[1] in l and l2[1] in l and l3[1] in l) or (l1[2] in l and l2[2] in l and l3[2] in l) or (l1[0] in l and l2[1] in l and l3[2] in l) or (l1[2] in l and l2[1] in l and l3[0] in l):
  print("Yes")
  sys.exit()
else:
  print("No")

Solution (Python):
AAs = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
Bs = [int(input()) for _ in range(N)]
CCs = [
    [False, False, False],
    [False, False, False],
    [False, False, False],
]

for b in Bs:
    for x in range(3):
        for y in range(3):
            if AAs[x][y] == b:
                CCs[x][y] = True

def check():
    for cs in CCs:
        if all(cs): 
            return True
    for cs in list(map(list, zip(*CCs))):
        if all(cs): 
            return True
    if CCs[0][0] and CCs[1][1] and CCs[2][2]:
        return True
    if CCs[0][2] and CCs[1][1] and CCs[2][0]:
        return True

    return False

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

Solution (Python):
H1 = [int(i) for i in input().split()]
H2 = [int(i) for i in input().split()]
H3 = [int(i) for i in input().split()]
N = int(input())
num = [int(input()) for i in range(N)]

L1 = [H1[0], H2[0], H3[0]]
L2 = [H1[1], H2[1], H3[1]]
L3 = [H1[2], H2[2], H3[2]]

S1 =[H1[0], H2[1], H3[2]]
S2 = [H1[2], H2[1], H3[0]]

ans = []
for i in [H1,H2,H3,L1,L2,L3,S1,S2]:
    i.extend(num)

ans = []
for i in [H1,H2,H3,L1,L2,L3,S1,S2]:
    ans.append(len(set(i)))

if min(ans) == N:
    print("Yes")
else:
    print("No")

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

Solution (Python):
l = []
flag = 0
for i in range(3):
  for j in input().split():
    l.append(j)
n = int(input())
for i in range(n):
  a = input()
  if a in l:
    l[l.index(a)] = 0
if not any(l[0:3])  or not any(l[3:6]) or not any(l[6:9]):
  flag = 1
if not any(l[0::3]) or not any(l[1::3]) or not any(l[2::3]):
  flag = 1
if not any(l[0::4]) or not any(l[2:7:2]):
  flag = 1
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
import itertools
A=[list(map(int,input().split())) for i in range(3)]
A=list(itertools.chain.from_iterable(A))
N=int(input())
for _ in range(N):
    b=int(input())
    try:
        A[A.index(b)]="X"
    except:
        continue
answer="No"
for bingo in [[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6],[0,3,6],[1,4,7],[2,5,8]]:
    if A[bingo[0]]=="X" and A[bingo[1]]=="X" and A[bingo[2]]=="X":
        answer="Yes"
print(answer)

Solution (Python):
import sys
a = []
b = []
c = [[False for i in range(3)] for i in range(3)]
for i in range(3):
    a.append(list(map(int, input().split())))

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

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

for i in range(3):
    if c[i] == [True, True, True]:
        print("Yes")
        sys.exit(0)

for i in range(3):
    if [c[0][i], c[1][i], c[2][i]] == [True, True, True]:
        print("Yes")
        sys.exit(0)

if [c[0][0], c[1][1], c[2][2]] == [True, True, True] or [c[0][2], c[1][1], c[2][0]] == [True, True, True]:
    print("Yes")
    sys.exit(0)
print("No")

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
B = [int(input()) for i in range(n)]
C = []
for a in A:
    a = ['o' if x in B else x for x in a]
    C.append(a)
for c in C:
    if c==['o','o','o']:
        print('Yes')
        exit()
for c in zip(*C):
    if list(c)==['o','o','o']:
        print('Yes')
        exit()
if C[0][0]==C[1][1]==C[2][2]=='o' or C[0][2]==C[1][1]==C[2][0]=='o':
    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()))
temp_list = []
temp_list.append(A1)
temp_list.append(A2)
temp_list.append(A3)

bingo_list = [[0 for i in range(3)] for j in range(3)]

N = int(input())
for _ in range(N):
    temp = int(input())
    if (temp in A1):
      bingo_list[0][A1.index(temp)] = 1
    if (temp in A2):
      bingo_list[1][A2.index(temp)] = 1
    if (temp in A3):
      bingo_list[2][A3.index(temp)] = 1

if sum(bingo_list[0]) == 3 or sum(bingo_list[1]) == 3 or sum(bingo_list[2]) == 3 or (bingo_list[0][0]+(bingo_list[1][0])+(bingo_list[2][0])) == 3 or (bingo_list[0][1]+(bingo_list[1][1])+(bingo_list[2][1])) == 3 or (bingo_list[0][2]+(bingo_list[1][2])+(bingo_list[2][2])) == 3:
    print("Yes")
elif (bingo_list[0][0]+(bingo_list[1][1])+(bingo_list[2][2])) == 3 or (bingo_list[0][2]+(bingo_list[1][1])+(bingo_list[2][0])) == 3:
    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 num in b:
    for i in range(len(a)):
        for j in range(len(a[i])):
            if a[i][j] == num:
                a[i][j] = 'O'
                
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][1] == a[2][2]) or (a[0][2] == a[1][1] == a[2][0])\
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]):
    print('Yes')
else:
    print('No')

Solution (Python):
rows = []
for i in range(3):
    row = [int(x) for x in input().split()]
    rows.append(row)


columns = []
for k in range(3):
    column = [rows[l][k] for l in range(3)]
    columns.append(column)

left = []
for m in range(3):
    left.append(rows[m][m])

right = []
o = 2
for n in range(3):
    right.append(rows[n][o])
    o -= 1


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


matches = []
for row in rows:
    matches.append([c for c in row if c in choice])

for column in columns:
    matches.append([c for c in column if c in choice])

matches.append([c for c in left if c in choice])
matches.append([c for c in right if c in choice])


isPrinted = False
for match in matches:
    if (len(match) == 3):
        print("Yes")
        isPrinted = True
        break

if (not isPrinted):
    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())
b = np.array([])
for _ in range(N):
    b = np.append(b, int(input()))
    
A = np.array([A1, A2, A3])
index = np.zeros((3,3))
for i in b:
  index += np.array(A==i, dtype=np.int)
retu = np.sum(index, axis=0)
gyou = np.sum(index, axis=1)
if np.any(retu >= 3):
  ans1 = 1
else:
  ans1 = 0

if np.any(gyou >= 3):
  ans2 = 1
else:
  ans2 = 0
  

if np.trace(index) >= 3:
  ans3 = 1
else:
  ans3 = 0
index = index[:, ::-1]
if np.trace(index) >= 3:
  ans4 = 1
else:
  ans4 = 0

y = ans1 + ans2 + ans3 + ans4
if y == 0:
  print("No")
else:
  print("Yes")

Solution (Python):
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
N = int(input())

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

for j in num_list:
    if a == j:
        a = 101
    if b == j:
        b = 101
    if c == j:
        c = 101
    if d == j:
        d = 101
    if e == j:
        e = 101
    if f == j:
        f = 101
    if g == j:
        g = 101
    if h == j:
        h = 101
    if i == j:
        i = 101

answer = 'No'
if a + b + c == 303:
    answer = 'Yes'
if d + e + f == 303:
    answer = 'Yes'
if g + h + i == 303:
    answer = 'Yes'
if a + d + g == 303:
    answer = 'Yes'
if b + e + h == 303:
    answer = 'Yes'
if c + f + i == 303:
    answer = 'Yes'
if a + e + i == 303:
    answer = 'Yes'
if c + e + g == 303:
    answer = 'Yes'

print(answer)

Solution (Python):
import sys

a = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]
n, *b = map(int, sys.stdin.read().split())
b = set(b)

def main():
    res = [[False] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                res[i][j] = True
    
    for i in range(3):
        for j in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for j in range(3):
        for i in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for i, j in zip(range(3), range(3)):
        if not res[i][j]:
            break
    else:
        return 'Yes'
    
    for i, j in zip(range(3), range(2, -1, -1)):
        if not res[i][j]:
            break
    else:
        return 'Yes'
    
    return 'No'

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
lines = [input().split() for i in range(3)]
 
num = int(input())
bs = []
for i in range(num):
  bs.append(input())
 
hits = []
for i in bs:
  for row_index in range(len(lines)):
    for col_index in range(len(lines[row_index])):
      if lines[row_index][col_index] == i:
        hits.append((row_index,col_index))
row_hits = [0,0,0]
col_hits = [0,0,0]
stride_hits = [0,0]
 
for hit in hits:
  r = hit[0]
  c = hit[1]
  row_hits[r]+=1
  col_hits[c]+=1
  if r == c:
    stride_hits[0]+=1
  if (r,c) == (0,2) or (r,c) == (1,1) or (r,c) == (2,0) :
    stride_hits[1]+=1
 
if max(row_hits)>= 3 or max(col_hits)>=3 or max(stride_hits)>= 3:
  print ('Yes')
else:
  print ('No')

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

n = int(input())
b = [int(input()) for i in range(n)]
c = []
for ii in range(n):
    for iii in range(9):
        if b[ii] == l[iii]:
            c.append(iii)
            break
flag = 'No'
for i in range(3):
    if 3*i in c and 3*i+1 in c and 3*i+2 in c:
        flag = 'Yes'
        break
    if i in c and 3+i in c and 6+i in c:
        flag = 'Yes'
        break
if 0 in c and 4 in c and 8 in c:
    flag = 'Yes'
elif 2 in c and 4 in c and 6 in c:
    flag = 'Yes'

print(flag)

Solution (Python):
import numpy as np

def in1d(ar1, ar2, assume_unique=False, invert=False):
    
    ar1 = np.asarray(ar1).ravel()
    ar2 = np.asarray(ar2).ravel()

    
    contains_object = ar1.dtype.hasobject or ar2.dtype.hasobject

    
    
    
    
    if len(ar2) < 10 * len(ar1) ** 0.145 or contains_object:
        if invert:
            mask = np.ones(len(ar1), dtype=bool)
            for a in ar2:
                mask &= (ar1 != a)
        else:
            mask = np.zeros(len(ar1), dtype=bool)
            for a in ar2:
                mask |= (ar1 == a)
        return mask

    
    if not assume_unique:
        ar1, rev_idx = np.unique(ar1, return_inverse=True)
        ar2 = np.unique(ar2)

    ar = np.concatenate((ar1, ar2))
    
    
    
    order = ar.argsort(kind='mergesort')
    sar = ar[order]
    if invert:
        bool_ar = (sar[1:] != sar[:-1])
    else:
        bool_ar = (sar[1:] == sar[:-1])
    flag = np.concatenate((bool_ar, [invert]))
    ret = np.empty(ar.shape, dtype=bool)
    ret[order] = flag

    if assume_unique:
        return ret[:len(ar1)]
    else:
        return ret[rev_idx]

def isin(element, test_elements, assume_unique=False, invert=False):
    element = np.asarray(element)
    return in1d(element, test_elements, assume_unique=assume_unique,
                invert=invert).reshape(element.shape)
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
T = isin(A,b)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).any()
ans[1]=T.all(axis=1).any()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
if any(ans):
    print('Yes')
else:
    print('No')

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


def create_bingo_card():
  result = [[0, 0, 0] for x in range(3)]
  i = 0
  while True:
    i2 = 0
    while True:
      if bs[i2] in As[i]:
        result[i][As[i].index(bs[i2])] += 1
      i2 += 1
      if i2 == len(bs):
        break
    i += 1
    if i == len(As):
      break
  return result


def solvd(bingo):
  tmp = [bingo[0][0], bingo[1][1], bingo[2][2]]
  if check1(tmp):
    print("Yes")
    return

  tmp = [bingo[0][2], bingo[1][1], bingo[2][0]]
  if check1(tmp):
    print("Yes")
    return

  r = 0
  for x in range(3):
    tmp = [bingo[0][x], bingo[1][x], bingo[2][x]]
    if check1(tmp):
      print("Yes")
      return

    bingoSet = set(bingo[x])
    if check2(bingoSet):
      r += 1

  if r >= 1:
    print("Yes")
    return
  print("No")


def check1(s):
  return s.count(1) == 3


def check2(s):
  return not (0 in list(s))


def main():
  Cs = create_bingo_card()
  solvd(Cs)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    re_dict_nums = dict()
    done_list = [0 for _ in range(9)]
    cnt = 0
    for _ in range(3):
        for s in map(int, input().split(' ')):
            re_dict_nums[s] = cnt
            cnt += 1
    for n in range(int(input())):
        try:
            done_list[re_dict_nums[int(input())]] = 1
        except KeyError:
            pass
    flag = False
    if done_list[4] == 1:
        if (done_list[0] == 1 and done_list[8] == 1) or (done_list[1] == 1 and done_list[7] == 1) or (
                done_list[2] == 1 and done_list[6] == 1) or 0 not in done_list[3:6]:
            flag = True
    if flag is False:
        if (0 not in done_list[:3]) or (0 not in done_list[6:]) or (
                done_list[0] == 1 and done_list[3] == 1 and done_list[6] == 1) or (
                done_list[2] == 1 and done_list[5] == 1 and done_list[8] == 1):
            flag = True
    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    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(3):
        for j in range(3):
            if a[i][j] in b:
                c[i][j]=1

    ans='No'
    for i in range(3):
        if c[i]==[1,1,1]:
            ans='Yes'
    for i in range(3):
        if [c[0][i],c[1][i],c[2][i]]==[1,1,1]:
            ans='Yes'
    if [c[0][0],c[1][1],c[2][2]]==[1,1,1]:
        ans='Yes'
    if [c[0][2],c[1][1],c[2][0]]==[1,1,1]:
        ans='Yes'
    print(ans)
resolve()

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

n=int(input())

for _ in range(n):
    x=int(input())
    for i in range(3):
        for j in range(3):
            if x==A[i][j]:
                A[i][j]=0
ans='No'
if A[1][1]==0:
    if A[0][0]==0 and A[2][2]==0:
        ans='Yes'
    if A[0][2]==0 and A[2][0]==0:
        ans='Yes'

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

Solution (Python):
x=[[]*3]*3
o=[[0] * 3 for i in range(3)]

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

n=int(input())

for i in range(0,n):
  b=int(input())
  for j in range(0,3):
    for k in range(0,3):
      if x[j][k]==b:
        o[j][k]=1

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

  if o[0][i]==1 and o[1][i]==1 and o[2][i]==1:
    print("Yes")
    exit()

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

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

Solution (Python):
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())

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

n = 0
o = 0
p = 0
q = 0
r = 0
s = 0
t = 0
u = 0


for i in num:
    if i in [A[0],A[1],A[2]]:
        n += 1
for j in num:
    if j in [B[0],B[1],B[2]]:
        t += 1
for k in num:
    if k in [C[0],C[1],C[2]]:
        u += 1
for l in num:
    if l in [A[0],B[0],C[0]]:
        o += 1
for m in num:
    if m in [A[1],B[1],C[1]]:
        p += 1
for v in num:
    if v in [A[2],B[2],C[2]]:
        q += 1
for w in num:
    if w in [A[0],B[1],C[2]]:
        r += 1
for x in num:
    if x in [A[2],B[1],C[0]]:
        s += 1

if n >= 3 or o >= 3 or p >= 3 or q >= 3 or r >= 3 or s >= 3 or t >= 3  or u >= 3:
    print("Yes")
else:
    print('No')

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

a.extend(b)
a.extend(c)
N = int(input())
b = [input() for i in range(N)]
for b1 in b:
    a = ['a' if b1 == s in s else s for s in a]

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

Solution (Python):
import sys
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)]
tate1=[A1[0],A2[0],A3[0]]
tate2=[A1[1],A2[1],A3[1]]
tate3=[A1[2],A2[2],A3[2]]
naname1=[A1[0],A2[1],A3[2]]
naname2=[A1[2],A2[1],A3[0]]

if A1[0] in b and A1[1] in b and A1[2] in b:
    print('Yes')
    sys.exit()
if A2[0] in b and A2[1] in b and A2[2] in b:
    print('Yes')
    sys.exit()
if A3[0] in b and A3[1] in b and A3[2] in b:
    print('Yes')
    sys.exit()
if tate1[0] in b and tate1[1] in b and tate1[2] in b:
    print('Yes')
    sys.exit()
if tate2[0] in b and tate2[1] in b and tate2[2] in b:
    print('Yes')
    sys.exit()
if tate3[0] in b and tate3[1] in b and tate3[2] in b:
    print('Yes')
    sys.exit()
if naname1[0] in b and naname1[1] in b and naname1[2] in b:
    print('Yes')
    sys.exit()
if naname2[0] in b and naname2[1] in b and naname2[2] in b:
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

a = l_in()
b = l_in()
c = l_in()
N = n_in()

s = set()

for _ in range(N):
  s.add(n_in())

def check(L):
  return all(l in s for l in L)

if any(check(L) for L in [
  a,b,c,
  [a[0],b[0],c[0]],
  [a[1],b[1],c[1]],
  [a[2],b[2],c[2]],
  [a[0],b[1],c[2]],
  [a[2],b[1],c[0]],
  ]):
  print("Yes")
else:
  print("No")

Solution (Python):
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Solution (Python):
list_1 = list(map(int,input().split()))
list_2 = list(map(int,input().split()))
list_3 = list(map(int,input().split()))




list_a=list_1


for x in list_2:
    list_a.append(x)


for x in list_3:
    list_a.append(x)


N = int(input())




list_b=[]
for k in range(N):
    b=int(input())
    list_b.append(b)


list_c = [0,0,0,0,0,0,0,0,0]
for i in range(N):
    for j in range(9):
        if list_a[j] == list_b[i]:
            list_c[j] = 1

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

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


L_tate = list(zip(*L_yoko))

L_naname = []
L_naname.append([L_yoko[0][0],L_yoko[1][1],L_yoko[2][2]])
L_naname.append([L_yoko[0][2],L_yoko[1][1],L_yoko[2][0]])

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

a = int(0)
for z in L_tate:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_yoko:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_naname:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break


if a == 0:
    print("No")
else:
    print("Yes")

Solution (Python):
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)

if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

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


def main():
	
	
	
	vAB=[tuple(map(int,input().split()))
		 for _ in [0,]*3]
	N=int(input())
	vD= [int(input()) for _ in [0,]*N]
	
	vQ = [False,] * 9
	for i in range(3):
		a,b,c = vAB[i]
		vQ[3*i+0] = a in vD
		vQ[3*i+1] = b in vD
		vQ[3*i+2] = c in vD
	
	bi = False
	if any((all(vQ[0:3]), all(vQ[3:6]),
		all(vQ[6:9]), all(vQ[0::3]),
		all(vQ[1::3]), all(vQ[2::3]),
		all((vQ[0],vQ[4],vQ[8])),
		all((vQ[2],vQ[4],vQ[6])),
		)):
		bi = True
	
	res = "Yes" if bi else "No"
	print(res)
	
	
main()

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

flg = False
for i in range(3):
  if sum(array[i]) == 0:
    flg = True
for i in range(3):
  if (array[0][i] + array[1][i] + array[2][i]) == 0:
    flg = True
if (array[0][0] + array[1][1] + array[2][2]) == 0:
  flg = True
if (array[2][0] + array[1][1] + array[0][2]) == 0:
  flg = True
  
if flg:
  print('Yes')
else:
  print('No')