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=[]
for _ in range(3):
    a=list(map(int,input().split()))
    A.append(a)
N=int(input())
L=[[0]*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:
                L[i][j]=1

if L[0][0]==L[0][1]==L[0][2]==1 or L[1][0]==L[1][1]==L[1][2]==1 or L[2][0]==L[2][1]==L[2][2]==1 or L[0][0]==L[1][0]==L[2][0]==1 or L[0][1]==L[1][1]==L[2][1]==1 or L[0][2]==L[1][2]==L[2][2]==1 or L[0][0]==L[1][1]==L[2][2]==1 or L[2][0]==L[1][1]==L[0][2]==1:
    print('Yes')
else:
    print('No')

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

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

n = int(input())

for _ in range(n):
    b = int(input())
    if b in A1:
        A1[A1.index(b)]=0
    if b in A2:
        A2[A2.index(b)]=0
    if b in A3:
        A3[A3.index(b)]=0
if sum(A1)==0 or sum(A2)==0 or sum(A3)==0 or A1[0]+A2[1]+A3[2]==0 or A1[2]+A2[1]+A3[0]==0 or A1[0]+A2[0]+A3[0]==0 or A1[1]+A2[1]+A3[1]==0 or A1[2]+A2[2]+A3[2]==0:
    print('Yes')
else:
    print('No')

Solution (Python):

A = []
for _ in range(3):
    tmp = list(map(int,input().split()))
    A.extend(tmp)
B = [0]*9
N = int(input())
for _ in range(N):
    tmp = int(input())
    for i in range(9):
        if tmp==A[i]:
            B[i] = 1
ans = 'No'
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 B[i]+B[j]+B[k]==3:
        ans = 'Yes'
print(ans)

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

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


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

flag = False
if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
    flag = True
if a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
    flag = True
if a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0:
    flag = True
if a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
    flag = True
if a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
    flag = True
if a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0:
    flag = True
if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    flag = True
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    flag = True

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

Solution (Python):
def f():
  lst=[]
  lst2=[]
  for _ in range(3):
      lst.append(input().split(" "))
  n=int(input())
  for i in range(n):
    lst2.append(input())
  for i in range(n):
    for j in range(3):
      for k in range(3):
        if lst[j][k]==lst2[i]:
          lst[j][k]="0"
  if lst[0][0]=="0" and lst[1][1]=="0" and lst[2][2]=="0":
    print("Yes")
    return()
  elif lst[0][2]=="0" and lst[1][1]=="0" and lst[2][0]=="0":
    print("Yes")
    return()
  else:
    for i in range(3):
      if lst[i][0]=="0" and lst[i][1]=="0" and lst[i][2]=="0":
        print("Yes")
        return()
      elif lst[0][i]=="0" and lst[1][i]=="0" and lst[2][i]=="0":
        print("Yes")
        return()
  print("No")
  return()

if __name__=="__main__":
  f()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = [list(map(int, readline().split())) for _ in range(3)]
    N, *B = map(int, read().split())

    nums = [False] * 101
    for b in B:
        nums[b] = True

    for i in range(3):
        ok = True
        for j in range(3):
            if not nums[A[i][j]]:
                ok = False
                break

        if ok:
            print('Yes')
            return

    for j in range(3):
        ok = True
        for i in range(3):
            if not nums[A[i][j]]:
                ok = False
                break

        if ok:
            print('Yes')
            return

    if nums[A[0][0]] and nums[A[1][1]] and nums[A[2][2]]:
        print('Yes')
        return

    if nums[A[0][2]] and nums[A[1][1]] and nums[A[0][2]]:
        print('Yes')
        return

    print('No')

    return


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

C = [[0,0,0],[0,0,0],[0,0,0]]
Ans = "No"

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 C[i][0]+C[i][1]+C[i][2] == 3:
        Ans ="Yes"

for i in range(3):
    if C[0][i]+C[1][i]+C[2][i] == 3:
        Ans ="Yes"
        
if C[0][0]+C[1][1]+C[2][2] == 3 or C[0][2]+C[1][1]+C[2][0] == 3:
    Ans = "Yes"
    
print(Ans)

Solution (Python):
A = [list(map(int,input().split())) for n in range(3)]
N = int(input())
B = [int(input()) for n in range(N)]
C = [[0,0,0],[0,0,0],[0,0,0]]
ans = "No"

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 C[i][0]+C[i][1]+C[i][2]==3:
    ans = "Yes"

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

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

print(ans)

Solution (Python):
import sys
A = []
for i in range(3):
    ls = [int(i) for i in input().split()]
    A.append(ls)
N = int(input())
ls = []
for i in range(N):
    num = int(input())
    ls.append(num)
for x in ls:
    for i in range(3):
        for j in range(3):
            if A[i][j] == x:
                A[i][j] = 0
for i in range(3):
    if sum(A[i]) == 0:
        print('Yes')
        sys.exit()
    num = 0
    for j in range(3):
        num += A[j][i]
    if num == 0:
        print('Yes')
        sys.exit()
num = 0
for i in range(3):
    num += A[i][i]
if num == 0:
    print('Yes')
    sys.exit()
if A[0][2] + A[1][1] + A[2][0] == 0:
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
import numpy as np
A = np.array([list(map(int, input().split())) for i in range(3)])
N = int(input())
for i in range(N):
    A = np.where(A == int(input()), 0, A)
if (np.any(np.sum(A, axis = 0) == 0) or 
    np.any(np.sum(A, axis = 1) == 0) or
    np.trace(A) == 0 or
    np.trace(np.fliplr(A)) == 0):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

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

N = int(input())
b = []
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]=0
naname=0
naname+=A[0][0]+A[1][1]+A[2][2]
if naname==0:
  print("Yes")
  sys.exit(0)
