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):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


A = [LI() for _ in range(3)]
N = I()
flag = [[0]*3 for _ in range(3)]

for i in range(N):
    b = I()
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                flag[j][k] = 1

for i in range(3):
    if flag[i][0] == flag[i][1] == flag[i][2] == 1 or flag[0][i] == flag[1][i] == flag[2][i] == 1:
        print('Yes')
        exit()

if flag[0][0] == flag[1][1] == flag[2][2] == 1 or flag[0][2] == flag[1][1] == flag[2][0] == 1:
    print('Yes')
    exit()

print('No')

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
B = [[0 for _ in range(3)] for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                B[i][j] = 1
flag = 0
for i in range(3):
    if sum(B[i])==3:
        flag = 1
        break
for j in range(3):
    cnt = 0
    for i in range(3):
        cnt += B[i][j]
    if cnt==3:
        flag = 1
        break
if B[0][0]+B[1][1]+B[2][2]==3:
    flag = 1
if B[2][0]+B[1][1]+B[0][2]==3:
    flag = 1
if flag==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

A1=np.array(list(map(int,input().split())))
A2=np.array(list(map(int,input().split())))
A3=np.array(list(map(int,input().split())))
A=np.concatenate([A1,A2,A3]).reshape(3,3)

N=int(input())

for i in range(N):
    b=int(input())
    A[np.where(A==b)] = 0

if np.all(A[0,:]==0) or np.all(A[1,:]==0) or np.all(A[2,:]==0) or np.all(A[:,0]==0) or np.all(A[:,1]==0) \
    or np.all(A[:,2]==0) or A[0,0]**2+A[1,1]**2+A[2,2]**2==0 or A[0,2]**2+A[1,1]**2+A[2,0]**2==0:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

CARD_SIZE = 3


def solve(card, called_numbers):
    checked_card = np.vectorize(lambda n: n in called_numbers)(card)

    for l in checked_card:
        if all(l):
            return True

    for l in zip(*checked_card):
        if all(l):
            return True

    if all([checked_card[n][n] for n in range(CARD_SIZE)]):
        return True
    if all([checked_card[n][CARD_SIZE - n - 1] for n in range(CARD_SIZE)]):
        return True

    return False


def resolve():
    card = [[int(row) for row in input().split()] for _ in range(CARD_SIZE)]

    N = int(input())
    called_numbers = {int(input()) for n in range(N)}

    ret = solve(card, called_numbers)

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


if __name__ == '__main__':
    resolve()

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

N = int(input())

test = [[0]*3 for _ in range(3)]

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

for b in B:
    for m in range(3):
        for n in range(3):
            if b == A[m][n]:
                test[m][n] =1

ans = 'No'

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

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

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

print(ans)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    A_ = []
    for a_ in A:
        A_ += [[a__, False] for a__ in a_]
    for b_ in b:
        for a__ in A_:
            if a__[0] == b_:
                a__[1] = True
    if (A_[0][1] and ((A_[1][1] and A_[2][1]) or \
                        (A_[3][1] and A_[6][1]) or \
                        (A_[4][1] and A_[8][1]))) or \
            (A_[1][1] and A_[4][1] and A_[7][1]) or \
            (A_[2][1] and A_[5][1] and A_[8][1]) or \
            (A_[3][1] and A_[4][1] and A_[5][1]) or \
            (A_[6][1] and A_[7][1] and A_[8][1]) or \
            (A_[2][1] and A_[4][1] and A_[6][1]):
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    A_ = []
    for a_ in A:
        A_ += [[a__, False] for a__ in a_]
    for b_ in b:
        for a__ in A_:
            if a__[0] == b_:
                a__[1] = True
    if (A_[0][1] and ((A_[1][1] and A_[2][1]) or \
                        (A_[3][1] and A_[6][1]) or \
                        (A_[4][1] and A_[8][1]))) or \
            (A_[1][1] and A_[4][1] and A_[7][1]) or \
            (A_[2][1] and A_[5][1] and A_[8][1]) or \
            (A_[3][1] and A_[4][1] and A_[5][1]) or \
            (A_[6][1] and A_[7][1] and A_[8][1]) or \
            (A_[2][1] and A_[4][1] and A_[6][1]):
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

a, b, c = I()
j, k, l = I()
x, y, z = I()

seen = {}
n = I()
for _ in range(n):
    d = I()
    seen[d] = 1

if a in seen and b in seen and c in seen:
    print('Yes')
elif j in seen and k in seen and l in seen:
    print('Yes')
elif x in seen and y in seen and z in seen:
    print('Yes')
elif a in seen and j in seen and x in seen:
    print('Yes')
elif b in seen and k in seen and y in seen:
    print('Yes')
elif c in seen and l in seen and z in seen:
    print('Yes')
elif a in seen and k in seen and z in seen:
    print('Yes')
elif x in seen and k in seen and c in seen:
    print('Yes')
else:
    print('No')

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

Solution (Python):
L = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
B = list(int(input()) for _ in range(n))
ans = 'No'
for i in range(3):
  for j in range(3):
    for b in B:
      if L[i][j] == b:
        L[i][j] = 0
        
for i in range(3):
  if L[i][0] == L[i][1] == L[i][2] == 0: ans = 'Yes' 
  if L[0][i] == L[1][i] == L[2][i] == 0: ans = 'Yes' 
if L[0][0] == L[1][1] == L[2][2] == 0: ans = 'Yes'
if L[0][2] == L[1][1] == L[2][0] == 0: ans = 'Yes'
  
print(ans)

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


for num in li:
    for i in range(3):
        for j in range(3):
            if masu[i][j] == num:
                check[i][j] = 1

for row in check:
    if all(row) == 1:
        print('Yes')
        exit()
for t in range(3):
    count = 0
    for row in check:
        if row[t] == 1:
            count += 1
    if count == 3:
        print('Yes')
        exit()
if check[0][0] + check[1][1] + check[2][2] == 3:
    print('Yes')
    exit()
if check[0][2] + check[1][1] + check[0][2] == 3:
    print('Yes')
    exit()
    
print('No')

Solution (Python):
B=[]
for i in range(3):
    A=list(map(int,input().split()))
    B.append(A[0])
    B.append(A[1])
    B.append(A[2])
N=int(input())
for j in range(N):
    b=int(input())
    if b in B:
        B[B.index(b)]=0
if B[0]==0 and B[1]==0 and B[2]==0:
    print('Yes')
elif B[3]==0 and B[4]==0 and B[5]==0:
    print('Yes')
elif B[6]==0 and B[7]==0 and B[8]==0:
    print('Yes')
elif B[0]==0 and B[3]==0 and B[6]==0:
    print('Yes')
elif B[1]==0 and B[4]==0 and B[7]==0:
    print('Yes')
elif B[2]==0 and B[5]==0 and B[8]==0:
    print('Yes')
elif B[0]==0 and B[4]==0 and B[8]==0:
    print('Yes')
elif B[2]==0 and B[4]==0 and B[6]==0:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    for i in range(N):
        n = b[i]
        for j in range(3):
            for k in range(3):
                if A[j][k] == n:
                    A[j][k] = 0
    if A[0][0] == A[0][1] == A[0][2]:
        print(YES)
    elif A[1][0] == A[1][1] == A[1][2]:
        print(YES)
    elif A[2][0] == A[2][1] == A[2][2]:
        print(YES)
    elif A[0][0] == A[1][0] == A[2][0]:
        print(YES)
    elif A[0][1] == A[1][1] == A[2][1]:
        print(YES)
    elif A[0][2] == A[1][2] == A[2][2]:
        print(YES)
    elif A[0][0] == A[1][1] == A[2][2]:
        print(YES)
    elif A[0][2] == A[1][1] == A[2][0]:
        print(YES)
    else:
        print(NO)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):
