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




from __future__ import division, print_function 

import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io


"""Uncomment modules according to your need"""













if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip



"""value of mod"""
MOD = 998244353
mod = 10**9 + 7

"""Uncomment next 4 lines if doing huge recursion"""




def prepare_factorial(mod=mod):
    """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """
    
    fact = [1]
    for i in range(1, 200005):
        fact.append((fact[-1] * i) % mod)

    ifact = [0] * 200005
    ifact[200004] = pow(fact[200004], mod - 2, mod)
    for i in range(200004, 0, -1):
        ifact[i - 1] = (i * ifact[i]) % mod

    return fact, ifact

def modinv(n, p):
    """ returns N inverse modulo p """
    return pow(n, p - 2, p)

def ncr(n, r,  fact, ifact):
    """ takes 4 arguments: n , r and factorial and inverse factorial lists"""
    t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD
    return t


def get_n(Sum):    
    """this function returns the maximum n for which Summation(n) <= Sum"""
    ans = (-1 + sqrt(1 + 8*Sum))//2
    return ans

def sieve(n):
    """ returns a list of prime numbers till n """
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r



def divs(n, start=1):
    """ returns a list of all divisors till n """
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors



def divn(n, primes):
    """ returns the number of divisors, two arguments n and the sieve till n """
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t



def lrfind(d, x, default=-1):
    """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return default, default
    else:
        return left, right

def gcd(x, y): 
    """ returns greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x

def check_sorted(a):
    ''' returns True/False '''
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return False
    return True
def ceil(n, k=1): return n // k + (n % k != 0) 
def input(): return sys.stdin.readline().strip()
def ii(): return int(input()) 
def mi(): return map(int, input().split()) 
def li(): return list(map(int, input().split())) 
def lw(): return input().split() 
def lcm(a, b): return abs(a * b) // gcd(a, b) 
def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) 
def dd(): return defaultdict(int) 
def ddl(): return defaultdict(list) 
def write(s): return sys.stdout.write(s)













def main():
    
    r1=li()
    r2=li()
    r3=li()
    c1=[r1[0],r2[0],r3[0]]
    c2=[r1[1],r2[1],r3[1]]
    c3=[r1[2],r2[2],r3[2]]
    d1=[r1[0],r2[1],r3[2]]
    d2=[r1[2],r2[1],r3[0]]
    n=ii()
    for i in range(n):
        b=ii()
        if b in c1:
            c1.remove(b)
        if b in c2:
            c2.remove(b)
        if b in c3:
            c3.remove(b)
        if b in r1:
            r1.remove(b)
        if b in r2:
            r2.remove(b)
        if b in d1:
            d1.remove(b)
        if b in r3:
            r3.remove(b)
        if b in d2:
            d2.remove(b)
    if(d2==[] or d1==[] or c3==[] or c2==[] or c1==[] or r3==[] or r2==[] or r1==[]  ):print("Yes")
    else: print("No")
        
    































""" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------"""

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill();
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):

    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode('ascii'))
            self.read = lambda: self.buffer.read().decode('ascii')
            self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')



""" main function"""

if __name__ == '__main__':
    main()

Solution (Python):


import numpy as np

def main():
    p = [list(map(int, input().split() ) ) for i in range(3)]
    n = int(input())
    bl = [int(input()) for i in range(n)]

    arr = np.array(p, dtype=np.float64)

    for b in bl:
        if b in arr:
            arr[arr==b] = 0
    yoko0 = np.sum(arr[0])
    yoko1 = np.sum(arr[1])
    yoko2 = np.sum(arr[2])
    tate0 = np.sum(arr[:, 0])
    tate1 = np.sum(arr[:, 1])
    tate2 = np.sum(arr[:, 2])
    naname0 = arr[0][0] + arr[1][1] + arr[2][2]
    naname1 = arr[0][2] + arr[1][1] + arr[2][0]
    if yoko0*yoko1*yoko2*tate0*tate1*tate2*naname0*naname1 == 0:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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

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

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

R = True
L = True
hw = False
_bingo = list(zip(*bingo))
for i in range(3):
    if False not in bingo[i] or False not in _bingo[i]:
        hw = True
        break
    if False is bingo[i][i]: L = False
    if False is bingo[i][2-i]: R = False

if hw or R or L:
    print('Yes')
else:
    print('No')