naname=0
naname+=A[0][2]+A[1][1]+A[2][0]
if naname==0:
  print("Yes")
  sys.exit(0)
  
for i in range(3):
  gyou=0
  retu=0
  gyou+=A[i][0]+A[i][1]+A[i][2]
  retu+=A[0][i]+A[1][i]+A[2][i]
  if gyou==0 or retu==0:
    print("Yes")
    sys.exit(0)
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)]
cnt = [0]*8
ans = "No"
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            cnt[i] += 1
            cnt[j+3] += 1
            if i== j:
                cnt[-2] += 1
            if i+j == 2:
                cnt[-1] += 1
for k in range(8):
    if cnt[k] >= 3:
        ans = "Yes"
        break
print(ans)

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

mat, q, b = [list(map(int, input().split())) for i in range(3)], int(
    input()), [[False, False, False] for i in range(3)]
s = [int(input()) for i in range(q)]
for i in range(q):
    x = s[i]
    for j in range(3):
        for k in range(3):
            if mat[j][k] == x:
                b[j][k] = True
    
    for l in b:
        if l == [True, True, True]:
            print('Yes')
            exit()
    for j in range(3):
        if [b[i][j] for i in range(3)] == [True, True, True]:
            print('Yes')
            exit()
    if [b[0][0], b[1][1], b[2][2]] == [True, True, True]:
        print('Yes')
        exit()
    if [b[0][2], b[1][1], b[2][0]] == [True, True, True]:
        print('Yes')
        exit()
print('No')

Solution (Python):
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))
n = int(input())
b = list(int(input()) for i in range(n))

for i in range(n):
    if b[i] in x:
        x[x.index(b[i])] = 'T'
    if b[i] in y:
        y[y.index(b[i])] = 'T'
    if b[i] in z:
        z[z.index(b[i])] = 'T'

if x[0] == 'T' and x[1] == 'T' and x[2] == 'T':
    print('Yes')
elif y[0] == 'T' and y[1] == 'T' and y[2] == 'T':
    print('Yes')
