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_list1 = list(map(int, input().split()))
A_list2 = list(map(int, input().split()))
A_list3 = list(map(int, input().split()))

bingo = [A_list1, A_list2, A_list3, [A_list1[0], A_list2[1], A_list3[2]], [A_list1[2], A_list2[1], A_list3[0]], [A_list1[0], A_list2[0], A_list3[0]], [A_list1[1], A_list2[1], A_list3[1]], [A_list1[2], A_list2[2], A_list3[2]]]

N = int(input())

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

ans = "No"
for b in bingo:
    c = 0
    for B in b:
        if B in b_list:
            c += 1
    if c == 3:
        ans = "Yes"
        break

print(ans)

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a = []
for i in range(3):
    a.append(inl())
b = [[0]*3 for i in range(3)]
n = inn()
for t in range(n):
    x = inn()
    for i in range(3):
        for j in range(3):
            if a[i][j]==x:
                b[i][j] = 1
if sum(b[0])==3 or \
       sum(b[1])==3 or \
       sum(b[2])==3 or \
       b[0][0]+b[1][0]+b[2][0]==3 or \
       b[0][1]+b[1][1]+b[2][1]==3 or \
       b[0][2]+b[1][2]+b[2][2]==3 or \
       b[0][0]+b[1][1]+b[2][2]==3 or \
       b[0][2]+b[1][1]+b[2][0]==3:
        print('Yes')
else:
        print('No')

Solution (Python):
import sys
a = []
bingo = [[0 for _ in range(3)] for _ in range(3)]
for _ in range(3):
  a_dash = list(map(int,input().split()))
  a.append(a_dash)

n = int(input())
b = []
for _ 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]:
        bingo[j][k] = 1

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

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

for i in range(n):
    m = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == m:
                B[j][k] = True

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

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

print("No")

Solution (Python):
a_1=list(map(int,input().split()))
a_2=list(map(int,input().split()))
a_3=list(map(int,input().split()))
n=int(input())
b=[int(input()) for i in range(n)]
result=0
if (a_1[0] in b) and (a_1[1] in b) and (a_1[2] in b):
  result=1
if (a_2[0] in b) and (a_2[1] in b) and (a_2[2] in b):
  result=1
if (a_3[0] in b) and (a_3[1] in b) and (a_3[2] in b):
  result=1
if (a_1[0] in b) and (a_2[0] in b) and (a_3[0] in b):
  result=1
if (a_1[1] in b) and (a_2[1] in b) and (a_3[1] in b):
  result=1
if (a_1[2] in b) and (a_2[2] in b) and (a_3[2] in b):
  result=1
if (a_1[0] in b) and (a_2[1] in b) and (a_3[2] in b):
  result=1
if (a_1[2] in b) and (a_2[1] in b) and (a_3[0] in b):
  result=1
  
if result==1:
  print('Yes')
else:
  print('No')

Solution (Python):
a_ls1 = list(map(int,input().split()))
a_ls2 = list(map(int,input().split()))
a_ls3 = list(map(int,input().split()))
n = int(input())
b_ls = [int(input()) for _  in range(n)]

a_ls4 = [a_ls1[0],a_ls2[0],a_ls3[0]]
a_ls5 = [a_ls1[1],a_ls2[1],a_ls3[1]]
a_ls6 = [a_ls1[2],a_ls2[2],a_ls3[2]]
a_ls7 = [a_ls1[0],a_ls2[1],a_ls3[2]]
a_ls8 = [a_ls1[2],a_ls2[1],a_ls3[0]]
lss = [a_ls1,a_ls2,a_ls3,a_ls4,a_ls5,a_ls6,a_ls7,a_ls8]

for i in b_ls:
    for j in lss:
        for k in j:
            if i ==k:
                j.pop(j.index(k))
for i in lss:
    if i ==[]:
        print('Yes')
        exit()
print('No')

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

def resolve():
    A = [list(iim()) for i in range(3)]
    N = int(input())
    B = set(int(input()) for i in range(N))

    C = [[i in B for i in aa] for aa in A]

    
    
    

    def f():
        for i in range(3):
            for j in range(3):
                if not C[i][j]:
                    break
            else:
                return True
            for j in range(3):
                if not C[j][i]:
                    break
            else:
                return True
        for i in range(3):
            if not C[i][i]:
                break
        else:
            return True
        for i in range(3):
            if not C[i][2-i]:
                break
        else:
            return True
        return False

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