board = [list(map(int,input().split())) for i in range(3)]
num = int(input())
for n in range(num):
    bi = int(input())
    for i in range(3):
        for j in range(3):
            if board[i][j] == bi:
                board[i][j] = 0


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

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

if board[0][0] == board[1][1] == board[2][2] == 0:
    print("Yes")
    exit()
if board[0][2] == board[1][1] == board[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)]

c = [[0]*3 for _ in range(3)]

for k in range(n):
  for i in range(3):
    for j in range(3):
      if a[i][j] == b[k]:
        c[i][j] += 1
        
for i in range(3):
  if c[0][i] == c[1][i] == c[2][i] == 1:
    print("Yes")
    exit()
for j in range(3):
  if c[j][0] == c[j][1] == c[j][2] == 1:
    print("Yes")
    exit()
if c[0][0] == c[1][1] == c[2][2] == 1:
  print("Yes")
  exit()
if c[0][2] == c[1][1] == c[2][0] == 1:
  print("Yes")
  exit()
print("No")

Solution (Python):
def mark(a, b):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0


def check_h(a):
    for row in a:
        if row == [0, 0, 0]:
            return True


def check_v(a):
    for col in range(3):
        if [row[col] for row in a] == [0, 0, 0]:
            return True


def check_c(a):
    if [a[i][i] for i in range(3)] == [0, 0, 0] or [a[i][2 - i] for i in range(3)] == [0, 0, 0]:
        return True