elif z[0] == 'T' and z[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[0] == 'T' and z[0] == 'T':
    print('Yes')
elif x[1] == 'T' and y[1] == 'T' and z[1] == 'T':
    print('Yes')
elif x[2] == 'T' and y[2] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[2] == 'T' and y[1] == 'T' and z[0] == 'T':
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import numpy as np

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))

As = np.array([A1, A2, A3])

bingo = np.array([[False] * 3, [False] * 3, [False] * 3])
for b in B:
    for i, A in enumerate(As):
        for j, a in enumerate(A):
            if b == a:
                bingo[i][j] = True

for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2]:
        print('Yes')
        sys.exit(0)

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

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

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

print('No')

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
C = [0] * 8
N = int(input())
flg = False
for _ in range(N):
    b = int(input())
    if flg:
        continue
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                C[i] += 1
                C[j + 3] += 1
                C[6] += 1 if i + j == 2 else 0
                C[7] += 1 if i == j else 0
                for c in C:
                    if c >= 3:
                        flg = True
                        break
if flg:
    print('Yes')
else:
    print('No')

Solution (Python):
def resolve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    punch = [[False for _ in range(3)] for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                punch[i][j] = True
    ans = "No"
    for i in range(3):
        if False not in punch[i]:
            ans = "Yes"
            break
        for j in range(3):
            if not punch[j][i]:
                break
        else:
            ans = "Yes"
            break
    if (punch[0][0] and punch[1][1] and punch[2][2]) or (
            punch[0][2] and punch[1][1] and punch[2][0]):
        ans = "Yes"
    print(ans)


resolve()

Solution (Python):
A = []

for i in range(3):
    for number in input().split():
        A.append(int(number))

N = int(input())

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


def bingo(card):
    
    if sum(card[:3]) == 0 or sum(card[3:6]) == 0 or sum(card[6:]) == 0:
        return True

    
    if sum(card[::3]) == 0 or sum(card[1::3]) == 0 or sum(card[2::3]) == 0:
        return True

    
    if sum(card[::4]) == 0 or sum(card[2:7:2]) == 0:
        return True


if bingo(A):
    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()))
a=a1+a2+a3
n=int(input())
b=[]
ans=False
for i in range(n):
    num=int(input())
    b.append(num)
for i in range(len(a)):
    for j in b:
        if a[i]==j:
            a[i]=0
if a[0]+a[1]+a[2]==0:
    ans=True
elif a[3]+a[4]+a[5]==0:
    ans=True
elif a[6]+a[7]+a[8]==0:
    ans=True
elif a[0]+a[3]+a[6]==0:
    ans=True
elif a[1]+a[4]+a[7]==0:
    ans=True
elif a[2]+a[5]+a[8]==0:
    ans=True
elif a[0]+a[4]+a[8]==0:
    ans=True
elif a[2]+a[4]+a[6]==0:
    ans=True
if ans==True:
    print("Yes")
else:
    print("No")

Solution (Python):
"""abc157_b"""

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

N = int(input())

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

for a in A:
    for i in range(3):
        if a[i] in B:
            a[i] = 0

ANS = "No"

for a in A:
    if sum(a) == 0:
        ANS = "Yes"
        break

verti = 0
for i in range(3):
    for j in range(3):
        verti += A[j][i]
    if verti == 0:
        ANS = "Yes"
        break
    verti = 0

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

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

print(ANS)

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

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l]==0 and a[2][l]==0:
        ans=1
        break




if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")

Solution (Python):
a = list()
a[0:2] = map(int, input().split())
a[3:5] = map(int, input().split())
a[6:8] = map(int, input().split())
n = int(input())
for i 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] == 0:
        print("Yes")
        exit()
print("No")

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

grid = []

for _ in range(3):
    grid.append(LIST())

n =INT()

for _ in range(n):
    b = INT()
    for i in range(3):
        for j in range(3):
            if(grid[i][j]==b):
                grid[i][j] = -1