if __name__ == "__main__":
    resolve()

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
X = [[0 for _ in range(3)] for _ in range(3)]
for n in range(N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == B[n]:
                X[i][j] = 1
tate = any([all([X[i][j] for j in range(3)]) for i in range(3)])
yoko = any([all([X[i][j] for i in range(3)]) for j in range(3)])
nana = all([X[i][i] for i in range(3)]) or all([X[i][2 - i] for i in range(3)])
if tate or yoko or nana:
    print('Yes')
else:
    print('No')

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

A = [list(map(int, (readline().split()))) for _ in range(3)]
N = int(readline().decode())
B = [int(readline().decode().rstrip()) for _ in range(N)]

card = [[False] * 3 for _ in range(3)]

ans = "No"

for b in B:
    for r in range(3):
        for c in range(3):
            if b == A[r][c]:
                card[r][c] = True

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

print(ans)

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

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

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

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

    print('No')

Solution (Python):
def check_bingo(s):
    for l in s:
        if all(l):
            return True

    for i in range(3):
        if s[0][i] and s[1][i] and s[2][i]:
            return True

    if s[0][0] and s[1][1] and s[2][2]:
        return True
    
    if s[0][2] and s[1][1] and s[2][0]:
        return True

    return False

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

if check_bingo(sheet):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    hit = [0] * 9
    for i in range(n):
        b = int(input())
        for j in range(9):
            if a[j] == b:
                hit[j] = 1

    ans = 'No'
    if hit[0] + hit[1] + hit[2] == 3:
        ans = 'Yes'
    if hit[3] + hit[4] + hit[5] == 3:
        ans = 'Yes'
    if hit[6] + hit[7] + hit[8] == 3:
        ans = 'Yes'
    if hit[0] + hit[3] + hit[6] == 3:
        ans = 'Yes'
    if hit[1] + hit[4] + hit[7] == 3:
        ans = 'Yes'
    if hit[2] + hit[5] + hit[8] == 3:
        ans = 'Yes'
    if hit[0] + hit[4] + hit[8] == 3:
        ans = 'Yes'
    if hit[2] + hit[4] + hit[6] == 3:
        ans = 'Yes'

    print(ans)


main()

Solution (Python):
a = [[0]*3 for _ in range(3)]
f = [[0]*3 for _ in range(3)]

for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
ans = "No"

for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                f[j][k] = 1
    
for l in range(3):
    if f[l][0] == 1 and f[l][1] == 1 and f[l][2] == 1:
        ans = "Yes"
    elif f[0][l] == 1 and f[2][l] == 1 and f[1][l] == 1:
        ans = "Yes"
    elif f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
        ans = "Yes"
    elif f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
        ans = "Yes"
        
print(ans)

Solution (Python):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [[0] * 3 for i in range(3)]
for i in range(n):
  num = int(input())
  for i in range(3):
    for j in range(3):
      if num == a[i][j]:
        b[i][j] = 1
for i in range(3):
  if b[i][0] == b[i][1] == b[i][2] == 1:
    print("Yes")
    exit()
  if b[0][i] == b[1][i] == b[2][i] == 1:
    print("Yes")
    exit()
if b[0][0] == b[1][1] == b[2][2] == 1:
  print("Yes")
  exit()
if b[0][2] == b[1][1] == b[2][0] == 1:
  print("Yes")
  exit()
print("No")

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

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

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

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

if A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1:
        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)]

arr=[[False]*3 for _ in range(3)]

for x in b:
  for i in range(3):
    for j in range(3):
      if x==a[i][j]:
        arr[i][j]=True

for i in range(3):
  if all(arr[i]) or all([arr[j][i] for j in range(3)]):
    print('Yes')
    exit()
if all([arr[i][i] for i in range(3)]) or all([arr[i][2-i] for i in range(3)]):
  print('Yes')
  exit()
