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

Solution (Python):

import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import os
import sys
import datetime
readline=readline = sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s



import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s


A=[input().split() for a in range(3)]
C=[[False for b in range(3)] for a in range(3)]
N=int(input())
B=[]
for a in range(N):
    b=input()
    for c in range(3):
        for d in range(3):
            if A[c][d]==b:
                C[c][d]=True
f=False
for a in range(3):
    if C[a].count(True)==3:
        f=True
    if [C[0][a],C[1][a],C[2][a]].count(True)==3:
        f=True
if [C[0][0],C[1][1],C[2][2]].count(True)==3:
    f=True
if [C[0][2],C[1][1],C[2][0]].count(True)==3:
    f=True
Yn(f)

Solution (Python):
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_c = list(map(int, input().split()))

n = int(input())

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


for i in list_s:
    for j in [list_a, list_b, list_c]:
        for k in range(3):
            if j[k] == i:
                j[k] = -1



for i in [list_a, list_b, list_c]:
    if i[0] == -1 and i[1] == -1 and i[2] == -1:
        print("Yes")
        exit()


for i in range(3):
    if list_a[i] == -1 and list_b[i] == -1 and list_c[i] == -1:
        print("Yes")
        exit()


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

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

print("No")

Solution (Python):
def judge(board):
    for i in range(0, 3):
        if board[i][0] == board[i][1] == board[i][2] == 0 :
            return True
        if board[0][i] == board[1][i] == board[2][i] == 0:
            return True
    
    if board[0][0] == board[1][1] == board[2][2] == 0:
        return True
    if board[0][2] == board[1][1] == board[2][0] == 0:
        return True
    
    return False


upper  = list(map(int, input().split(" ")))
middle = list(map(int, input().split(" ")))
lower  = list(map(int, input().split(" ")))

board = (upper,middle,lower)

N = int(input())
bingos = list()

for i in range(0, N):
    bingos.append(int(input()))


"""
print(upper)
print(middle)
print(lower)
print(bingos)

for i in range(3):
    for j in range(3):
        print(f'board[', i, '][', j, '] =', board[i][j])
"""

for i in range(0, len(bingos)):
    for j in range(0, 3):

        if upper[j] == bingos[i]:
            board[0][j] = 0

            break
        elif middle[j] == bingos[i]:
            board[1][j] = 0

            break
        elif lower[j] == bingos[i]:
            board[2][j] = 0

            break
        else:
            pass


if judge(board):
    print('Yes')
else:
    print('No')

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

for _ in range(N):
  y = int(input())
  A = [0 if x == y else x for x in A]

if any((sum(A[::3]) == 0,
       sum(A[1::3]) == 0,
       sum(A[2::3]) == 0,
       sum(A[:3]) == 0,
       sum(A[3:6]) == 0,
       sum(A[6:]) == 0,
       sum(A[::4]) == 0,
       sum(A[2:7:2]) == 0)):
  print('Yes')
else:
  print('No')

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a = [LI() for _ in range(3)]
    n = I()
    b = [I() for _ in range(n)]
    f = [[False]*3 for _ in range(3)]
    for c in b:
        for i in range(3):
            for j in range(3):
                if c == a[i][j]:
                    f[i][j] = True

    for i in range(3):
        if all(f[i][j] for j in range(3)):
            return "Yes"
        if all(f[j][i] for j in range(3)):
            return "Yes"
    if all(f[i][i] for i in range(3)):
        return "Yes"
    if all(f[i][2-i] for i in range(3)):
        return "Yes"

    return "No"


print(main())

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

n = int(input())