Solution (Python):
A=[]
B=[[1 for i in range(3)]for j in range(3)]
A.append(list(map(int,input().split(" "))))
A.append(list(map(int,input().split(" "))))
A.append(list(map(int,input().split(" "))))
n=int(input())
for i in range(n):
  num=int(input())
  for l in range(3):
    if num in A[l]:
      N=A[l].index(num)
      B[l][N]=0
a=0
f=0
h=0
for i in range(3):
  if sum(B[i])==0:
    a=1
    break
  g=0
  f=f+B[i][i]
  h=h+B[i][2-i]
  for j in range(3):
    g=g+B[j][i]
  if g==0:
    a=1
    break

if a==1 or f==0 or h==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 i in range(n)]

f = [[False]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      f[i][j] = True
      
if f[0][0] and f[0][1] and f[0][2]:
  print("Yes")
elif f[1][0] and f[1][1] and f[1][2]:
  print("Yes")
elif f[2][0] and f[2][1] and f[2][2]:
  print("Yes")
elif f[0][0] and f[1][0] and f[2][0]:
  print("Yes")
elif f[0][1] and f[1][1] and f[2][1]:
  print("Yes")
elif f[0][2] and f[1][2] and f[2][2]:
  print("Yes")
elif f[0][0] and f[1][1] and f[2][2]:
  print("Yes")
elif f[0][2] and f[1][1] and f[2][0]:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter
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())
for _ in range(N):
  b=int(input())
  
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  

  

if True in [ not False in [A[j][i]==A[j+1][i] for j in range(len(A)-1)] for i in range(len(A[0]))]:
  print("Yes")

elif True in [len(Counter(tmpA))==1 for tmpA in A]:
  print("Yes")

elif A[1][1]==-1 and (A[0][0] == A[2][2] or A[0][2]==A[2][0]):
  print("Yes")

else:
  print("No")

Solution (Python):
from collections import Counter
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())
for _ in range(N):
  b=int(input())
  
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  

  

if True in [ not False in [A[j][i]==A[j+1][i] for j in range(len(A)-1)] for i in range(len(A[0]))]:
  print("Yes")

elif len(Counter(A[0]))==1 or len(Counter(A[1]))==1 or len(Counter(A[2]))==1:
  print("Yes")

elif A[1][1]==-1 and (A[0][0] == A[2][2] or A[0][2]==A[2][0]):
  print("Yes")

else:
  print("No")

Solution (Python):
from collections import Counter
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())
for _ in range(N):
  b=int(input())
  
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  

  

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

elif len(Counter(A[0]))==1 or len(Counter(A[1]))==1 or len(Counter(A[2]))==1:
  print("Yes")

elif A[1][1]==-1 and (A[0][0] == A[2][2] or A[0][2]==A[2][0]):
  print("Yes")

else:
  print("No")

Solution (Python):
from collections import Counter
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())
for _ in range(N):
  b=int(input())
  
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  

  

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

elif len(Counter(A[0]))==1 or len(Counter(A[1]))==1 or len(Counter(A[2]))==1:
  print("Yes")

elif A[1][1]==-1 and (A[0][0] == A[2][2] or A[0][2]==A[2][0]):
  print("Yes")

else:
  print("No")

Solution (Python):
from collections import Counter
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())
for _ in range(N):
  b=int(input())
  
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  


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

 

if A[0][0]==A[1][0] and A[1][0]==A[2][0] or A[0][2]==A[1][2]and A[1][2]==A[2][2]:
  print("Yes")
 
elif len(Counter(A[0]))==1or len(Counter(A[2]))==1:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter
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())
for _ in range(N):
  b=int(input())
  
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  


if A[1][1]==-1:
  
  if A[0][0] == A[2][2] or A[0][2]==A[2][0]:
    print("Yes")
  
  elif A[0][1]==A[2][1] or A[1][0]==A[1][2]:
    print("Yes")

else:
  
  if A[0][0]==A[1][0] and A[1][0]==A[2][0] or A[0][2]==A[1][2]and A[1][2]==A[2][2]:
    print("Yes")
   
  elif len(Counter(A[0]))==1or len(Counter(A[2]))==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()))
a = [a1, a2, a3]
n = int(input())
b = []
bng = 0
for i in range(n):
    bn = int(input())
    b.append(bn)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -5
for i in range(3):
    if sum(a[i]) == -15:
        bng = 1