def resolve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    for _ in range(N):
        B = int(input())
        mark(A, B)
    if check_h(A) or check_v(A) or check_c(A):
        print("Yes")
    else:
        print("No")
resolve()

Solution (Python):
Bingo_1 = list(map(int, input().split()))
Bingo_2 = list(map(int, input().split()))
Bingo_3 = list(map(int, input().split()))

number_table = []
number_count = int(input())
for i in range(number_count):
    number_table.append(int(input()))

for j in range(number_count):
    if number_table[j] == Bingo_1[0]:
        Bingo_1[0] = 0
    elif number_table[j] == Bingo_1[1]:
        Bingo_1[1] = 0
    elif number_table[j] == Bingo_1[2]:
        Bingo_1[2] = 0
    elif number_table[j] == Bingo_2[0]:
        Bingo_2[0] = 0
    elif number_table[j] == Bingo_2[1]:
        Bingo_2[1] = 0
    elif number_table[j] == Bingo_2[2]:
        Bingo_2[2] = 0
    elif number_table[j] == Bingo_3[0]:
        Bingo_3[0] = 0
    elif number_table[j] == Bingo_3[1]:
        Bingo_3[1] = 0
    elif number_table[j] == Bingo_3[2]:
        Bingo_3[2] = 0

if Bingo_1[0] == 0 and Bingo_1[1] == 0 and Bingo_1[2] == 0:
    print('Yes')
elif Bingo_2[0] == 0 and Bingo_2[1] == 0 and Bingo_2[2] == 0:
    print('Yes')
elif Bingo_3[0] == 0 and Bingo_3[1] == 0 and Bingo_3[2] == 0:
    print('Yes')
elif Bingo_1[0] == 0 and Bingo_2[0] == 0 and Bingo_3[0] == 0:
    print('Yes')
elif Bingo_1[1] == 0 and Bingo_2[1] == 0 and Bingo_3[1] == 0:
    print('Yes')
elif Bingo_1[2] == 0 and Bingo_2[2] == 0 and Bingo_3[2] == 0:
    print('Yes')
elif Bingo_1[0] == 0 and Bingo_2[1] == 0 and Bingo_3[2] == 0:
    print('Yes')
elif Bingo_1[2] == 0 and Bingo_2[1] == 0 and Bingo_3[0] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
bin = []

for i in range(3):
  lst = list(map(int,input().split()))
  bin.append(lst)
  
n = int(input())
for i in range(n):
  m = int(input())
  for j in range(3):
    for k in range(3):
      if m == bin[j][k]:
        bin[j][k] = 't'
        break
    
    
for i in range(3):
  if bin[i][0] == 't' and bin[i][1] == 't' and bin[i][2] == 't':
    print('Yes')
    sys.exit()
    
for j in range(3):
  if bin[0][j] == 't' and bin[1][j] == 't' and bin[2][j] == 't':
    print('Yes')
    sys.exit()
    
if (bin[0][0] == 't' and bin[1][1] == 't' and bin[2][2] == 't') or (bin[0][2] == 't' and bin[1][1] == 't' and bin[2][0] == 't'):  
  print('Yes')
  sys.exit()
  
print('No')

Solution (Python):
A = [0 for i in range(9)]
for i in range(3):
  A[3*i], A[3*i+1], A[3*i+2] = map(int, input().split())
N = int(input())
b = [0 for i in range(N)]
for i in range(N):
  b[i] = int(input())


for i in range(9):
  for j in range(N):
    if A[i] == b[j]:
      A[i] = 0


flag = 0

for i in [0, 3, 6]:
  if A[i]==A[i+1] and A[i+1]==A[i+2]:
    flag += 1

for j in range(3):
  if A[j]==A[j+3] and A[j+3]==A[j+6]:
    flag += 1