flag = 0
for i in range(3):
    if(sum(grid[i])==-3):
        flag = 1
        break
if(flag==0):
    for i in range(3):
        temp = 0
        for j in range(3):
            temp+=grid[j][i]
        if(temp==-3):
            flag= 1
            break
if(flag==0):
    temp = 0
    for i in range(3):
        temp+=grid[i][i]
    if(temp==-3):
        flag = 1
if(flag==0):
    temp = 0
    for i in range(3):
        temp += grid[i][2-i]
    if (temp == -3):
        flag = 1
if(flag==1):
    print("Yes")
else:
    print("No")

Solution (Python):

import sys
import numpy as np
import itertools as itlt
from collections import deque
 

 
s = [[0,0,0]
    ,[0,0,0]
    ,[0,0,0]]    
s[0] = [int(x) for x in sys.stdin.readline().split()]
s[1] = [int(x) for x in sys.stdin.readline().split()]
s[2] = [int(x) for x in sys.stdin.readline().split()]
g = [[0,0,0]
    ,[0,0,0]
    ,[0,0,0]]
N = int(sys.stdin.readline())
p = list([0]*N)
s = np.array(s)
for _ in range(N):
    a = int(sys.stdin.readline())
    b = np.where(s == a)
    for i in range(np.size(b[0])):
        g[b[0][i]][b[1][i]] = 1
 

 
 
flg_win = 0
 
for i in range(3):
    if (g[i][0] + g[i][1] + g[i][2]) == 3:
        flg_win = 1
    if (g[0][i] + g[1][i] + g[2][i]) == 3:
        flg_win = 1
 
if (g[0][0]+g[1][1]+g[2][2]) == 3:
    flg_win = 1
 
if (g[0][2]+g[1][1]+g[2][0]) == 3:
    flg_win = 1
 
if flg_win == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

bingo = [list(map(int,input().split())) for i in range(3)]
n = int(input())
hole = [[0,0,0] for i in range(3)]

for i in range(n):
    a = int(input())
    for j in range(3):
        for k in range(3):
            if(bingo[j][k] == a):
                hole[j][k] = 1


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

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


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

Solution (Python):
def main():
    a = [[int(i) for i in input().split()] for _ in range(3)]
    n = int(input())
    ans = 'No'
    for i in range(n):
        b = int(input())
        for index, j in enumerate(a):
            if j[0] == b:
                a[index][0] = 0
            elif j[1] == b:
                a[index][1] = 0
            elif j[2] == b:
                a[index][2] = 0

    for i in a:
        if not any(i):
            ans = 'Yes'

    for i in zip(*a):
        if not any(i):
            ans = 'Yes'

    if not a[0][0] and not a[1][1] and not a[2][2]:
        ans = 'Yes'
    elif not a[0][2] and not a[1][1] and not a[2][0]:
        ans = 'Yes'

    print(ans)


if __name__ == "__main__":
    main()

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

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

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

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

for _ in range(N):
    b = input()
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                C[i][j] = True

ans = False
for i in range(3):
    ans |= C[i][0] and C[i][1] and C[i][2]
for j in range(3):
    ans |= C[0][j] and C[1][j] and C[2][j]

ans |= C[0][0] and C[1][1] and C[2][2]
ans |= C[2][0] and C[1][1] and C[0][2]

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

Solution (Python):
a=list(map(str,input().split()))
b=list(map(str,input().split()))
c=list(map(str,input().split()))
n=int(input())
s=[input() for i in range(n)]
if b[1]in s and a[0] in s and c[2] in s:
    print("Yes")
elif b[1]in s and a[1] in s and c[1] in s:
    print("Yes")
elif b[1]in s and  a[2] in s and c[0] in s:
    print("Yes")
elif b[1]in s and b[0] in s and b[2] in s:
    print("Yes")
elif a[0] in s and a[1] in s and a[2] in s:
    print("Yes")
elif a[0] in s and b[0] in s and c[0] in s:
    print("Yes")