for i in range(3):
     cnt = 0
     for j in range(3):
       cnt += a[j][i]
       if cnt == -15:
         bng = 1
        
cnt = 0
for i in range(3):
        cnt += a[i][i]
if cnt == -15:
        bng = 1 
if a[0][2] + a[1][1] + a[2][0] == -15:
    bng = 1
                
if bng == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    if(a[i] == x):
      a[i] = 0
    elif(b[i] == x):
      b[i] = 0
    elif(c[i] == x):
      c[i] = 0

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

Solution (Python):
import sys

A = list(list(map(int, input().split())) for _ in range(3))
N = int(input())
num = list(int(input()) for _ in range(N))

for i in range(3):
    for j in range(3):
        if A[i][j] in num:
            A[i][j] = -1
            
if A[0][0] == -1 and A[0][1] == -1 and A[0][2] == -1:
    print("Yes")
    sys.exit()
elif A[1][0] == -1 and A[1][1] == -1 and A[1][2] == -1:
    print("Yes")
    sys.exit()
elif A[2][0] == -1 and A[2][1] == -1 and A[2][2] == -1:
    print("Yes")
    sys.exit()
elif A[0][0] == -1 and A[1][0] == -1 and A[2][0] == -1:
    print("Yes")
    sys.exit()
elif A[0][1] == -1 and A[1][1] == -1 and A[2][1] == -1:
    print("Yes")
    sys.exit()
elif A[0][2] == -1 and A[1][2] == -1 and A[2][2] == -1:
    print("Yes")
    sys.exit()
elif A[0][0] == -1 and A[1][1] == -1 and A[1][1] == -1:
    print("Yes")
    sys.exit()
elif A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1:
    print("Yes")
    sys.exit()
    
print("No")

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

ans = "No"
if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
  ans = "Yes"
elif a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0:
  ans = "Yes"
else:
  for i in range(3):
    if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0:
      ans = "Yes"
    elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
      ans ="Yes"
print(ans)

Solution (Python):
A = [[]]*3
for T in range(0,3):
    A[T] = [int(x) for x in input().split()]
A   = sum(A,[])
ATF = [False]*9

N = int(input())
for TT in range(0,N):
    B = int(input())
    if B in A:
        ATF[A.index(B)] = True

Flag = 0
if   (all(ATF[:3])) or (all(ATF[3:6])) or (all(ATF[6:])):
    Flag = 1
elif (all(ATF[::3])) or (all(ATF[1::3])) or (all(ATF[2::3])):
    Flag = 1
elif (all(ATF[::4])) or (all(ATF[2:7:2])):
    Flag = 1

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

a = [readints() for i in range(3)]
n = readint()

for i in range(n):
    b = readint()
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
ans = 0
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0:
        ans = 1
        break
    if a[0][i]==a[1][i]==a[2][i]==0:
        ans = 1
        break
if a[0][0]==a[1][1]==a[2][2]:
    ans = 1
if a[0][2]==a[1][1]==a[2][0]:
    ans = 1
print('Yes'if ans else 'No')

Solution (Python):
import copy

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

A_rep = copy.deepcopy(A)

N = int(input())

B = []
for x in range(N):
    B.append(int(input()))
    

for x in range(3):   
    for y in range(3):
        for z in B:
            if A_rep[x][y] == z:
                A_rep[x][y] = -1





for x in range(3):
    if max(A_rep[x]) == -1:
        print("Yes")
        exit()

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

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

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


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

if A_rep[0][2] == -1 and A_rep[1][1] == -1 and A_rep[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)]
 
for num in b:
  for x in range(3):
    for y in range(3):
      if a[x][y] == num:
        a[x][y] = 0
 
if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][1],a[2][2]]) == 0 or sum([a[2][0],a[1][1],a[0][2]]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][0],a[2][0]]) == 0 or sum([a[0][1],a[1][1],a[2][1]]) == 0 or sum([a[0][2],a[1][2],a[2][2]]) == 0:
  print("Yes")                                                 
else:
  print("No")

Solution (Python):
A = [[]]*3
for T in range(0,3):
    A[T] = [int(x) for x in input().split()]
A   = sum(A,[])
ATF = [False]*9

N = int(input())
for TT in range(0,N):
    B = int(input())
    if B in A:
        ATF[A.index(B)] = True

Flag = 0
if   (all(ATF[:3])) or (all(ATF[3:6])) or (all(ATF[6:])):
    Flag = 1