print('No')

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    A = [LIST() for i in range(3)]
    N = INT()

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

        flag = False
        if A[0][0] + A[0][1] + A[0][2] == 0:
            flag = True
        if A[1][0] + A[1][1] + A[1][2] == 0:
            flag = True
        if A[2][0] + A[2][1] + A[2][2] == 0:
            flag = True
        if A[0][0] + A[1][0] + A[2][0] == 0:
            flag = True
        if A[0][1] + A[1][1] + A[2][1] == 0:
            flag = True
        if A[0][2] + A[1][2] + A[2][2] == 0:
            flag = True
        if A[0][0] + A[1][1] + A[2][2] == 0:
            flag = True
        if A[2][0] + A[1][1] + A[0][2] == 0:
            flag = True

        if flag:
            print("Yes")
            sys.exit()

    print("No")


if __name__ == '__main__':
    main()

Solution (Python):

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

N = int(input())
List=[int(input()) for i in range(N)]

for i in List:
  if i in Bingo[0]:
    a = Bingo[0].index(i)
    Bingo[0][a] = 0
  if i in Bingo[1]:
    a = Bingo[1].index(i)
    Bingo[1][a] = 0
  if i in Bingo[2]:
    a = Bingo[2].index(i)
    Bingo[2][a] = 0
    
ans = "No"

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

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

Solution (Python):
c = []
for i in range(3):
    l = [int(x) for x in input().split()]
    c+=l
n = int(input())
che = [False]*9
ans = "No"
for i in range(n):
    b = int(input())
    for j in range(9):
        if c[j] == b:
            che[j] = True

for i in range(3):
    if che[i] and che[i+3] and che[i+6]:
        ans = "Yes"
        break
    elif che[i*3] and che[i*3 +1] and che[i*3 +2]:
        ans = "Yes"
        break
if ans == "No":
    if che[0] and che[4] and che[8]:
        ans = "Yes"
    elif che[2] and che[4] and che[6]:
        ans = "Yes"
print(ans)

Solution (Python):
p = [input().split() for i in range(3)]
N = int(input())
bs = [input() for i in range(N)]

flag = False
if p[0][0] in bs and p[0][1] in bs and p[0][2] in bs:
  flag = True
if p[1][0] in bs and p[1][1] in bs and p[1][2] in bs:
  flag = True
if p[2][0] in bs and p[2][1] in bs and p[2][2] in bs:
  flag = True
if p[0][0] in bs and p[1][0] in bs and p[2][0] in bs:
  flag = True
if p[0][1] in bs and p[1][1] in bs and p[2][1] in bs:
  flag = True
if p[0][2] in bs and p[1][2] in bs and p[2][2] in bs:
  flag = True
if p[0][0] in bs and p[1][1] in bs and p[2][2] in bs:
  flag = True
if p[0][2] in bs and p[1][1] in bs and p[2][0] in bs:
  flag = True

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

Solution (Python):
A = [[0]*3 for _ in range(3)]

for i in range(3):
    a1, a2, a3 = map(int, input().split())
    A[i][0] = a1
    A[i][1] = a2
    A[i][2] = a3
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        print("Yes")
        exit()
    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):
A = []
for _ in range(3):
    a = list(map(int,input().split()))
    A.append(a)
N = int(input())
Y = []
for _ in range(N):
    y = int(input())
    Y.append(y)
ans = 0
for i in range(3):
    if A[i][0] in Y and A[i][1] in Y and A[i][2] in Y :
        ans = 1
for i in range(3):
    if A[0][i] in Y and A[1][i] in Y and A[2][i] in Y :
        ans = 1
if A[0][0] in Y and A[1][1] in Y and A[2][2] in Y :
    ans = 1
if A[2][0] in Y and A[1][1] in Y and A[0][2] in Y :
    ans = 1
if ans == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
A1=list(map(int, input().split()))
A2=list(map(int, input().split()))
A3=list(map(int, input().split()))
N=int(input())
b=[]
for _ in range(N):
    b.append( int(input()) )
A1_check = [False, False, False]
A2_check = [False, False, False]
A3_check = [False, False, False]
for ii in range(3):
    for b_ in b:
        if A1[ii]==b_:
            A1_check[ii]=True
for ii in range(3):
    for b_ in b:
        if A2[ii]==b_:
            A2_check[ii]=True
for ii in range(3):
    for b_ in b:
        if A3[ii]==b_:
            A3_check[ii]=True