elif c[2] in s and a[2] in s and b[2] in s:
    print("Yes")
elif c[2] in s and c[0]in s and c[1] in s:
    print("Yes")
else:
  print("No")

Solution (Python):
def main():
    top = list(map(int, input().split()))
    middle = list(map(int, input().split()))
    bottom = list(map(int, input().split()))
    N = int(input())
    taken = []
    for i in range(N):
        taken.append(int(input()))
    
    bingo = []
    bingo.append(top)
    bingo.append(middle)
    bingo.append(bottom)
    temp = [top[0], middle[0], bottom[0]]
    bingo.append(temp)
    temp = [top[1], middle[1], bottom[1]]
    bingo.append(temp)
    temp = [top[2], middle[2], bottom[2]]
    bingo.append(temp)
    temp = [top[0], middle[1], bottom[2]]
    bingo.append(temp)
    temp = [top[2], middle[1], bottom[0]]
    bingo.append(temp)
 
 
    cnt = 0
    flag = 0
    for i in range(len(bingo)):
        cnt = 0
        for j in range(len(bingo[i])):
            if bingo[i][j] in taken:
                cnt += 1
        if cnt == 3:
            flag += 1
    
    if flag > 0:
        print('Yes')
    else:
        print('No')
main()

Solution (Python):
def main():
    top = list(map(int, input().split()))
    middle = list(map(int, input().split()))
    bottom = list(map(int, input().split()))
    N = int(input())
    taken = []
    for f in range(N):
        taken.append(int(input()))
    
    bingo = []
    bingo.append(top)
    bingo.append(middle)
    bingo.append(bottom)
    temp = [top[0], middle[0], bottom[0]]
    bingo.append(temp)
    temp = [top[1], middle[1], bottom[1]]
    bingo.append(temp)
    temp = [top[2], middle[2], bottom[2]]
    bingo.append(temp)
    temp = [top[0], middle[1], bottom[2]]
    bingo.append(temp)
    temp = [top[2], middle[1], bottom[0]]
    bingo.append(temp)
    
    if bingo[0][0] in taken and bingo[0][1] in taken and bingo[0][2] in taken:
        print('Yes')
    elif bingo[1][0] in taken and bingo[1][1] in taken and bingo[1][2] in taken:
        print('Yes')
    elif bingo[2][0] in taken and bingo[2][1] in taken and bingo[2][2] in taken:
        print('Yes')
    elif bingo[3][0] in taken and bingo[3][1] in taken and bingo[3][2] in taken:
        print('Yes')
    elif bingo[4][0] in taken and bingo[4][1] in taken and bingo[4][2] in taken:
        print('Yes')
    elif bingo[5][0] in taken and bingo[5][1] in taken and bingo[5][2] in taken:
        print('Yes')
    elif bingo[6][0] in taken and bingo[6][1] in taken and bingo[6][2] in taken:
        print('Yes')
    elif bingo[7][0] in taken and bingo[7][1] in taken and bingo[7][2] in taken:
        print('Yes')
    else:
        print('No')
main()

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=[]
for i in range(N):
    b.append(int(input()))
    
for i in b:
    for j in range(3):
        if A_1[j] == i:
            A_1[j] = -1

        if A_2[j] == i:
            A_2[j] = -1
            
        if A_3[j] == i:
            A_3[j] = -1


if A_1[0] == A_2[0] == A_3[0] == -1 or A_1[1] == A_2[1] == A_3[1] == -1 or A_1[2] == A_2[2] == A_3[2] == -1:
    print('Yes')
elif A_1[0] == A_1[1] == A_1[2] == -1 or A_2[0] == A_2[1] == A_2[2] == -1 or A_3[0] == A_3[1] == A_3[2] == -1:
    print('Yes')
elif A_1[0] == A_2[1] == A_3[2] == -1 or A_1[2] == A_2[1] == A_3[0] == -1:
    print('Yes')
else:
    print('No')

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

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

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

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


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