elif (all(ATF[::3])) or (all(ATF[1::3])) or (all(ATF[2::3])):
    Flag = 1
elif (all(ATF[::4])) or (all(ATF[2:7:2])):
    Flag = 1

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

Solution (Python):
import numpy as np

A = []

[A.append(list(map(int, input().split(' ')))) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)] 
temp = [[False]*3 for _ in range(3)]


for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            temp[i][j] = True


bingo = []
bingo += temp + np.array(temp).T.tolist() + [[temp[0][0], temp[1][1], temp[2][2]], [temp[0][2], temp[1][1], temp[2][0]]]

result = False
for t in bingo:
    if t.count(True) == 3:
        result = True

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

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

Solution (Python):

a = []
ans = 1
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -1
for k in range(3):
    if a[k] == [-1, -1, -1] or (a[0][k] == a[1][k] == a[2][k] == -1):
        ans = 0
if a[0][0] == a[1][1] == a[2][2] == -1:
    ans = 0
elif a[0][2] == a[1][1] == a[2][0] == -1:
    ans = 0
print('YNeos'[ans::2])

Solution (Python):
a = []

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


n = int(input())
for i in range(n):
  n = int(input())
  if n in a:
    idx = a.index(n)
    a[idx] = 0


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


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


if (a[0] == 0 and a[4] == 0 and a[8] == 0) or (a[2] == 0 and a[4] == 0 and a[6] == 0):
  print('Yes')
  exit(0)

print('No')

Solution (Python):
A11, A12, A13 = list(map (int, input().split()))
A21, A22, A23 = list(map (int, input().split()))
A31, A32, A33 = list(map (int, input().split()))

called = []
N = int(input())

for i in range(0,N):
  b = int(input())
  called.append(b)
  
if A11 in called and A12 in called and A13 in called:
  print("Yes")
elif A21 in called and A22 in called and A23 in called:
  print("Yes")
elif A31 in called and A32 in called and A33 in called:
  print("Yes")
elif A11 in called and A21 in called and A31 in called:
  print("Yes")
elif A12 in called and A22 in called and A32 in called:
  print("Yes")
elif A13 in called and A23 in called and A33 in called:
  print("Yes")
elif A11 in called and A22 in called and A33 in called:
  print("Yes")
elif A13 in called and A22 in called and A31 in called:
  print("Yes")
else:
  print("No")

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

for i in range(3):
    ans = True
    for j in range(3):
        if a[i][j] not in b:
            ans = False
    if ans:
        print("Yes")
        sys.exit()
for j in range(3):
    ans = True
    for i in range(3):
        if a[i][j]  not in b:
            ans = False
    if ans:
        print("Yes")
        sys.exit()
if all([a[0][0] in b, a[1][1] in b, a[2][2] in b]) or all([a[0][2] in b, a[1][1] in b, a[2][0] in b]):
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
bingo = ({(0,0),(0,1),(0,2)},{(1,0),(1,1),(1,2)},
         {(2,0),(2,1),(2,2)},{(0,0),(1,0),(2,0)},
         {(0,1),(1,1),(2,1)},{(0,2),(1,2),(2,2)},
         {(0,0),(1,1),(2,2)},{(0,2),(1,1),(2,0)})

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

a = set()
for i in range(3):
    for j in range(3):
        if card[i][j] in b:
            a.add((i,j))

flag = False
for line in bingo:
    if line <= a:
        flag = True
        break

if flag:
    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())
lst=[]
flg=False
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
if a[0][0]==a[0][1]==a[0][2]==0:
    flg=True
if a[1][0]==a[1][1]==a[1][2]==0:
    flg=True
if a[2][0]==a[2][1]==a[2][2]==0:
    flg=True
if a[0][0]==a[1][0]==a[2][0]==0:
    flg=True
if a[0][1]==a[1][1]==a[2][1]==0:
    flg=True
if a[0][2]==a[1][2]==a[2][2]==0:
    flg=True
if a[0][0]==a[1][1]==a[2][2]==0:
    flg=True
if a[0][2]==a[1][1]==a[2][0]==0:
    flg=True
if flg==True:
    print("Yes")
else:
    print("No")

Solution (Python):

import numpy as np
a0=np.array(list(map(int,input().split())))
a1=np.array(list(map(int,input().split())))
a2=np.array(list(map(int,input().split())))
A=np.array([a0,a1,a2])