bingo = [[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:
                bingo[i][j] = 1

ok = False

for i in range(3):
    count = 0
    for j in range(3):
        count += bingo[i][j]
    if count == 3:
        ok = True
for i in range(3):
    count = 0
    for j in range(3):
        count += bingo[j][i]
    if count == 3:
        ok = True
count = 0
for i in range(3):
    count += bingo[i][i]
    if count == 3:
        ok = True
count = 0
for i in range(3):
    count += bingo[2-i][i]
    if count == 3:
        ok = True

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

Solution (Python):
import math
import sys

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

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

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

ok = False

ok |= all(A[0][i] in b for i in range(3))
ok |= all(A[1][i] in b for i in range(3))
ok |= all(A[2][i] in b for i in range(3))
ok |= all(A[i][0] in b for i in range(3))
ok |= all(A[i][1] in b for i in range(3))
ok |= all(A[i][2] in b for i in range(3))
ok |= all(A[i][i] in b for i in range(3))
ok |= all(A[i][2 - i] in b for i in range(3))

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

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

Solution (Python):
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = []
for i in range(N):
    B.append(input())
B=set(B)
if set(A[0]) <= B or set(A[1]) <= B or set(A[2]) <= B or {A[0][0], A[1][0], A[2][0]} <= B or\
{A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B \
or {A[0][0], A[1][1], A[2][2]} <= B or {A[0][2], A[1][1], A[2][0]} <= B:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

def BINGO():
    print("Yes")
    sys.exit()

Frow=list(map(int,input().split()))
Srow=list(map(int,input().split()))
Trow=list(map(int,input().split()))
Mybingo=[Frow,Srow,Trow]
n=int(input())

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

for i in range(3):
    for j in range(3):
        if Mybingo[i][j] in blist:
            Mybingo[i][j] = 1
        else:
            Mybingo[i][j] = 0

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

if Mybingo[0][0]+Mybingo[1][1]+Mybingo[2][2] == 3 or Mybingo[0][2]+Mybingo[1][1]+Mybingo[2][0] ==3:
    BINGO()

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)]
bingo = "No"

for i in range(N):
    for a in range(3):
        for b in range(3):
            if(B[i]==A[a][b]):
                A[a][b] = 0
for i in range(3):
    if(A[i]==[0,0,0]):
        bingo = "Yes"
    if(A[0][i]==0 and A[1][i]==0 and A[2][i]==0):
        bingo = "Yes"
if(A[0][0]==0 and A[1][1]==0 and A[2][2]==0):
        bingo = "Yes"
if(A[0][2]==0 and A[1][1]==0 and A[2][0]==0):
        bingo = "Yes"

print(bingo)

Solution (Python):
cards = []
put = []

for i in range(3):
    a, b, c = map(int, input().split())
    cards.append(a)
    cards.append(b)
    cards.append(c)

num = int(input())

for s in range(num):
    tmp = int(input())
    if tmp in cards:
        put_index = cards.index(tmp)
        put.append(put_index)

Yes_flg = False

if len(put) < 3:
    pass
else:
    if 0 in put:
        if 1 in put and 2 in put:
            Yes_flg = True
        elif 3 in put and 6 in put:
            Yes_flg = True
        elif 4 in put and 8 in put:
            Yes_flg = True
    if 4 in put:
        if 3 in put and 5 in put:
            Yes_flg = True
        elif 1 in put and 7 in put:
            Yes_flg = True
        elif 2 in put and 6 in put:
            Yes_flg = True
    if 8 in put:
        if 6 in put and 7 in put:
            Yes_flg = True
        elif 2 in put and 5 in put:
            Yes_flg = True

if Yes_flg:
    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)]

cards = A[0] + A[1] + A[2]

for b in B:
    cards = [c if c != b else 0 for c in cards]

if (sum(cards[0:3]) == 0):
    print('Yes')
elif (sum(cards[3:6]) == 0):
    print('Yes')
elif (sum(cards[6:9]) == 0):
    print('Yes')
elif ((cards[0] + cards[3] + cards[6]) == 0):
    print('Yes')
elif ((cards[1] + cards[4] + cards[7]) == 0):
    print('Yes')
elif ((cards[2] + cards[5] + cards[8]) == 0):
    print('Yes')
elif ((cards[0] + cards[4] + cards[8]) == 0):
    print('Yes')