if A1_check[0]*A1_check[1]*A1_check[2]==True or \
   A2_check[0]*A2_check[1]*A2_check[2]==True or \
   A3_check[0]*A3_check[1]*A3_check[2]==True or \
   A1_check[0]*A2_check[0]*A3_check[0]==True or \
   A1_check[1]*A2_check[1]*A3_check[1]==True or \
   A1_check[2]*A2_check[2]*A3_check[2]==True or \
   A1_check[0]*A2_check[1]*A3_check[2]==True or \
   A1_check[2]*A2_check[1]*A3_check[0]==True:
    print('Yes')
else:
    print('No')

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

for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b:
            a1[j]=0
        if a2[j]==b:
            a2[j]=0
        if a3[j]==b:
            a3[j]=0

if a1[0]+a1[1]+a1[2]==0:
    print("Yes")
    exit()
if a2[0]+a2[1]+a2[2]==0:
    print("Yes")
    exit()
if a3[0]+a3[1]+a3[2]==0:
    print("Yes")
    exit()
if a1[0]+a2[0]+a3[0]==0:
    print("Yes")
    exit()
if a1[1]+a2[1]+a3[1]==0:
    print("Yes")
    exit()
if a1[2]+a2[2]+a3[2]==0:
    print("Yes")
    exit()
if a1[0]+a2[1]+a3[2]==0:
    print("Yes")
    exit()
if a1[2]+a2[1]+a3[0]==0:
    print("Yes")
    exit()

print("No")

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


answer = []
for h in hyo:
    answer.append(h)
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(hyo[j][i])
    answer.append(tmp)
answer.append([hyo[0][0],hyo[1][1],hyo[2][2]])
answer.append([hyo[0][2],hyo[1][1],hyo[2][0]])

for a in answer:
    tmp = set(target) & set(a)
    if len(tmp) == 3:
        print('Yes')
        exit(0)
print('No')

Solution (Python):
l = []

for _ in range(3):
    t = [int(x) for x in input().split()]
    l.append(t[0])
    l.append(t[1])
    l.append(t[2])
    
for _ in range(int(input())):
    t = int(input())

    for x in range(9):
        if l[x] == t:
            l[x] = 0

s = ["012", "345", "678", "036", "147", "258", "048", "246"]
flag = 0

for x in s:
    chk = 0
    for y in x:
        if l[int(y)] == 0:
            chk += 1

    if chk == 3:
        flag = 1
        break

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

Solution (Python):
a = []
for _ in range(3):
    a.extend(list(input().split()))

n = int(input())
for _ in range(n):
    k = input()
    for i in range(9):
        if a[i] == str(k):
            a[i] = 0

ans = False

if a[0] == a[1] and a[1] == a[2] and a[2] == 0:
    ans = True

if a[3] == a[4] and a[4] == a[5] and a[5] == 0:
    ans = True

if a[6] == a[7] and a[7] == a[8] and a[8] == 0:
    ans = True

if a[0] == a[3] and a[3] == a[6] and a[6] == 0:
    ans = True

if a[1] == a[4] and a[4] == a[7] and a[7] == 0:
    ans = True

if a[2] == a[5] and a[5] == a[8] and a[8] == 0:
    ans = True

if a[0] == a[4] and a[4] == a[8] and a[8] == 0:
    ans = True

if a[2] == a[4] and a[4] == a[6] and a[6] == 0:
    ans = True

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

Solution (Python):
card = [list(map(int, input().split())) for _ in range(3)]
yes_no = [False]*9
N = int(input())
for i in range(N):
  b = int(input()) 
  for j in range(9):
    j_1 = j//3
    j_2 = j%3
    if b == card[j_1][j_2]:
      yes_no[j] = True

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

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

for i in range(3):
    if l[i][0] in b and l[i][1] in b and l[i][2] in b :
        print("Yes")
        exit()
for j in range(3):
    if l[0][j] in b and l[1][j] in b and l[2][j] in b :
        print("Yes")
        exit()

if l[0][0] in b and l[1][1] in b and l[2][2] in b :
    print("Yes")
    exit()
if l[2][0] in b and l[1][1] in b and l[0][2] in b :
    print("Yes")
    exit()

print("No")

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