C=np.zeros((3, 3))
n=int(input())
B=[]
for i in range(n):
    b=int(input())
    B.append(b)

for i in range(3):
    for j in range(3):
        if int(A[i][j]) in B:
            C[i][j]=1

if int(C[0][0]*C[0][1]*C[0][2])==1 or\
int(C[1][0]*C[1][1]*C[1][2])==1 or\
int(C[2][0]*C[2][1]*C[2][2]) ==1 or\
int(C[0][0]*C[1][0]*C[2][0])==1 or\
int(C[0][1]*C[1][1]*C[2][1])==1 or\
int(C[0][2]*C[1][2]*C[2][2])==1 or\
int(C[0][0]*C[1][1]*C[2][2])==1 or\
int(C[0][2]*C[1][1]*C[2][0])==1 :
    print('Yes')
else:
    print('No')

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

N = int(input())

for _ in range(N):
    v = int(input())
    for j in range(3):
        for k in range(3):
            if v in bingo[j]:
                id = bingo[j].index(v)
                bingo[j][id] = 0

def judge(l):
    for i in range(3):
        if l[i][0] + l[i][1] + l[i][2] == 0: 
            return print("Yes")

        if l[0][i] + l[1][i] + l[2][i] == 0: 
            return print("Yes")

    if l[0][0] + l[1][1] + l[2][2] == 0 or l[2][0] + l[1][1] + l[0][2] == 0:
        return print("Yes")

    return print("No")

judge(bingo)

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

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

if cnt>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 num in b:
  for x in range(3):
    for y in range(3):
      if a[x][y] == num:
        a[x][y] = 0

if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][1],a[2][2]]) == 0 or sum([a[2][0],a[1][1],a[0][2]]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][0],a[2][0]]) == 0 or sum([a[0][1],a[1][1],a[2][1]]) == 0 or sum([a[0][2],a[1][2],a[2][2]]) == 0:
  print("Yes")                                                 
else:
  print("No")

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

n = int(input())

if n < 3:
    print('No')
    exit()

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

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

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

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

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

print('No')

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

for i in range(n): 
    hoge = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == hoge:
                a[j][k] = 0
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i]:
        ans = 'Yes'
    if a[i][0] == a[i][1] == a[i][2]:
        ans = 'Yes'
if a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]:
    ans = 'Yes'
print(ans)

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 = [int(input()) for i in range(n)]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if B[i] == A[j][k]:
        A[j][k] = "*"
ans = ["*","*","*"]
for i in range(3):
  if A[i] == ans or [A[0][i],A[1][i],A[2][i]] == ans:
    print("Yes")
    exit()
    
if [A[0][0],A[1][1],A[2][2]] == ans or [A[0][2],A[1][1],A[2][0]] == ans:
  print("Yes")
  exit()

print("No")

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

n=int(input())
for i in range(n):
  b=int(input())
  if b in A:
    A[Ad[b]]=-1

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

for i in range(3):
  if A[i]==-1 and A[i+3]==-1 and A[i+6]==-1:
    print('Yes')
    exit()
    
if A[0]==-1 and A[4]==-1 and A[8]==-1:
  print('Yes')
  exit()
  
if A[2]==-1 and A[4]==-1 and A[6]==-1:
  print('Yes')
  exit()
  
print('No')

Solution (Python):
def solve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for b in B:
        for a in A:
            if b in a:
                a[a.index(b)] = 0

    print(judge(A))


def judge(A):
    if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
        return 'Yes'
    elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
        return 'Yes'
    elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
        return 'Yes'
    elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
        return 'Yes'
    elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
        return 'Yes'
    for i in range(3):
        if A[i].count(0) == 3:
            return 'Yes'
    return 'No'




if __name__ == '__main__':
    solve()

Solution (Python):
import sys
a=[[int(x) for x in input().split()] for i in range(3)]
n=int(input())
for i in range(n):
  bi = int(input())
  for j in range(3):
    if bi in a[j]:
      a[j][a[j].index(bi)] = 0
  
  for j in range(3):
    x = [a[k][j] for k in range(3)]
    if (not any(x)) or (not any(a[j])):
      print('Yes')
      sys.exit()
  if not any([a[0][0],a[1][1],a[2][2]]):
    print('Yes')
    sys.exit()
  if not any([a[2][0],a[1][1],a[0][2]]):
    print('Yes')
    sys.exit()
print('No')