if (A[0]==A[4] and A[4]==A[8]) or (A[2]==A[4] and A[4]==A[6]):
  flag += 1

if flag >= 1:
  print("Yes")
else:
  print("No")

Solution (Python):
A = [0 for i in range(9)]
for i in range(3):
  A[3*i], A[3*i+1], A[3*i+2] = map(int, input().split())
N = int(input())
b = [0 for i in range(N)]
for i in range(N):
  b[i] = int(input())


for i in range(9):
  for j in range(N):
    if A[i] == b[j]:
      A[i] = 1


flag = 0

for i in [0, 3, 6]:
  if A[i]==A[i+1] and A[i+1]==A[i+2]:
    flag += 1

for j in range(3):
  if A[j]==A[j+3] and A[j+3]==A[j+6]:
    flag += 1

if (A[0]==A[4] and A[4]==A[8]) or (A[2]==A[4] and A[4]==A[6]):
  flag += 1

if flag >= 1:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    A = [list(map(int, input().split())) 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:
                    A[i][j] = 0

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def check(arr):
    
    for i in range(len(arr)):
        if arr[i] == ["x", "x", "x"]:
            return True

    
    for i in range(3):
        if arr[0][i] == "x" and arr[1][i] == "x" and arr[2][i] == "x":
            return True

    
    if arr[0][0] == "x" and arr[1][1] == "x" and arr[2][2] == "x":
        return True
    elif arr[0][2] == "x" and arr[1][1] == "x" and arr[2][0] == "x":
        return True

    return False

arr = []
for _ in range(3):
    arr.append(list(map(int, input().split(' '))))

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(len(arr)):
        tmp_arr = []
        for ele in arr[i]:
            if b == ele:
                tmp_arr.append("x")
            else:
                tmp_arr.append(ele)
        arr[i] = tmp_arr

if check(arr) == True:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
P = ['o']*9
for i in range(3):
    a = [int(i) for i in input().split()]
    for j in range(3):
        A.append(a[j])

N = int(input())
for i in range(N):
    b = int(input())
    for j in range(9):
        if A[j] == b:
            P[j] = 'x'

t = 0
for i in range(3):
    if (P[i] == P[i+3] == P[i+6] == 'x') or (P[3*i] == P[3*i+1] == P[3*i+2] == 'x'):
        t += 1
        break
if (P[0] == P[4] == P[8] == 'x') or (P[2] == P[4] == P[6] == 'x'):
    t += 1

if t == 0:
    print('No')
else:
    print('Yes')

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

cnt=[]
pattern=[[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 in range(n):
    b.append(int(input()))
    for j , x in enumerate(a):
        if x == b[i]:
            cnt.append(j)

for q,w,e in pattern:
    if q in cnt and w in cnt and e in cnt:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
flag = 0
for _ in range(n):
    b = int(input())
    for i in range(3):
        if b == a1[i]:
            a1[i] = 0
        elif b == a2[i]:
            a2[i] = 0
        elif b == a3[i]:
            a3[i] = 0
    for i in range(3):
        if a1[i] == a2[i] == a3[i]:
            flag = 1
        if sum(a1) == 0:
            flag = 1
        if sum(a2) == 0:
            flag = 1
        if sum(a3) == 0:
            flag = 1
        if a1[0] == a2[1] == a3[2]:
            flag = 1
        if a1[2] == a2[1] == a3[0]:
            flag = 1
    if flag == 1:
        print("Yes")
        break
if flag == 0:
    print("No")

Solution (Python):


def main():
    A = []
    num = [1 for _ in range(101)]
    C = [
        [0, 1, 2],
        [3, 4, 5],
        [6, 7, 8],
        [0, 3, 6],
        [1, 4, 7],
        [2, 5, 8],
        [0, 4, 8],
        [2, 4, 6],
    ]
    ans = 'No'
    
    for _ in range(3):
        for i in list(map(int, input().split())):
            A.append(i)
        

    N = int(input())

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

    for c in C:
        if num[A[c[0]]] == 0 and num[A[c[1]]] == 0 and num[A[c[2]]] == 0:
            ans = 'Yes'
            break

    print(ans)


if __name__ == "__main__":
    main()

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

ans = "No"
for i in visited:
    if i==[True,True,True]:
        ans = "Yes"

for i in range(3):
    flag = True
    for j in range(3):
        if visited[j][i]==False:
            flag = False
            break
    if flag:
        ans = "Yes"

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

Solution (Python):
a = [0]*9
a[0],a[1],a[2] = map(int,input().split())
a[3],a[4],a[5] = map(int,input().split())
a[6],a[7],a[8] = map(int,input().split())
n = int(input())
ans = [0]*9
for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            ans[j] = 1
if sum(ans[:3]) == 3 or sum(ans[3:6]) == 3 or sum(ans[6:9]) == 3:
    print('Yes')
elif sum(ans[0::3]) == 3 or sum(ans[1::3]) == 3 or sum(ans[2::3]) == 3:
    print('Yes')
elif sum(ans[0::4]) == 3 or sum(ans[2:7:2]) == 3:
    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())

x = []
y = [a,b,c,d,e,f,g,h,i]

n = int(input())
for s in range(n):
  x.append(int(input()))

for m in range(9):
  if y[m] in x:
      y[m] = 0

if y[0] == y[1] == y[2] == 0:
    print("Yes")
elif y[3] == y[4] == y[5] == 0:
    print("Yes")

elif y[6] == y[7] == y[8] == 0:
    print("Yes")

elif y[0] == y[3] == y[6] == 0:
    print("Yes")

elif y[1] == y[4] == y[7] == 0:
    print("Yes")

elif y[2] == y[5] == y[8] == 0:
    print("Yes")

elif y[0] == y[4] == y[8] == 0:
    print("Yes")

elif y[2] == y[4] == y[6] == 0:
    print("Yes")

else:

    print("No")

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


C = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if b[k] == A[i][j]:
                C[i][j] = 1

for i in range(3):
    if sum(C[i]) == 3:
        print("Yes")
        sys.exit(0)

for j in range(3):
    if C[0][j]+C[1][j]+C[2][j] == 3:
        print("Yes")
        sys.exit(0)

if C[0][0]+C[1][1]+C[2][2] == 3 or C[0][2]+C[1][1]+C[2][0] == 3:
    print("Yes")
    sys.exit(0)

print("No")

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

a = inl()
b = inl()
c = inl()
n = ini()
bingo = []
for _ in range(n):
    bingo.append(ini())
ct = [0] * 9
for i in bingo:
    if i in a:
        ct[a.index(i)] = 1
    if i in b:
        ct[b.index(i) + 3] = 1
    if i in c:
        ct[c.index(i) + 6] = 1
if sum(ct[:3]) == 3 or sum(ct[3:6]) == 3 or sum(ct[6:9]) == 3:
    print("Yes")
elif (ct[0] + ct[4] + ct[8]) == 3 or (ct[2] + ct[4] + ct[6]) == 3:
    print("Yes")
elif (ct[0] + ct[3] + ct[6]) == 3 or (ct[1] + ct[4] + ct[7]) == 3 or (ct[2] + ct[5] + ct[8]) == 3:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque 


def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()






bingo = []
for i in range(3):
    ls = inpl()
    bingo.append(ls)
N = inp()
for i in range(N):
    a = inp()
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == a:
                bingo[i][j] = -1

bl = False
for i in range(3):
    if bingo[i][0] == -1 and bingo[i][1] == -1 and bingo[i][2] == -1:
        bl = True
    if bingo[0][i] == -1 and bingo[1][i] == -1 and bingo[2][i] == -1:
        bl = True
         
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
        bl = True

if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1:
        bl = True
 
print('Yes' if bl else 'No')



end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Solution (Python):
A1 = list(map(str,input().split()))
A2 = list(map(str,input().split()))
A3 = list(map(str,input().split()))
N = int(input())
for k in range(N):
  i = str(input())  
  if i == A1[0]:
    A1[0] = 'OK'
  if i == A1[1]:
    A1[1] = 'OK'
  if i == A1[2]:
    A1[2] = 'OK'
  if i == A2[0]:
    A2[0] = 'OK' 
  if i == A2[1]:
    A2[1] = 'OK'
  if i == A2[2]:
    A2[2] = 'OK'
  if i == A3[0]:
    A3[0] = 'OK'
  if i == A3[1]:
    A3[1] = 'OK'
  if i == A3[2]:
    A3[2] = 'OK'
if A1 == ['OK','OK','OK'] or A2 == ['OK','OK','OK'] or A3 == ['OK','OK','OK']:
  print('Yes')
  exit()
for i in range(3):
  if A1[i] == 'OK' and A2[i] == 'OK' and A3[i]== 'OK':
    print('Yes')
    exit()
if A1[0] == 'OK' and A2[1] == 'OK' and A3[2]== 'OK':
    print('Yes')
    exit()
if A1[2] == 'OK' and A2[1] == 'OK' and A3[0]== 'OK':
    print('Yes')
    exit()
print('No')

Solution (Python):
a = [list(map(int, input().split())) for i 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 a[i][j] == b:
                a[i][j] = 0
    row0 = a[0] == [0, 0, 0]
    row1 = a[1] == [0, 0, 0]
    row2 = a[2] == [0, 0, 0]
    colum0 = [a[0][0], a[1][0], a[2][0]] == [0, 0, 0]
    colum1 = [a[0][1], a[1][1], a[2][1]] == [0, 0, 0]
    colum2 = [a[0][2], a[1][2], a[2][2]] == [0, 0, 0]
    diag0 = [a[0][0], a[1][1], a[2][2]] == [0, 0, 0]
    diag1 = [a[2][0], a[1][1], a[0][2]] == [0, 0, 0]
    if row0 or row1 or row2 or colum0 or colum1 or colum2 or diag0 or diag1:
        print('Yes')
        break
else:
    print('No')

Solution (Python):

import sys
input=sys.stdin.readline

def bingo_check(card):
    
    for low in card:
        if sum(low)==0:
            print("Yes")
            exit()
    
    column1=0
    column2=0
    column3=0
    for low in card:
        column1+=low[0]
        column2+=low[1]
        column3+=low[2]
    if column1 == 0 or column2 == 0 or column3==0:
        print("Yes")
        exit()
    
    diagonal1=card[0][0]+card[1][1]+card[2][2]
    diagonal2=card[0][2]+card[1][1]+card[2][0]
    if diagonal1 == 0 or diagonal2 == 0:
        print("Yes")
        exit()
    print("No")

def main():
    bingo=[]
    use_card=[]
    bingo=[list(map(int,input().split())) for _ in range(3)]
    use_card=bingo
    n = int(input())

    for idx in range(n):
        number=int(input())
        for i in range(3):
            for j in range(3):
                if number==use_card[i][j]:
                    use_card[i][j]=0
                else:
                    continue
    bingo_check(use_card)

if __name__=="__main__":
    main()

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

called = [False] * 9

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

N = int(input())
for i in range(N):
  target = int(input())
  if target in A:
    called[A.index(target)] = True
  
for a,b,c in bingo:
  if called[a] and called[b] and called[c]:
    print("Yes")
    break
else:
  print("No")

Solution (Python):
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
n = int(input())
B = [int(input()) for i in range(n)]
A = [A1,A2,A3]
ans = [[0,0,0],[0,0,0],[0,0,0]]
for b in B:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        ans[i][j] = 1
for i in range(3):
  if ans[i][0] and ans[i][1] and ans[i][2]:
    print("Yes")
    quit()
  if ans[0][i] and ans[1][i] and ans[2][i]:
    print("Yes")
    quit()
if ans[0][0] and ans[1][1] and ans[2][2]:
  print("Yes")
  quit()
if ans[0][2] and ans[1][1] and ans[2][0]:
  print("Yes")
  quit()
print("No")

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

ans = "No"
for k in range(3):
  if map_list[0][k] == map_list[1][k] == map_list[2][k] or \
     map_list[k][0] == map_list[k][1] == map_list[k][2]:
      ans = "Yes"
      break
  if map_list[0][0] == map_list[1][1] == map_list[2][2] or \
	 map_list[0][2] == map_list[1][1] == map_list[2][0]:
      ans = "Yes"
print(ans)

Solution (Python):
a =[]

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


n = int(input())
b =[]

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



flag = 0
cnt = 0

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


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

        else:
            if cnt == 3:
                print("Yes")
                flag += 1
                exit()
            else:
                cnt = 0



if flag == 0:
    for i in range(3):
        if a[i][i] in b:
             cnt += 1
    else:
        if cnt == 3:
            print("Yes")
            flag += 1
            exit()
        else:
            cnt = 0


if flag == 0:
    if a[2][0] in b:
        if a[1][1] in b:
            if a[0][2] in b:
                print("Yes")
                flag += 1


if flag == 0:
    print("No")