elif ((cards[2] + cards[4] + cards[6]) == 0):
    print('Yes')
else:
    print('No')

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

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

for i in range(int(input())):
  n=int(input())
  for y in range(3):
    for x in range(3):
      if A[y][x]==n:
        s[y][x]=1

a=[]
for i in range(3):
  a.append(s[0][i]*s[1][i]*s[2][i])
  a.append(s[i][0]*s[i][1]*s[i][2])
a.append(s[0][0]*s[1][1]*s[2][2])
a.append(s[0][2]*s[1][1]*s[2][0])

print('Yes' if 1 in a else 'No')

Solution (Python):
import sys
input = sys.stdin.readlines()
nums = []
[[nums.append(num) for num in row.strip().split(" ")] for row in input[:3]]
bs = [i.strip() for i in input[4:]]
mat = [num in bs for num in nums]
patterns = [[0, 1, 2],
            [0, 4, 8],
            [0, 3, 6],
            [1, 4, 7],
            [2, 4, 6],
            [2, 5, 8],
            [3, 4, 5],
            [6, 7, 8]]
for pat in patterns:
    if mat[pat[0]] and mat[pat[1]] and mat[pat[2]]:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):
import numpy as np
L=[]
bingo = np.zeros([3,3])
for i in range(3):
	L.append(input().split())
L = list(np.reshape(L,9))
N = int(input())
for i in range(N):
	l = input()
	if l in L:
		ptr = L.index(l)
		bingo[ptr/3,ptr%3]=1

ans = "No"
flg = 0
for i in range(3):
	flg = flg or bingo[i,0] and bingo[i,1] and bingo[i,2]
for i in range(3):
	flg = flg or bingo[0,i] and bingo[1,i] and bingo[2,i]
flg = flg or bingo[0,0] and bingo[1,1] and bingo[2,2]
flg = flg or bingo[2,0] and bingo[1,1] and bingo[0,2]
if flg == 1:
	ans = "Yes"
print(ans)

Solution (Python):

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

a = [[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j] == b:
                a[i][j] = True

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

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

def judge(l):
  if len(l)<=2:
    return 'No'
  else:
    if [0,0] in l and [1,1] in l and [2,2] in l:
      return 'Yes'
    elif [0,2] in l and [1,1] in l and [2,0] in l:
      return 'Yes'
    else:
      dic1={}
      dic2={}
      for ij in l:
        i,j=ij[0],ij[1]
        if i not in dic1.keys():
          dic1[i]=1
        else:
          dic1[i]+=1
          if dic1[i]==3:
            return 'Yes'
        if j not in dic2.keys():
          dic2[j]=1
        else:
          dic2[j]+=1
          if dic2[j]==3:
            return 'Yes'
      return 'No'
print(judge(l))

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

for i in out: 
    for j in range(3):
        if i in bingo[j]: 
            bingo[j][bingo[j].index(i)] = 0

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

else :
    for i in range(3):
        if bingo[i][0] == bingo[i][1] == bingo[i][2] == 0:
            print("Yes")
            break
        elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 0:
            print("Yes")
            break
    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)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')

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

for i in range(n):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    elif b in a2:
        a2[a2.index(b)] = 0
    elif b in a3:
        a3[a3.index(b)] = 0

ans = "No"
bi = [0,0,0]
if a1 == bi or a2 == bi or a3 == bi:
    ans = "Yes"
elif a1[0] == 0 and a2[1] == 0 and a3[2] == 0:
    ans = "Yes"
elif a1[2] == 0 and a2[1] == 0 and a3[0] == 0:
    ans = "Yes"
else:
    for i in range(3):
        if a1[i] == 0 and a2[i] == 0 and a3[i] == 0:
            ans = "Yes"
            break
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):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                B[j][k] = 1

flag = 0
for i in range(3):
    if B[i][0]==B[i][1]==B[i][2]==1:
        flag = 1
    if B[0][i]==B[1][i]==B[2][i]==1:
        flag = 1