A = [iln() for _ in range(3)]
N = iin()
b = [iin() for _ in range(N)]

B = [[False for _ in range(3)] for _ in range(3)]

for i in range(N):
    t = b[i]
    for j in range(3):
        for k in range(3):
            if A[j][k] == t:
                B[j][k] = True

for i in range(3):
    if B[i][0] and B[i][1] and B[i][2]:
        print('Yes')
        exit()
for i in range(3):
    if B[0][i] and B[1][i] and B[2][i]:
        print('Yes')
        exit()
if B[0][0] and B[1][1] and B[2][2]:
    print('Yes')
    exit()
if B[2][0] and B[1][1] and B[0][2]:
    print('Yes')
    exit()
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(3):
        for j in range(3):
            if A[i][j] in b:
                A[i][j] = 0
    for i in range(3):
        row_flag = True
        for j in range(3):
            if A[i][j]!=0:
                row_flag = False
        if row_flag == True:
            print(YES)
            return
    for j in range(3):
        line_flag = True
        for i in range(3):
            if A[i][j]!=0:
                line_flag = False
        if line_flag == True:
            print(YES)
            return
    if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
        print(YES)
        return
    if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
        print(YES)
        return
    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):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
bingo_sheet = [a1, a2, a3]
n = int(input())

memo = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

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

    for j, ai in enumerate(bingo_sheet):
        for k, a in enumerate(ai):
            if a == b:
                memo[j][k] = 1

ans = False

for i in range(3):
    if memo[i][0] and memo[i][1] and memo[i][2]:
        ans = True
        break

    elif memo[0][i] and memo[1][i] and memo[2][i]:
        ans = True
        break

if memo[0][0] and memo[1][1] and memo[2][2]:
    ans = True

if memo[0][2] and memo[1][1] and memo[2][0]:
    ans = True

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

Solution (Python):
def hantei(array):
  for i in range(3):
    if array[i][0] and array[i][1] and array[i][2]:
      return True
    
  for i in range(3):
    if array[0][i] and array[1][i] and array[2][i]:
      return True
    
  if array[0][0] and array[1][1] and array[2][2]:
    return True
  
  if array[2][0] and array[1][1] and array[0][2]:
    return True
  
  return False

bingo = []
array = [[False for i in range(3)] for j in range(3)]

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

n = int(input())

for i in range(n):
  b = int(input())
  
  for j in range(3):
    for k in range(3):
      if b == bingo[j][k]:
        array[j][k] = True
        
if hantei(array):
  print('Yes')
else:
  print('No')

Solution (Python):
from itertools import product

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

for h, w in product(range(3), repeat=2):
    if A[h][w] in B:
        A[h][w] = -1

for h in range(3):
    if all(A[h][i]==-1 for i in range(3)):
        print('Yes')
        exit()

for w in range(3):
    if all(A[i][w]==-1 for i in range(3)):
        print('Yes')
        exit()

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

print('No')

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

flag_hit = [[False,False,False],
            [False,False,False],
            [False,False,False]]

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

flag_bingo = False
for i in range(3):
    if (flag_hit[i][0] is True) and (flag_hit[i][1] is True) and (flag_hit[i][2] is True):
        flag_bingo = True
    if (flag_hit[0][i] is True) and (flag_hit[1][i] is True) and (flag_hit[2][i] is True):
        flag_bingo = True
    if (flag_hit[0][0] is True) and (flag_hit[1][1] is True) and (flag_hit[2][2] is True):
        flag_bingo = True
    if (flag_hit[0][2] is True) and (flag_hit[1][1] is True) and (flag_hit[2][0] is True):
        flag_bingo = True

if flag_bingo is True:
    print("Yes")
else:
    print("No")

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
mark = [[False] * 3 for _ in range(3)]
n = int(input())
for _ in range(n):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j] == b:
        mark[i][j] = True
bingo = False
for i in range(3):
  if mark[i][0] and mark[i][1] and mark[i][2]:
    bingo = True
  if mark[0][i] and mark[1][i] and mark[2][i]:
    bingo = True
if mark[0][0] and mark[1][1] and mark[2][2]:
  bingo = True
if mark[0][2] and mark[1][1] and mark[2][0]:
  bingo = True
if bingo:
  print('Yes')
else:
  print('No')

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