Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

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


def ball(b):
    global A
    for c in range(3):
        for co in range(3):
            if A[c][co] == b:
                A[c][co] = "ok"


for c in range(N):
    b = int(input())
    ball(b)


if A[0].count("ok") == 3 or A[1].count("ok") == 3 or A[2].count("ok") == 3:
    print("Yes")
elif A[0][0] == "ok" and A[1][0] == "ok" and A[2][0] == "ok":
    print("Yes")
elif A[0][1] == "ok" and A[1][1] == "ok" and A[2][1] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][2] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][0] == "ok" and A[1][1] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][1] == "ok" and A[2][0] == "ok":
    print("Yes")
else:
    print("No")

Solution (Python):
A = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
for i in range(N) :
    b = int(input())
    for j in range(3) :
        if b in A[j] :
            x = A[j].index(b)
            A[j][x] = 0
        


for i in range(3) :
    if all(A[i][n] == 0 for n in range(3)) or all(A[m][i] == 0 for m in range(3)):
        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):
a = [input().split() for l in range(3)]
n = int(input())
b = list(input() for i in range(n))
c = [[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]:
                c[j][k] = 1

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

Solution (Python):
a = [input().split() for l in range(3)]
n = int(input())
b = list(input() for i in range(n))
c = [[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]:
                c[j][k] = 1

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

Solution (Python):
L = []
p = "No"
for i in range(3):
  a, b, c = map(str, input().split())
  L.append(a)
  L.append(b)
  L.append(c)
n = int(input())
for i in range(n):
  d = input()
  for j in range(9):
    if d == L[j]:
      L[j] = "×"
if (L[0] == "×" and L[8] == "×" and L[4] == "×") or (L[1] == "×" and L[7] == "×" and L[4] == "×") or (L[2] == "×" and L[6] == "×" and L[4] == "×") or (L[3] == "×" and L[5] == "×" and L[4] == "×"):
  p = "Yes"
elif (L[0] == "×" and L[1] == "×" and L[2] == "×") or (L[2] == "×" and L[5] == "×" and L[8] == "×") or (L[0] == "×" and L[3] == "×" and L[6] == "×") or (L[6] == "×" and L[7] == "×" and L[8] == "×"):
  p="Yes"
print(p)

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3) ]
n = int(input())
b = [int(input()) for i in range(n)]
for j in range(n):
    for k in range(3):
        for l in range(3):
            if b[j] == a[k][l]:
                a[k][l] = "o"
if a[0][0] == "o" and a[0][1] == "o" and a[0][2] == "o":
    print("Yes")
elif a[1][0] == "o" and a[1][1] == "o" and a[1][2] == "o":
    print("Yes")
elif a[2][0] == "o" and a[2][1] == "o" and a[2][2] == "o":
    print("Yes")
elif a[0][0] == "o" and a[1][0] == "o" and a[2][0] == "o":
    print("Yes")
elif a[0][1] == "o" and a[1][1] == "o" and a[2][1] == "o":
    print("Yes")
elif a[0][2] == "o" and a[1][2] == "o" and a[2][2] == "o":
    print("Yes")
elif a[0][0] == "o" and a[1][1] == "o" and a[2][2] == "o":
    print("Yes")
elif a[0][2] == "o" and a[1][1] == "o" and a[2][0] == "o":
    print("Yes")
else:
    print("No")

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

Solution (Python):
X = 3
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))
def checkbingo(a):
    for i,j,k in bingo:
        if a[i] + a[j] + a[k] == 0:
            return True 
    return False
    
    

a = []
for i in range(X):
    a += list(map(int,input().split()))
    
N = int(input())
for j in range(N):
    b = int(input())
    if b in a:
        a[a.index(b)] = 0
if checkbingo(a):
    print('Yes')
else:
    print('No')

Solution (Python):
arr = []
temp = []
for i in range(3):
    t = list(map(int, input().split()))
    arr.append(t)
    temp.extend(t)
    
n = int(input())
for i in range(n):
    a = int(input())
    if a in temp:
        for i in range(3):
            for j in range(3):
                if arr[i][j] == a:
                    arr[i][j] = 'X'
                if arr[0][j] == arr[1][j] == arr[2][j] or  arr[0][0] == arr[1][1] == arr[2][2] or arr[0][2] == arr[1][1] == arr[2][0] or set(arr[i]) == {'X'}:
                    print('Yes')
                    exit()
        