if B[0][0]==B[1][1]==B[2][2]==1:
    flag = 1
if B[0][2]==B[1][1]==B[2][0]==1:
    flag = 1

if flag == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
def bingo(board):
    for i in range(3):
        if all(board[i][j] for j in range(3)):
            return True
    for j in range(3):
        if all(board[i][j] for i in range(3)):
            return True
    if all(board[i][i] for i in range(3)):
        return True
    if all(board[i][2-i] for i in range(3)):
        return True

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

seen = {}
for i in range(3):
    for j in range(3):
        seen[a[i][j]] = (i, j)

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

n = int(input())
for _ in range(n):
    b = int(input())
    if b in seen:
        board[seen[b][0]][seen[b][1]] = True

if bingo(board):
    print('Yes')
else:
    print('No')

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

for i in range(n):
    b = int(input())
    for j, k in enumerate(horizontals):
        if b in k:
            horizontals[j][k.index(b)] = 0

verticals = [[horizontals[i][j] for i in range(3)] for j in range(3)]
diagonals = [[horizontals[i][i] for i in range(3)],
            [horizontals[j][2-j] for j in range(3)]]
card = horizontals + verticals + diagonals
bingo = [0, 0, 0]
if bingo in card:
    print('Yes')
else:
    print('No')

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

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

for r in range(3):
	if a[r]==[0, 0, 0]:
		print('Yes')
		exit()
	elif a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

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

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

for x in range(n):
	for i in range(3):
		for j in range(3):
			if a[i][j] == b[x]:
				a[i][j] = 0
                
for r in range(3):
	if a[r]==[0, 0, 0]:
		print('Yes')
		exit()
	if a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		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 i 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

bingo = [0, 0, 0]
for i in range(3):
    if a[i] == bingo:
        print("Yes")
        exit()
    tate = []
    for j in range(3):
        tate.append(a[j][i])
        if tate == bingo:
            print("Yes")
            exit()

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