print("No")

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

Solution (Python):
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
for i in range (3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j]=0
if a[0][0]==0 and a[0][1]==0 and a[0][2]==0:
  print('Yes')
elif a[1][0]==0 and a[1][1]==0 and a[1][2]==0:
  print('Yes')
elif a[2][0]==0 and a[2][1]==0 and a[2][2]==0:
  print('Yes')
elif a[0][0]==0 and a[1][0]==0 and a[2][0]==0:
  print('Yes')
elif a[0][1]==0 and a[1][1]==0 and a[2][1]==0:
  print('Yes')
elif a[0][2]==0 and a[1][2]==0 and a[2][2]==0:
  print('Yes')
elif a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
  print('Yes')
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
  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()))



yoko_1=set(A1)
yoko_2=set(A2)
yoko_3=set(A3)
tate_1=set([A1[0],A2[0],A3[0]])
tate_2=set([A1[1],A2[1],A3[1]])
tate_3=set([A1[2],A2[2],A3[2]])
naname_1=set([A1[0],A2[1],A3[2]])
naname_2=set([A1[2],A2[1],A3[0]])
B=set(b)

if yoko_1<=B or yoko_2<=B or yoko_3<=B or tate_1<=B or tate_2<=B or tate_3<=B or naname_1<=B or naname_2<=B:
    print('Yes')
else:
    print('No')

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
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:
                A[j][k] = -1

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

Solution (Python):
B=[]
B+=[list(map(int,input().split()))]
B+=[list(map(int,input().split()))]
B+=[list(map(int,input().split()))]
N = int(input())
for _ in range(N):
    a = int(input())
    for i in range(3):
        for j in range(3):
            if B[i][j] == a:
                B[i][j] = 0

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

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

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

print("No")

Solution (Python):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
l = []
for i in range(int(input())):
    l.append(int(input()))
if (l.__contains__(a11) and l.__contains__(a12) and l.__contains__(a13)):
    print('Yes')
elif (l.__contains__(a21) and l.__contains__(a22) and l.__contains__(a23)):
    print('Yes')
elif (l.__contains__(a31) and l.__contains__(a32) and l.__contains__(a33)):
    print('Yes')
elif (l.__contains__(a31) and l.__contains__(a21) and l.__contains__(a11)):
    print('Yes')
elif (l.__contains__(a12) and l.__contains__(a22) and l.__contains__(a32)):
    print('Yes')
elif (l.__contains__(a13) and l.__contains__(a23) and l.__contains__(a33)):
    print('Yes')
elif (l.__contains__(a11) and l.__contains__(a22) and l.__contains__(a33)):
    print('Yes')
elif (l.__contains__(a13) and l.__contains__(a22) and l.__contains__(a31)):
    print('Yes')
else:
    print('No')

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

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b_list:
            card[i][j] = 1

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

Solution (Python):
bingo_int_list = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
num_int_list = [int(input()) for _ in range(N)]
num_int_set = set(num_int_list)

bingo_bin_list = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(3):
    for j in range(3):
        if bingo_int_list[i][j] in num_int_set:
            bingo_bin_list[i][j] = 1


for i in range(3):
    if sum(bingo_bin_list[i]) == 3:
        print('Yes')
        exit()


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


if bingo_bin_list[0][0] + bingo_bin_list[1][1] + bingo_bin_list[2][2] == 3 or bingo_bin_list[0][2] + bingo_bin_list[1][
    1] + bingo_bin_list[2][0] == 3:
    print('Yes')
    exit()

print('No')

Solution (Python):

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

cnt = [0]*8
for i in range(3):
    for j in range(3):
        if bingo[i][j] in b:
            cnt[i] += 1
            cnt[j+3] += 1
            if i == j:
                cnt[-1] += 1
            if i+j == 2:
                cnt[-2] += 1
ans = "No"
for i in cnt:
    if i >= 3:
        ans = "Yes"
        break
print(ans)