print('No')

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

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

for i,j,k in [
    (0,1,2),(3,4,5),(6,7,8),
    (0,3,6),(1,4,7),(2,5,8),
    (0,4,8),(2,4,6),
]:
    if A[i]==A[j]==A[k]:
        print('Yes')
        break
else:
    print('No')

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

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

p=[
  (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 i,j,k in p:
    if A[i]==A[j]==A[k]:
        print('Yes')
        break
else:
    print('No')

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

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

p=[
  (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 i,j,k in p:
    if A[i]==A[j]==A[k]==0:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
def bingo():
    for i in a:
        if i[0] in b and i[1] in b and i[2] in b:
            return True
    for i in range(3):
        if a[0][i] in b and a[1][i] in b and a[2][i] in b:
            return True
    tmp=[(a[i][i] in b) for i in range(3)]
    if tmp.count(True)==3:
        return True
    tmp=[a[0][2] in b,a[1][1] in b,a[2][0] in b]
    if tmp.count(True)==3:
        return True
 
a=[[int(i)for i in input().split()]for j in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
bingo=bingo()
print("Yes" if bingo else "No")

Solution (Python):
def bingo():
    for i in a:
        tmp=0
        for j in i:
            if j in b:
                tmp+=1
        if tmp==3:
            return True
    for i in range(3):
        tmp=0
        for j in a:
            if j[i] in b:
                tmp+=1
        if tmp==3:
            return True
    tmp=[(a[i][i] in b) for i in range(3)]
    if tmp.count(True)==3:
        return True
    tmp=[a[0][2] in b,a[1][1] in b,a[2][0] in b]
    if tmp.count(True)==3:
        return True

a=[[int(i)for i in input().split()]for j in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
bingo=bingo()
print("Yes" if bingo else "No")

Solution (Python):
A = []
is_checked = []
res = False

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

N = int(input())

b = {int(input()) for i in range(N)}

for i in range(3):
    is_checked.append([False]*3)
    for j in range(3):
        if A[i][j] in b:
            is_checked[i][j] = True

for i in range(3):
    if is_checked[i][0] and is_checked[i][1] and is_checked[i][2]:
        res = True
    if is_checked[0][i] and is_checked[1][i] and is_checked[2][i]:
        res = True

if is_checked[0][0] and is_checked[1][1] and is_checked[2][2]:
    res = True
if is_checked[0][2] and is_checked[1][1] and is_checked[2][0]:
    res = True

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

Solution (Python):
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

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

N = int(input())
for n in range(N):
  b = int(input())
  if my_index(A1, b) is not False:
    A1[my_index(A1, b)] = -1
  if my_index(A2, b) is not False:
    A2[my_index(A2, b)] = -1
  if my_index(A3, b) is not False:
    A3[my_index(A3, b)] = -1

if (sum(A1) == -3) or (sum(A2) == -3) or (sum(A3) == -3):
  print("Yes")
elif (A1[0]+A2[0]+A3[0]==-3) or (A1[1]+A2[1]+A3[1]==-3) or (A1[2]+A2[2]+A3[2]==-3):
  print("Yes")
elif (A1[0]+A2[1]+A3[2]==-3) or (A1[2]+A2[1]+A3[0]==-3):
  print("Yes")
else:
  print("No")

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

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

n = int(input())
ans = False

for i in range(n):
    b = int(input())
    for  j in range(3):
        if b in card[j]:
            card[j][card[j].index(b)] = 0

def judge(lst):
    return lst == [0,0,0]

for i in range(3):
    ans |= judge(card[i])
for i in range(3):
    ans |= judge([card[j][i] for j in range(3)])
ans |= judge([card[i][i] for i in range(3)])
ans |= judge([card[i][2-i] for i in range(3)])

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

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

G=[['.']*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            G[i][j]='


if any(all(G[i][j]=='
   any(all(G[i][j]=='
   all(G[i][2-i]=='
   all(G[i][i]=='
    print('Yes')
else:
    print('No')

Solution (Python):
listA = []
listB = []
for _ in range(3):
    listA.append(list(map(int, input().split())))
N = int(input())
for _ in range(N):
    listB.append(int(input()))
tate =  [0 , 0 , 0]
yoko = [0, 0, 0]
naname = [0, 0] 
for i in range(3):
    for j in range(3):
        if listA[i][j] in listB:
            tate[i] += 1
            yoko[j] += 1
            if i == j:
                naname[0] += 1
            if  i + j == 2:
                naname[1] += 1
if  3 in tate or 3 in yoko or 3 in naname:
    print("Yes")
else:
    print("No")

Solution (Python):
a=[]
for _ in range(3):
  b=list(map(int,input().split()))
  a.append(b)
  
n=int(input())
for _ in range(n):
  x=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==x:
        a[i][j]=-1
        
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):
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
n = int(input())
for j in range(n):
    x = int(input())
    if a == x:
        a = 0
    elif b == x:
        b == 0
    elif c == x:
        c = 0
    elif d == x:
        d = 0
    elif e == x:
        e = 0
    elif f == x:
        f = 0
    elif g == x:
        g = 0
    elif h == x:
        h = 0
    elif i == x:
        i = 0
y =[[a, b, c], [d, e, f], [g, h, i], [a, d, g], [b, e, h], [c, f, i], [a, e, i], [c, e, g]]
print("Yes" if [0, 0, 0] in y else "No")

Solution (Python):
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = False
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == seen[2] == "O":
    over = True
  elif seen[3] == seen[6] == "O":
    over = True
  elif seen[4] == seen[8] == "O":
    over = True
elif seen[4] == "O":
  if seen[2] == seen[6] == "O":
    over = True
  elif seen[1] == seen[7] == "O":
    over = True
  elif seen[3] == seen[5] == "O":
    over = True
elif seen[8] == "O":
  if seen[6] == seen[7] == "O":
    over = True
  if seen[2] == seen[5] == "O":
    over = True
if not over:
  print("No")
else:
  print("Yes")

Solution (Python):
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "No"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[6] == "O":
    over = "Yes"
  if seen[4] == "O" and seen[8] == "O":
    over = "Yes"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[2] == "O" and seen[5] == "O":
    over = "Yes"
if seen[4] == "O":
  if seen[6] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[1] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[5] == "O":
    over = "Yes"
print(over)

Solution (Python):
def resolve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ 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] = None
                    break
    for i in range(3):
        for j in range(3):
            if A[i][j] is not None:
                break
        else:
            print("Yes")
            return
    for i in range(3):
        for j in range(3):
            if A[j][i] is not None:
                break
        else:
            print("Yes")
            return
    if all(map(lambda x: x is None, [A[0][0], A[1][1], A[2][2]])) or all(map(lambda x: x is None, [A[0][2], A[1][1], A[2][0]])):
        print("Yes")
        return
    print("No")


if '__main__' == __name__:
    resolve()

Solution (Python):
a = [0]*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())

  
  

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


for i in range(3):
  if sum(a[i]) == 0:
    print("Yes")
    exit()
    
for i in range(3):
  if a[0][i] + a[1][i] + a[2][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):
arr = []
arr.append(list(map(int, input().split())))
arr.append(list(map(int, input().split())))
arr.append(list(map(int, input().split())))

def checker(arr):
    if arr[0][0] == arr[0][1] == arr[0][2] == "X":
        return True
    if arr[1][0] == arr[1][1] == arr[1][2] == "X":
        return True
    if arr[2][0] == arr[2][1] == arr[2][2] == "X":
        return True
    if arr[0][0] == arr[1][0] == arr[2][0] == "X":
        return True
    if arr[0][1] == arr[1][1] == arr[2][1] == "X":
        return True
    if arr[0][2] == arr[1][2] == arr[2][2] == "X":
        return True
    if arr[0][0] == arr[1][1] == arr[2][2] == "X":
        return True
    if arr[0][2] == arr[1][1] == arr[2][0] == "X":
        return True
    return False

for i in range(int(input())):
    a = int(input())
    for i in range(3):
        for j in range(3):
            if arr[i][j] == a:
                arr[i][j] = "X"
    
if checker(arr): print("Yes")
else: print("No")

Solution (Python):
board, dp = [], []
bingo = False

for _ in range(3):
    board.append(list(map(int, input().split()))) 
    dp.append([0, 0, 0])

N = int(input())

for _ in range(N):
    num = int(input())

    for r in range(3):
        for c in range(3):
            if num == board[r][c]:
                dp[r][c] = 1

for i in range(3):
    if dp[i][0] == dp[i][1] == dp[i][2] == 1 or dp[0][i] == dp[1][i] == dp[2][i] == 1:
        bingo = True
        print("Yes")
        break

if not bingo:
    if dp[0][0] == dp[1][1] == dp[2][2] == 1 or dp[0][2] == dp[1][1] == dp[2][0] == 1:
        print("Yes")
    else:
        print("No")

Solution (Python):
board=[0,0,0,0,0,0,0,0,0]
board[0],board[1],board[2] = map(int,input().split())
board[3],board[4],board[5] = map(int,input().split())
board[6],board[7],board[8] = map(int,input().split())
for _ in range(int(input())):
    x = int(input())
    if x in board:
        board[board.index(x)] = "X"
found = "No"
if board[0] == "X":
    if board[1] == "X" and board[2] == "X":
        found = "Yes"
    elif board[4] == "X" and board[8] == "X":
        found = "Yes"
    elif board[3] == "X" and board[6] == "X":
        found = "Yes"
if board[8] == "X":
    if board[5] == "X" and board[2] == "X":
        found = "Yes"
    elif board[7] == "X" and board[6] == "X":
        found = "Yes"
if board[4] == "X":
    if board[1] == "X" and board[7] == "X":
        found = "Yes"
    elif board[3] == "X" and board[5] == "X":
        found = "Yes"
    elif board[2] == "X" and board[6] == "X":
        found = "Yes"
print(found)

Solution (Python):
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]
G=[['*']*3,['*']*3,['*']*3]
for i in range(3):
  for j in range(3):
    if A[i][j] not in b:
      G[i][j]=A[i][j]

if G[0][0]==G[1][1]==G[2][2]=='*':
  print('Yes')
  exit()
elif G[0][2]==G[1][1]==G[2][0]=='*':
  print('Yes')
  exit()
else:
  for i in range(3):
    if G[i][0]==G[i][1]==G[i][2]=='*':
      print('Yes')
      exit()
    elif G[0][i]==G[1][i]==G[2][i]=='*':
      print('Yes')
      exit()

print('No')

Solution (Python):
bingo = []
sheet = set()
for _ in range(3):
  lst = [int(i) for i in input().split()]
  bingo.append(lst)
n = int(input())
for _ in range(n):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if bingo[i][j] == a:
        num = 3 * i + j
        sheet.add(num)
if 0 in sheet and 1 in sheet and 2 in sheet:
  print('Yes')
elif 0 in sheet and 3 in sheet and 6 in sheet:
  print('Yes')
elif 0 in sheet and 4 in sheet and 8 in sheet:
  print('Yes')
elif 1 in sheet and 4 in sheet and 7 in sheet:
  print('Yes')
elif 2 in sheet and 5 in sheet and 8 in sheet:
  print('Yes')
elif 2 in sheet and 4 in sheet and 6 in sheet:
  print('Yes')
elif 3 in sheet and 4 in sheet and 5 in sheet:
  print('Yes')
elif 6 in sheet and 7 in sheet and 8 in sheet:
  print('Yes')
else:
  print('No')

Solution (Python):
def main():
    bingo = []
    for ss in range(3):
        s = list(map(int,input().strip().split()))
        bingo.append(s)
    
    n = int(input())
    nl = []
    for nn in range(n):
        nl.append(int(input()))
    
    for i in range(3):
        for j in range(3):
            for n in nl:
                if bingo[i][j] == n:
                    bingo[i][j] = -1
    
    for i in range(3):
        if bingo[0][i] == bingo[1][i] == bingo[2][i] == -1:
            print("Yes")
            return
        if bingo[i][0] == bingo[i][1] == bingo[i][2] == -1:
            print("Yes")
            return
    
    if bingo[0][0] == bingo[1][1] == bingo[2][2] == -1:
        print("Yes")
        return
    if bingo[0][2] == bingo[1][1] == bingo[2][0] == -1:
        print("Yes")
        return
    
    print("No")
    return

    
main()

Solution (Python):
import numpy as np

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

n = int(input())

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

c = np.zeros(9).reshape(3,3)

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

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")

Solution (Python):


A_list = [[] for _ in range(3)]

for i in range(3):
    A1, A2, A3 = map(int, input().split())
    A_list[i] += [A1, A2, A3]

N = int(input())

set1 = {A_list[0][0], A_list[0][1], A_list[0][2]}
set2 = {A_list[1][0], A_list[1][1], A_list[1][2]}
set3 = {A_list[2][0], A_list[2][1], A_list[2][2]}
set4 = {A_list[0][0], A_list[1][0], A_list[2][0]}
set5 = {A_list[0][1], A_list[1][1], A_list[2][1]}
set6 = {A_list[0][2], A_list[1][2], A_list[2][2]}
set7 = {A_list[0][0], A_list[1][1], A_list[2][2]}
set8 = {A_list[0][2], A_list[1][1], A_list[2][0]}


b_set = set()

for n in range(N):
    b = int(input())
    b_set.add(b)

if (set1 <= b_set or 
    set2 <= b_set or
    set3 <= b_set or
    set4 <= b_set or
    set5 <= b_set or
    set6 <= b_set or
    set7 <= b_set or
    set8 <= b_set):

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

Solution (Python):
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=set()
c=[[0,0,0] for _ in range(3)]
for i in range(n):
    b.add(int(input()))
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j]=1
for i in range(3):
    if sum(c[i])==3:
        print("Yes")
        exit()
    elif c[0][i]+c[1][i]+c[2][i]==3:
        print("Yes")
        exit()

if c[0][0]+c[1][1]+c[2][2]==3:
    print("Yes")
elif c[0][2]+c[1][1]+c[2][0]==3:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
n=int(input())
d=[]
for e in sys.stdin:
	e=int(e)
	if e in a:
		a[a.index(e)]=0
	if e in b:
		b[b.index(e)]=0
	if e in c:
		c[c.index(e)]=0
if sum(a)==0 or sum(b)==0 or sum(c)==0:
	print("Yes")
	exit()
for i in range(3):
	if a[i]==0 and b[i]==0 and c[i]==0:
		print("Yes")
		exit()
if (a[0]==0 and b[1]==0 and c[2]==0) or (a[2]==0 and b[1]==0 and c[0]==0):
	print("Yes")
	exit()
print("No")

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

for b in B:
  A = np.where(A==b,0,A)

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

Solution (Python):
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    bingo = [False]*9
    dic = dict()
    c = 0
    for _ in range(3):
        tmp = list(IL())
        for rep in tmp:
            dic[rep] = c
            c += 1
    n = I()
    for _ in range(n):
        b = I()
        idx = dic.get(b)
        if idx is None:
            continue
        bingo[idx] = True
    
    flag = False
    for i in range(0,3):
        for j in range(0,7,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return
        
    for i in range(0,7,3):
        for j in range(0,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return

    if (bingo[2] and bingo[4] and bingo[6]) or (bingo[0] and bingo[4] and bingo[8]):
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    solve()

Solution (Python):
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
for i in range(N):
  b=int(input())
  if b in A1:
    t=A1.index(b)
    A1[t]=0
  elif b in A2:
    t=A2.index(b)
    A2[t]=0
  elif b in A3:
    t=A3.index(b)
    A3[t]=0
if sum(A1)==0 or sum(A2)==0 or sum(A3)==0:
  print("Yes")
else:
  for j in range(3):
    if A1[j]+A2[j]+A3[j]==0:
      print("Yes")
      break
  else:
    if A1[0]+A2[1]+A3[2]==0 or A1[2]+A2[1]+A3[0]==0:
      print("Yes")
    else:
      print("No")

Solution (Python):
def exe():
    print('Yes')
    exit()

A = []
for _ in range(3):
    A.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 A[i][j] == b:
                A[i][j] = 0

for i in range(3):
    if sum(A[i]) == 0:
        exe()
    elif A[0][i]+A[1][i]+A[2][i]==0:
        exe()
if A[0][0]+A[1][1]+A[2][2] == 0:
    exe()
elif A[0][2]+A[1][1]+A[2][0] == 0:
    exe()

print('No')

Solution (Python):
A = []
for _ in range(3):
    A.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 A[i][j] == b:
                A[i][j] = 0

for i in range(3):
    if sum(A[i]) == 0:
        print('Yes')
        exit()
    elif A[0][i]+A[1][i]+A[2][i]==0:
        print('Yes')
        exit()
if A[0][0]+A[1][1]+A[2][2] == 0:
    print('Yes')
    exit()
elif A[0][2]+A[1][1]+A[2][0] == 0:
    print('Yes')
    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 b in B:
    for y in range(3):
        for x in range(3):
            if A[y][x] == b:
                A[y][x] = -1
for y in range(3):
    if sum(A[y]) == -3:
        print("Yes")
        exit()
for x in range(3):
    if A[0][x] == A[1][x] == A[2][x] == -1:
        print("Yes")
        exit()
if A[0][0] == A[1][1] == A[2][2] == -1 or A[2][0] == A[1][1] == A[0][2] == -1:
    print("Yes")
    exit()
print("No")

Solution (Python):
a = []
for i in range(3):
  t = [int(x) for x in input().split()]
  a.append(t)
n = int(input())
b = [int(input()) for i in range(n)]
m = [[0 for j in range(3)] for i in range(3)]
for i in range(3):
  for j in range(3):
    for k in b:
      if (a[i][j] == k):
        m[i][j] = 1
for i in range(3):
  if (m[i][0] and m[i][1] and m[i][2]):
    print("Yes")
    exit()
for i in range(3):
  if (m[0][i] and m[1][i] and m[2][i]):
    print("Yes")
    exit()
if ((m[0][0] and m[1][1] and m[2][2]) or (m[0][2] and m[1][1] and m[2][0])):
  print("Yes")
  exit()
print("No")

Solution (Python):
A=[]
B=[]
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(3):
    for j in range(3):
        for k in range(N):
            if A[i][j]==B[k]:
                A[i][j]=-1
C=[]
for i in range(3):
    if A[0][0]==A[1][1] and A[1][1]==A[2][2] and A[2][2]==-1:
        C.append('Yes')
    elif A[0][2]==A[1][1] and A[1][1]==A[2][0] and A[2][0]==-1:
        C.append('Yes')
    elif A[i][0]==A[i][1] and A[i][1]==A[i][2]:
        C.append('Yes')
    elif A[0][i]==A[1][i] and A[1][i]==A[2][i]:
        C.append('Yes')
    else:
        C.append('No')
if 'Yes' in C:
    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 k in range(N)]
hole = [[0,0,0] for i in range(3)]
ans = "No"

for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j] == b[k]:
        hole[i][j] = 1
  flag_hol = 1
  for j in range(3):
    flag_hol *= hole[i][j]
  if flag_hol == 1:
  	ans = "Yes"

flag_diag1 = 1
flag_diag2 = 1
for j in range(3):
  flag_vert = 1
  for i in range(3):
    flag_vert *= hole[i][j]
  if flag_vert ==1:
    ans = "Yes"
  flag_diag1 *= hole[j][j]
  flag_diag2 *= hole[j][2-j]
if (flag_diag1 == 1) or (flag_diag2 == 1):
  ans = "Yes"
  
print(ans)

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

n=int(input())
for i in range (n):
  num=int(input())
  if num in a1:
  	a1[a1.index(num)]='O'
  if num in a2:
  	a2[a2.index(num)]='O'
  if num in a3:
  	a3[a3.index(num)]='O'
if a1[0] == 'O' and a1[1] == 'O' and a1[2] == 'O':
  print('Yes')
elif a2[0] == 'O' and a2[1] == 'O' and a2[2] == 'O':
  print('Yes')
elif a3[0] == 'O' and a3[1] == 'O' and a3[2] == 'O':
  print('Yes')
elif a1[0] == 'O' and a2[0] == 'O' and a3[0] == 'O':
  print('Yes')
elif a1[1] == 'O' and a2[1] == 'O' and a3[1] == 'O':
  print('Yes')
elif a1[2] == 'O' and a2[2] == 'O' and a3[2] == 'O':
  print('Yes')
elif a1[0] == 'O' and a2[1] == 'O' and a3[2] == 'O':
  print('Yes')
elif a1[2] == 'O' and a2[1] == 'O' and a3[0] == 'O':
  print('Yes')
else:
  print('No')

Solution (Python):
import itertools
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = list(itertools.chain.from_iterable([a1, a2, a3]))

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

for i in b:
    a = [x if x != i else 0 for x in a]

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