Solution (Python):
import numpy as np
a = [[j for j in 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):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
a = np.array(a)
if sum(a[0,:]) == 0 or sum(a[1,:]) == 0 or sum(a[2,:]) == 0:
    print('Yes')
elif sum(a[:,0]) == 0 or sum(a[:,1]) == 0 or sum(a[:,2]) == 0:
    print('Yes')
elif (a[0][0] + a[1][1] + a[2][2]) == 0 or (a[0][2] + a[1][1] + a[2][0]) == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
A=[[int(i) for i in 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
flag=False
for h in range(3):
    cnt=0
    for w in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for w in range(3):
    cnt=0
    for h in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
cnt=0
for d in range(3):
    if A[d][d]==-1:
        cnt+=1
if cnt==3:
    flag=True
cnt=0
for d in range(3):
    if A[d][2-d]==-1:
        cnt+=1
if cnt==3:
    flag=True
print('Yes' if flag else 'No')

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
s = [[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 b == a[i][j]: s[i][j] = True

for i in range(3):
    if all(s[i]) or (s[0][i] and s[1][i] and s[2][i]):
        print("Yes")
        break
else:
    if all([s[i][i] for i in range(3)]) or all([s[i][2-i] for i in range(3)]):
        print("Yes")
    else: print("No")

Solution (Python):
import itertools
l1=list(map(int,input().split(" ")))
l2=list(map(int,input().split(" ")))
l3=list(map(int,input().split(" ")))
b_st=[list(sorted(l1))]
b_st.append(list(sorted(l2)))
b_st.append(list(sorted(l3)))

b_st.append(list(sorted([l1[0],l2[0],l3[0]])))
b_st.append(list(sorted([l1[1],l2[1],l3[1]])))
b_st.append(list(sorted([l1[2],l2[2],l3[2]])))
b_st.append(list(sorted([l1[0],l2[1],l3[2]])))
b_st.append(list(sorted([l1[2],l2[1],l3[0]])))
con=int(input())

f=0

if con==1:
    a=int(input())
    l2=[[a,a,a]]
elif con==2:
    list1=[int(input())for n in range(0,con)]
    l2=list[list[itertools.combinations_with_replacement(list1, 3)]]
else:
    list1=[int(input())for n in range(0,con)]
    list1=list(sorted(list1))
    l2=[[a,b,c] for a,b,c in list(list(itertools.combinations(list1,3)))]


for sw in b_st:
    for lw2 in l2:
        
        
        if sw==lw2:
            print("Yes")
            f=1
            break
    if f==1:
        break
if f==0:
    print("No")

Solution (Python):




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

n = int(input())


wl = [[0] * 3 for i in range(3)]
ans = "No"


for x in range(n):
    b = int(input())
    for y in range(3):
        for z in range(3):
            if al[y][z] == b:
                wl[y][z] = 1
                y = 3
                break


for y in range(3):
    cnt = 0
    for z in range(3):
        cnt = cnt + wl[y][z]
    if cnt >= 3:
        ans = "Yes"
        break


for y in range(3):
    cnt = 0
    for z in range(3):
        cnt = cnt + wl[z][y]
    if cnt >= 3:
        ans = "Yes"
        break


bs = wl[0][0] + wl[1][1] + wl[2][2]
sl = wl[2][0] + wl[1][1] + wl[0][2]

if bs >= 3 or sl >= 3:
    ans = "Yes"


print(ans)

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

Solution (Python):
from sys import stdin
def main():
    readline=stdin.readline
    bingo=[]
    for _ in range(3):
        A=list(map(int,readline().split()))
        bingo.append(A)
    N=int(readline())
    b=[0]*N
    c=[[False]*3 for _ in range(3)]
    for i in range(N):
        b[i]=int(readline())
        for j in range(3):
            for k in range(3):
                if bingo[j][k]==b[i]:
                    c[j][k]=True

    
    flag=False
    for j in range(3):
        if c[0][j] and c[1][j] and c[2][j]:
            flag=True

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

    if c[0][2] and c[1][1] and c[2][0]:
        flag=True

    if flag:
        print("Yes")
    else:
        print("No")
if __name__=="__main__":
    main()

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 b:
  for j in range(3):
    for k in range(3):
      if i==a[j][k]:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]:ans="Yes"
if a[0][2]==a[1][1]==a[2][0]:ans="Yes"
print(ans)

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

for i in l:
    for p in range(3):
        for q in range(3):
            if bingo[p][q] == i:
                bingo[p][q] = -1

flag = False

for i in range(3):
    t = True
    for j in range(3):
        t &= bingo[i][j] == -1
    flag |= t

for i in range(3):
    t = True
    for j in range(3):
        t &= bingo[j][i] == -1
    flag |= t

flag |= bingo[0][0]==-1 and bingo[1][1]==-1 and bingo[2][2]==-1
flag |= bingo[0][2]==-1 and bingo[1][1]==-1 and bingo[2][0]==-1

if flag:
    print('Yes')
else:
    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 a in A:
        if b in a:
            a[a.index(b)] = 0

if (any(A[0]) and any(A[1]) and any(A[2])
        and any((A[0][0], A[1][0], A[2][0]))
        and any((A[0][1], A[1][1], A[2][1]))
        and any((A[0][2], A[1][2], A[2][2]))
        and any((A[0][0], A[1][1], A[2][2]))
        and any((A[0][2], A[1][1], A[0][2]))):
    print("No")
else:
    print("Yes")

Solution (Python):
row1 = input().split()
row2 = input().split()
row3 = input().split()

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

rows = [row1, row2, row3]

for i in range(0, 3):
    rows += [[row1[i], row2[i], row3[i]]]

rows += [[row1[0], row2[1], row3[2]]]
rows += [[row1[2], row2[1], row3[0]]]

for row in rows:
    j = 0
    for num in nums:
        if num in row:
            j += 1
        if j == 3:
            print('Yes')
            exit()

print('No')