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-----
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

Solutions:
a = list(list(map(int,input().split())) for _ in range(3))
n = int(input())
b = list(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

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

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


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

# bingo = [[0] * 3 for i in range(3)]
# bingo[0][0] = 1
# print(bingo)

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

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

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


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



A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [0 for i in range(8)]
for i in range(N):
    b = int(input())
    if b == A[0][0] or b == A[1][0] or b == A[2][0]:
        B[0] += 1
    if b == A[0][1] or b == A[1][1] or b == A[2][1]:
        B[1] += 1
    if b == A[0][2] or b == A[1][2] or b == A[2][2]:
        B[2] += 1
    if b == A[0][0] or b == A[0][1] or b == A[0][2]:
        B[3] += 1
    if b == A[1][0] or b == A[1][1] or b == A[1][2]:
        B[4] += 1
    if b == A[2][0] or b == A[2][1] or b == A[2][2]:
        B[5] += 1
    if b == A[0][0] or b == A[1][1] or b == A[2][2]:
        B[6] += 1
    if b == A[0][2] or b == A[1][1] or b == A[2][0]:
        B[7] += 1
if 3 in B:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

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

bingo = []
for i in range(3):
    x = a[i]
    for j in range(3):
        bingo.append(x[j])

for i in b:
    for j in range(0,9):
        if i == bingo[j]:
            bingo[j] = 0

if bingo[0]==0 and bingo[1]==0 and bingo[2]==0:
    print("Yes")
elif bingo[3]==0 and bingo[4]==0 and bingo[5]==0:
    print("Yes")
elif bingo[6]==0 and bingo[7]==0 and bingo[8]==0:
    print("Yes")
elif bingo[0]==0 and bingo[3]==0 and bingo[6]==0:
    print("Yes")
elif bingo[1]==0 and bingo[4]==0 and bingo[7]==0:
    print("Yes")
elif bingo[2]==0 and bingo[5]==0 and bingo[8]==0:
    print("Yes")
elif bingo[0]==0 and bingo[4]==0 and bingo[8]==0:
    print("Yes")
elif bingo[2]==0 and bingo[4]==0 and bingo[6]==0:
    print("Yes")
else:
    print("No")

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

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

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

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

a=[input().split()for _ in range(3)]
n=int(input())
b= [input() for _ in range(n)]
a1=[]
for i in range(3):
    a1.append(a[0][i])
for i in range(3):
    a1.append(a[1][i])
for i in range(3):
    a1.append(a[2][i])
for i in range(n):
    if b[i] in a1:
        w=a1.index(b[i])
        a1[w]="a"
    else:
        pass

if a1[0]==a1[1]==a1[2]=="a" or a1[3]==a1[4]==a1[5]=="a" or a1[6]==a1[7]==a1[8]=="a":
    print("Yes")
else:
    if a1[0]==a1[3]==a1[6]=="a" or a1[1]==a1[4]==a1[7]=="a" or a1[2]==a1[5]==a1[8]=="a":
        print("Yes")
    else:
        if a1[0]==a1[4]==a1[8]=="a" or a1[2]==a1[4]==a1[6]=="a":
            print("Yes")
        else:
            print("No")

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 b[i] == a[j][k]:
        a[j][k] = 0

def bingo(board):
  if board[0][0] == board[0][1] == board[0][2]:
    return True
  if board[1][0] == board[1][1] == board[1][2]:
    return True
  if board[2][0] == board[2][1] == board[2][2]:
    return True
  if board[0][0] == board[1][0] == board[2][0]:
    return True
  if board[0][1] == board[1][1] == board[2][1]:
    return True
  if board[0][2] == board[1][2] == board[2][2]:
    return True
  if board[0][0] == board[1][1] == board[2][2]:
    return True
  if board[0][2] == board[1][1] == board[0][2]:
    return True
  return False

if bingo(a):
  print("Yes")
else:
  print("No")

l=[]
A,B,C=map(int,input().split());l.append(A);l.append(B);l.append(C)
D,E,F=map(int,input().split());l.append(D);l.append(E);l.append(F)
G,H,I=map(int,input().split());l.append(G);l.append(H);l.append(I)
N= int(input())
b={0}

for i in range(N):
  c=int(input())
  if c in l:b.add(c)
b.discard(0)


for i in b:
  l[l.index(i)]=0

if l[0]+l[1]+l[2]==0 or l[3]+l[4]+l[5]==0 or l[6]+l[7]+l[8]==0:print('Yes');return
if l[0]+l[3]+l[6]==0 or l[1]+l[4]+l[7]==0 or l[2]+l[5]+l[8]==0:print('Yes');return
if l[0]+l[4]+l[8]==0 or l[2]+l[4]+l[6]==0:print('Yes');return
print('No')

#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

def __starting_point():
    main()

__starting_point()

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 b:
    for j in range(0,3):
        for k in range(0,3):
            if i == a[j][k]:
                a[j][k] = 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")

a=[[x for x in map(int,input().split())] for _ in range(3)]
n=int(input())
bingo=[[0]*3 for _ in range(3)]
for k in range(n):
  x=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==x:
        bingo[i][j]=1
for i in range(3):
  if bingo[i]==[1,1,1]:
    print('Yes')
    return
  if [row[i] for row in bingo]==[1,1,1]:
    print('Yes')
    return
if [bingo[i][i] for i in range(3)]==[1,1,1]:
  print('Yes')
  return
if [bingo[i][2-i] for i in range(3)]==[1,1,1]:
  print('Yes')
  return
print('No')

def main():
    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(N):
        for j in range(3):
            for h in range(3):
                if A[j][h] == b[i]:
                    A[j][h] = 0

    if A[0][0]==0 and A[0][1]==0 and A[0][2]==0:
        return 'Yes'
    elif A[1][0]==0 and A[1][1]==0 and A[1][2]==0:
        return 'Yes'
    elif A[2][0]==0 and A[2][1]==0 and A[2][2]==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'
    elif 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'

    return ('No')

print((main()))


def ck_bingo(lis):
  flg=False
  for i in range(0,3):
    if lis[i][0]+lis[i][1]+lis[i][2]==3:
      flg=True
      break
    
  for j in range(0,3):
    if lis[0][j]+lis[1][j]+lis[2][j]==3:
      flg=True
      break

  if lis[0][0]+lis[1][1]+lis[2][2]==3 \
  or lis[0][2]+lis[1][1]+lis[2][0]==3:
    flg=True
  
  return flg


Bingo=[[0] for _ in range(3)]
for b in range(3):
  Bingo[b]=list(map(int,input().split()))

N=int(input())
A=[[0,0,0] for _ in range(3)]
Ans='No'

for i in range(N):
  ball=int(input())
  for j in range(3):
    for k in range(3):
      if ball==Bingo[j][k]:
        A[j][k]=1
        if ck_bingo(A):
          Ans='Yes'
          #break
    
print(Ans)


def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


def LIH(h):
    return [int(input()) for _ in range(h)]


card = LIHW(3)
N = int(input())
num = LIH(N)
bingo = [[0, 0, 0] for _ in range(3)]
for i in num:
    for a in range(3):
        for b in range(3):
            if i == card[a][b]:
                bingo[a][b] = 1
                break
ans = "No"
for i in range(3):
    if bingo[i][0] == 1 and bingo[i][1] == 1 and bingo[i][2] == 1:
        ans = "Yes"
for i in range(3):
    if bingo[0][i] == 1 and bingo[1][i] == 1 and bingo[2][i] == 1:
        ans = "Yes"
if bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
    ans = "Yes"
if bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
    ans = "Yes"
print(ans)


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

Alist = []
Alist.append(A11)
Alist.append(A12)
Alist.append(A13)
Alist.append(A21)
Alist.append(A22)
Alist.append(A23)
Alist.append(A31)
Alist.append(A32)
Alist.append(A33)
bingolist =[0]*9

N = int(input())
#print (N)
for i in range(N):
  b = int(input())
  #print (b)
  for j in range(len(bingolist)):
    if b ==Alist[j]:
      bingolist[j] = 1

if sum(bingolist[0:3])==3 or sum(bingolist[3:6])==3 or sum(bingolist[6:9])==3 or (bingolist[0]+bingolist[3]+bingolist[6])==3 or (bingolist[1]+bingolist[4]+bingolist[7])==3 or (bingolist[2]+bingolist[5]+bingolist[8])==3 or (bingolist[0]+bingolist[4]+bingolist[8])==3 or (bingolist[2]+bingolist[4]+bingolist[6])==3:
  print ("Yes")
else :
  print ("No")
#print (bingolist[0:3])
#print (bingolist[3:6])
#print (bingolist[6:9])
#print (bingolist)


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

for i in range(N):
  for j in range(3):
    for k in range(3):
      if B[i] == A[j][k]:
        sheet[j][k] = 1
if sheet[0][0] == 1 and sheet[0][1] == 1 and sheet[0][2] == 1:
  print('Yes')
elif sheet[1][0] == 1 and sheet[1][1] == 1 and sheet[1][2] == 1:
  print('Yes')
elif sheet[2][0] == 1 and sheet[2][1] == 1 and sheet[2][2] == 1:
  print('Yes')
elif sheet[0][0] == 1 and sheet[1][0] == 1 and sheet[2][0] == 1:
  print('Yes')
elif sheet[0][1] == 1 and sheet[1][1] == 1 and sheet[2][1] == 1:
  print('Yes')
elif sheet[0][2] == 1 and sheet[1][2] == 1 and sheet[2][2] == 1:
  print('Yes')
elif sheet[0][0] == 1 and sheet[1][1] == 1 and sheet[2][2] == 1:
  print('Yes')
elif sheet[2][0] == 1 and sheet[1][1] == 1 and sheet[0][2] == 1:
  print('Yes')
else:
  print('No')

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


class Info:
    def __init__(self, a_3_3, n, b_n):
        self.a_3_3 = a_3_3
        self.n = n
        self.b_n = b_n

    @staticmethod
    def setting():
        for num in b_n:
            for line in a_3_3:
                if num in line:
                    line[line.index(num)] = 0
        return a_3_3

    @staticmethod
    def result():
        diagonal_lurd = a_3_3[0][0] + a_3_3[1][1] + a_3_3[2][2]
        diagonal_ldru = a_3_3[2][0] + a_3_3[1][1] + a_3_3[0][2]

        for index, line in enumerate(a_3_3):
            row_sum = sum(line)
            col_sum = a_3_3[0][index] + a_3_3[1][index] + a_3_3[2][index]
            if diagonal_lurd == 0 or diagonal_ldru == 0 or row_sum == 0 or col_sum == 0:
                print('Yes')
                return

        print('No')


info = Info(a_3_3, n, b_n)
info.setting()
info.result()


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

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

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

A_11,A_12,A_13=list(map(int,input().split()))
A_21,A_22,A_23=list(map(int,input().split()))
A_31,A_32,A_33=list(map(int,input().split()))
N=int(input())
Li=[A_11,A_12,A_13,A_21,A_22,A_23,A_31,A_32,A_33]
for i in range(N):
  b=int(input())
  if b in Li:
    Num=Li.index(b)
    Li[Num]=0

if Li[0]==Li[1]==Li[2]==0 or Li[3]==Li[4]==Li[5]==0 or Li[6]==Li[7]==Li[8]:
  print("Yes")
elif Li[0]==Li[3]==Li[6]==0 or Li[1]==Li[4]==Li[7]==0 or Li[2]==Li[5]==Li[8]:
  print("Yes")
elif Li[0]==Li[4]==Li[8]==0 or Li[2]==Li[4]==Li[6]==0:
  print("Yes")
else:
  print("No")


A = [list(map(int, input().split())) for _ in range(3)]
for j in range(3): A.append([A[i][j] for i in range(3)])
A.append([A[0][0], A[1][1], A[2][2]])
A.append([A[2][0], A[1][1], A[0][2]])
d = {int(input()): 0 for _ in range(int(input()))}
print("YNeos"[all(any(d.get(v, 1) for v in r) for r in A)::2])

def main():
    card = [[int(j) for j in input().split()] for i in range(3)]
    n = int(input())
    def punch(v):
        for i in range(len(card)):
            for j in range(len(card[i])):
                if card[i][j] == v:
                    card[i][j] = True
        return card

    def check(board):
        for i in range(len(board)):
            l = list(set(board[i]))
            if len(l)==1 and l[0] ==True:
                return True
        for i in range(len(board[0])):
            if board[0][i] == board[1][i]==board[2][i] == True:
                return True
        if board[0][0] == board[1][1]==board[2][2] == True:
            return True
        if board[0][2] == board[1][1]==board[2][0] == True:
            return True

    for _ in range(n):
        num = int(input())
        if check(punch(num)):
            return "Yes"
    return "No"


    print(card)

def __starting_point():
    print(main())
__starting_point()

import numpy as np

CARD_SIZE = 3


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

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

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

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

    return False


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

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

    ret = solve(card, called_numbers)

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


def __starting_point():
    resolve()
__starting_point()

A = [[int(i) for i in input().split()] for j in range(3)]
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] = 0
for i in range(3):
    if(A[i][0] == A[i][1] and A[i][1] == A[i][2]):
        print("Yes")
        return
    if(A[0][i] == A[1][i] and A[1][i] == A[2][i]):
        print("Yes")
        return
if(A[0][0] == A[1][1] and A[1][1] == A[2][2]):
    print("Yes")
    return
if(A[0][2] == A[1][1] and A[1][1] == A[2][0]):
    print("Yes")
    return
print("No")

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 b:
    for j in range(0,3):
        for k in range(0,3):
            if i == a[j][k]:
                a[j][k] = 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")

from typing import List


def answer(a: List[List[int]], n: int, b: List[int]) -> str:
    bingo_card = list([i[j] in b for i in a] for j in range(3))
    for i in range(2):
        for j in bingo_card:
            if all(j):
                return 'Yes'
        if i == 0:
            bingo_card = list(zip(*bingo_card))

    if bingo_card[0][0] and bingo_card[1][1] and bingo_card[2][2]:
        return 'Yes'
    if bingo_card[0][2] and bingo_card[1][1] and bingo_card[2][0]:
        return 'Yes'

    return 'No'


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


def __starting_point():
    main()
__starting_point()

def check(arr):
    # 横チェック
    for i in range(len(arr)):
        if arr[i] == ["x", "x", "x"]:
            return True

    # 縦チェック
    for i in range(3):
        if arr[0][i] == "x" and arr[1][i] == "x" and arr[2][i] == "x":
            return True

    # 斜めチェック
    if arr[0][0] == "x" and arr[1][1] == "x" and arr[2][2] == "x":
        return True
    elif arr[0][2] == "x" and arr[1][1] == "x" and arr[2][0] == "x":
        return True

    return False

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

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

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


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

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

# Check bingo or not
flag = 0
# Check rows
for i in [0, 3, 6]:
  if A[i]==A[i+1] and A[i+1]==A[i+2]:
    flag += 1
# Check colums
for j in range(3):
  if A[j]==A[j+3] and A[j+3]==A[j+6]:
    flag += 1
# Check naname?
if (A[0]==A[4] and A[4]==A[8]) or (A[2]==A[4] and A[4]==A[6]):
  flag += 1

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

A = {}
for i in range(3) :
    a1,a2,a3 = map(int, input().split())
    A[a1] = (i,0)
    A[a2] = (i,1)
    A[a3] = (i,2)

N = int(input())
A2 = [[False,False,False] for i in range(3)]

for i in range(N):
    b = int(input())
    if(b not in A) :
        continue
    r,c = map(int,A[b])
    A2[r][c] = True

def isBingo(table) :
    for r in range(3) :
        if(table[r][0] and table[r][1] and table[r][2]) :
            return True
    for c in range(3) :
        if(table[0][c] and table[1][c] and table[2][c]) :
            return True
    if(table[0][0] and table[1][1] and table[2][2]) :
        return True
    if(table[0][2] and table[1][1] and table[2][0]) :
        return True
    return False

if(isBingo(A2)) :
    print("Yes")
else :
    print("No")

A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
c = [[0]*3 for _ in range(3)]
for x in b:
  for i in range(3):
    for j in range(3):
      if A[i][j] == x:
        c[i][j] = 1

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

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]=-1
if A[0][0]==-1 and A[1][1]==-1 and A[2][2]==-1:
    print("Yes")
    return
elif A[0][2]==-1 and A[1][1]==-1 and A[2][0]==-1:
    print("Yes")
    return
for i in range(3):
    total=0
    if A[i].count(-1)==3:
        print("Yes")
        return
    for j in range(3):
        if A[j][i]==-1:
            total+=1
    if total==3:
        print("Yes")
        return
print("No")

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

for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0
    row0 = a[0] == [0, 0, 0]
    row1 = a[1] == [0, 0, 0]
    row2 = a[2] == [0, 0, 0]
    colum0 = [a[0][0], a[1][0], a[2][0]] == [0, 0, 0]
    colum1 = [a[0][1], a[1][1], a[2][1]] == [0, 0, 0]
    colum2 = [a[0][2], a[1][2], a[2][2]] == [0, 0, 0]
    diag0 = [a[0][0], a[1][1], a[2][2]] == [0, 0, 0]
    diag1 = [a[2][0], a[1][1], a[0][2]] == [0, 0, 0]
    if row0 or row1 or row2 or colum0 or colum1 or colum2 or diag0 or diag1:
        print('Yes')
        break
else:
    print('No')

def main():
  A = []
  C = [False] * 9
  for i in range(3):
    a0, a1, a2 = map(int, input().split())
    A.append(a0)
    A.append(a1)
    A.append(a2)
    
  N = int(input())
  for i in range(N):
    b = int(input())
    if b in A:
      C[A.index(b)] = True

  for i in range(3):
    if C[0+3*i] and C[1+3*i] and C[2+3*i]:
      print("Yes")
      return

  for i in range(3):
    if C[i] and C[i+3] and C[i+6]:
      print("Yes")
      return

  if C[0] and C[4] and C[8]:
    print("Yes")
    return

  if C[2] and C[4] and C[6]:
    print("Yes")
    return

  print("No")

    
main()

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):
    if a[i][j] not in b:
      break
    elif j == 2:
      print("Yes")
      return
#列の判定
for i in range(3):
  for j in range(3):
    if a[j][i] not in b:
      break
    elif j == 2:
      print("Yes")
      return
#ななめの判定
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
  print("Yes")
  return
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
  print("Yes")
  return
print("No")

l = [list(map(int, input().split())) for i in range(3)]
n = int(input())
s = set([int(input()) for j in range(n)])

ans = "No"

for i in range(3):
    if l[i][0] in s and l[i][1] in s and l[i][2] in s:
        ans = "Yes"

for i in range(3):
    if l[0][i] in s and l[1][i] in s and l[2][i] in s:
        ans = "Yes"

if l[0][0] in s and l[1][1] in s and l[2][2] in s:
    ans = "Yes"
elif l[0][2] in s and l[1][1] in s and l[2][0] in s:
    ans = "Yes"

print(ans)

import math
def i_input(): return int(input())


def i_map(): return map(int, input().split())


def i_list(): return list(map(int, input().split()))


def i_row(N): return [int(input()) for _ in range(N)]


def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]

aaa= i_row_list(3)
n=i_input()
b=i_row(n)
ans='No'
for i in range(3):
    for j in range(3):
        if aaa[i][j] in b:
            aaa[i][j]=0
xlos1=0
xlos2=0
for i in range(3):
    colm=0
    rows=0

    for j in range(3):
        colm+=aaa[i][j]
        rows+=aaa[j][i]
    xlos1+=aaa[i][i]
    xlos2+=aaa[2-i][i]
    if colm==0 or rows==0:
        ans='Yes'
        break
if ans!='Yes':
    if xlos1==0 or xlos2==0:
        ans='Yes'


print(ans)

def Judge(a):
  col=[]
  diag1=0
  diag2=0

  for i in range(3):
    if(a[i].count(0)==3):
      return 1
      break
    if(a[i][0]==0):
      col.append(0)
    if(a[i][1]==0):
      col.append(1)
    if(a[i][2]==0):
      col.append(2)
    if(a[i][i]==0):
      diag1+=1
    if(a[i][-(i+1)]==0):
      diag2+=1
  if(diag1==3 or diag2==3):
    return 1
  if(col.count(0)==3 or col.count(1)==3 or col.count(2)==3):
    return 1
  return 0


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(b==a[j][k]):
        a[j][k]=0
judge=Judge(a)
if(judge==1):
  print("Yes")
else:
  print("No")

A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
cdl = 0
cdr = 0
for i in range(3):
    cr = 0
    cc = 0
    for j in range(3):
        if A[i][j] in b:
            cr += 1
        if A[j][i] in b:
            cc += 1
        if i == j and A[i][j] in b:
            cdl += 1
        if i+j==2 and A[i][j] in b:
            cdr += 1

    if cr == 3 or cc == 3 or cdl == 3 or cdr ==3:
        print('Yes')
        return
print('No')

def resolve():
	a = []
	bingo = [(0,3,6),(1,4,7),(2,5,8),(0,1,2),(3,4,5)
			 ,(6,7,8),(0,4,8),(2,4,6)]
	for _ in range(3):
		a += list(map(int,input().split()))
	for i in range(int(input())):
		r = int(input())
		if r in a:
			a[a.index(r)]=0
	ans = 'No'
	for i in bingo:
		if a[i[0]] == 0 and a[i[1]]==0 and a[i[2]]==0:
			ans ='Yes'
	print(ans)
resolve()

# coding=utf-8
import sys

def __starting_point():
    bingo = [[0] * 3 for i in range(3)]

    ans = [[0] * 3 for i in range(3)]
    for i in range(3):
        temp = list(map(int, input().split()))
        for j in range(3):
            bingo[i][j] = temp[j]

    N = int(input())

    for i in range(N):
        b = int(input())
        for j in range(3):
            for k in range(3):
                if bingo[j][k] == b:
                    ans[j][k] = 1

    #print(bingo, ans)


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

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

    #naname
    if (ans[0][0] + ans[1][1] + ans[2][2]) == 3:
        print("Yes")
        return

    if (ans[0][2] + ans[1][1] + ans[2][0]) == 3:
        print("Yes")
        return

    print('No')

__starting_point()

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

def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    if a[0][0] in b and a[0][1] in b and a[0][2] in b or \
        a[1][0] in b and a[1][1] in b and a[1][2] in b or \
            a[2][0] in b and a[2][1] in b and a[2][2] in b or \
                a[0][0] in b and a[1][0] in b and a[2][0] in b or \
                    a[0][1] in b and a[1][1] in b and a[2][1] in b or \
                        a[0][2] in b and a[1][2] in b and a[2][2] in b or \
                            a[0][0] in b and a[1][1] in b and a[2][2] in b or \
                                a[0][2] in b and a[1][1] in b and a[2][0] in b:
                                    print('Yes')
    else:
        print('No')
        
def __starting_point():
    main()
__starting_point()

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

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

arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
arr3 = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    x = int(input())
    if x in arr1:
        arr1[arr1.index(x)] -= x
    elif x in arr2:
        arr2[arr2.index(x)] -= x
    elif x in arr3:
        arr3[arr3.index(x)] -= x
    if _ >= 3:
        if arr1[0] == arr1[1] and arr1[1] == arr1[2]:
            print("Yes")
            return
        if arr2[0] == arr2[1] and arr2[1] == arr2[2]:
            print("Yes")
            return
        if arr3[0] == arr3[1] and arr3[1] == arr3[2]:
            print("Yes")
            return
        for jj in range(3):
            if arr1[jj] == arr2[jj] and arr2[jj] == arr3[jj]:
                print("Yes")
                return
        if arr1[0] == arr2[1] and arr2[1] == arr3[2]:
            print("Yes")
            return
        if arr1[2] == arr2[1] and arr2[1] == arr3[0]:
            print("Yes")
            return
print("No")

a = input()
a = a.split()
b = input()
b = b.split()
c = input()
c = c.split()
d = [a[0],b[0],c[0]]
e = [a[1],b[1],c[1]]
f = [a[2],b[2],c[2]]
g = [a[0],b[1],c[2]]
h = [a[2],b[1],c[0]]
n = int(input())
for i in range(n):
    j = int(input())
    for k in range(3):
        if int(a[k])==j:
            a.pop(k)
            a.insert(k,0)
        if int(b[k])==j:
            b.pop(k)
            b.insert(k,0)
        if int(c[k])==j:
            c.pop(k)
            c.insert(k,0)
        if int(d[k])==j:
            d.pop(k)
            d.insert(k,0)
        if int(e[k])==j:
            e.pop(k)
            e.insert(k,0)
        if int(f[k])==j:
            f.pop(k)
            f.insert(k,0)
        if int(g[k])==j:
            g.pop(k)
            g.insert(k,0)
        if int(h[k])==j:
            h.pop(k)
            h.insert(k,0)
if a == [0,0,0] or b == [0,0,0] or c == [0,0,0] or d == [0,0,0] or e == [0,0,0] or f == [0,0,0] or g == [0,0,0] or h == [0,0,0]:
    print("Yes")
else:
    print("No")

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):
        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,0,0]:
        ans = "Yes"
        break
    for j in range(3):
        if A[j][i] != 0:
            break
    else:
        ans = "Yes"
        break
for i in range(3):
    if A[i][i] != 0:
        break
else:
    ans = "Yes"
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    ans = "Yes"
print(ans)

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

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

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

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

import numpy as np

arr = np.array([list(map(int, input().split())) for _ in range(3)])


n = int(input())

for _ in range(n):
    b = int(input())
    arr[np.where(arr == b)] = 0

ans1 = (np.sum(arr, axis=0) == 0).sum() >= 1
ans2 = (np.sum(arr, axis=1) == 0).sum() >= 1
ans3 = (np.diag(arr) == 0).sum() == 3
ans4 = (np.diag(np.rot90(arr)) == 0).sum() == 3

print("Yes" if ans1 or ans2 or ans3 or ans4 else "No")

A11,A12,A13 = list(map(int,input().split()))
A21,A22,A23 = list(map(int,input().split()))
A31,A32,A33 = list(map(int,input().split()))
A = [[A11,A12,A13],[A21,A22,A23],[A31,A32,A33]]

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] = 'YES'


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

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

    else:
        print('No')




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

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

bingo = []
kiroku = [[0,0,0] for i in range(3)]
for i in range(3):
    a,b,c = map(int,input().split())
    bingo.append([a,b,c])

n =  int(input())
for j in range(n):
    num = int(input())
    for k in range(3):
        for l in range(3):
            if bingo[k][l] == num:
                kiroku[k][l] = 1
ans = 0

for i in range(3):
    if (kiroku[i][0] == kiroku[i][1] == kiroku[i][2] == 1) or (kiroku[0][i] == kiroku[1][i] == kiroku[2][i] == 1):
        ans = 1
        break
if (kiroku[0][0] == kiroku[1][1] == kiroku[2][2] == 1) or (kiroku[0][2] == kiroku[1][1] == kiroku[2][0] == 1):
    ans = 1


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

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



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


import sys

input = sys.stdin.readline

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

N = int(input())
nums = []
for _ in range(N):
    nums.append(int(input()))

for num in nums:
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                bingo[i][j] = -1

for i in range(3):
    if sum(bingo[i]) == -3:
        print("Yes")
        return
    tmp = 0
    for j in range(3):
        tmp += bingo[j][i]
    if tmp == -3:
        print("Yes")
        return
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
    print("Yes")
    return
if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[0][2] == -1:
    print("Yes")
    return

print("No")

A11,A12,A13 = map(int,input().split())
A21,A22,A23 = map(int,input().split())
A31,A32,A33 = map(int,input().split())
A =[[A11,A12,A13],[A21,A22,A23],[A31,A32,A33]]
N =int(input())
b = []
for x in range(N):
    b.append(int(input()))
    for i in range(3):
        for j in range(3):
            A[i][j] = 'YES' if b[x] == A[i][j] else A[i][j]
if A[0][0]==A[0][1]==A[0][2]=='YES' or A[1][0]==A[1][1]==A[1][2]=='YES' or A[2][0]==A[2][1]==A[2][2]=='YES' or \
A[0][0]==A[1][0]==A[2][0]=='YES' or A[0][1]==A[1][1]==A[2][1]=='YES' or A[0][2]==A[1][2]==A[2][2]=='YES' or \
A[0][0]==A[1][1]==A[2][2]=='YES' or A[0][2]==A[1][1]==A[2][0]=='YES' :
    print('Yes')
else :
    print('No')

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

for b in B:
    tmp=[i for i,x in enumerate(A) if x==b]
    for t in tmp:
        table[t//3][t%3]=1

flag=False
n1,n2=0,0
for i in range(3):
    if sum(table[i])==3: flag=True
    if sum([table[j][i] for j in range(3)])==3: flag=True
    n1+=table[i][i]
    n2+=table[i][2-i]
if n1==3 or n2==3: flag=True
if flag: print('Yes')
else: print('No')


a,b,c = list(map(int,input().split()))
d,e,f = list(map(int,input().split()))
g,h,i = list(map(int,input().split()))

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

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

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

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

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

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

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

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

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

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

else:

    print("No")


import numpy as np

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

N=int(input())

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

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

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

cnt=[]
pattern=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

for i in range(n):
    b.append(int(input()))
    for j , x in enumerate(a):
        if x == b[i]:
            cnt.append(j)

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

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

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

N = int(input())

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if rows[i][j] == b:
                rows[i][j] = 0

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

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


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

called = [False] * 9

bingo = ((0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6))

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


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

N=int(input())

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

list2=[]
i=0
while i<=2:
    j=0
    while j<=2:
        list2.append(num_list[i][j])
        j=j+1
    i=i+1

s=0
for k in list2:
    if list1.count(k)==1:
        list2[s]=101
        s=s+1
    else:
        s=s+1
        continue

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


def bingo(board):
    if board[0][0] == board[0][1] == board[0][2]:
        return True
    if board[1][0] == board[1][1] == board[1][2]:
        return True
    if board[2][0] == board[2][1] == board[2][2]:
        return True
    if board[0][0] == board[1][0] == board[2][0]:
        return True
    if board[0][1] == board[1][1] == board[2][1]:
        return True
    if board[0][2] == board[1][2] == board[2][2]:
        return True
    if board[0][0] == board[1][1] == board[2][2]:
        return True
    if board[0][2] == board[1][1] == board[0][2]:
        return True


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

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

ans = bingo(A)
if ans:
    print('Yes')
else:
    print('No')


a=[[*map(int,input().split())] for _ in range(3)]
b=[int(input()) for _ in range(int(input()))]
for i in b:
  for j in range(3):
    if i in a[j]:
      a[j][a[j].index(i)]=-1
if a[0][0]+a[1][1]+a[2][2]==-3 or a[0][2]+a[1][1]+a[2][0]==-3:
  print('Yes')
else:
  for i,j in zip(a,[*zip(*a)]):
    if sum(i)==-3 or sum(j)==-3:
      print('Yes');break
  else:
    print('No')

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

li = list(map(int,input().split()))
li1 = list(map(int,input().split()))
li2 = list(map(int,input().split()))

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

for i in range(3):
    if li[i] in li3:
        li[i] = 0
    if li1[i] in li3:
        li1[i] = 0
    if li2[i] in li3:
        li2[i] = 0
su = li[0] + li1[0] + li2[0]
su1 = li[1] + li1[1] + li2[1]
su2 = li[2] + li1[2] + li2[2]
su3 = li[0] + li1[1] + li2[2]
su4 = li[2] + li1[1] + li2[0]
if sum(li)==0 or sum(li1)==0 or sum(li2)==0:
    print('Yes')
elif su == 0 or su1 == 0 or su2 == 0:
    print('Yes')
elif su3 == 0 or su4 == 0:
    print('Yes')
else:
    print('No')

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

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

A = [[],[],[]]
A[0] = [int(s) for s in input().split(' ')]
A[1] = [int(s) for s in input().split(' ')]
A[2] = [int(s) for s in input().split(' ')]
N = int(input())
B = []
for n in range(N):
    b = int(input())
    B.append(b)
B = set(B)
lines = []
lines.append(set(A[0]))
lines.append(set(A[1]))
lines.append(set(A[2]))
lines.append(set(A[i][i] for i in range(3)))
lines.append(set(A[2 - i][i] for i in range(3)))
lines.append(set(A[i][0] for i in range(3)))
lines.append(set(A[i][1] for i in range(3)))
lines.append(set(A[i][2] for i in range(3)))
for line in lines:
    if len(line & B) == 3:
        print('Yes')
        return
print('No')


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

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

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

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

    print(ans)


def __starting_point():
    main()

__starting_point()

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

ans = [[0] * 3 for _ 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:
                ans[j][k] = 1

state = False
for i in range(3):
    num = 0
    for j in range(3):
        num += ans[i][j]
    
    if num == 3:
        state = True

for i in range(3):
    num = 0
    for j in range(3):
        num += ans[j][i]
    
    if num == 3:
        state = True

if ans[0][0] + ans[1][1] + ans[2][2] == 3:
    state = True

if ans[0][2] + ans[1][1] + ans[2][0] == 3:
    state = True

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



#!/usr/local/bin/python3
# https://atcoder.jp/contests/abc157/tasks/abc157_b
import numpy as np

def check(A, b):
    A = np.where(A == b, -1, A)
    return A

def bingo(A):
    for a in A:
        if a[0] == a[1] == a[2] == -1:
            return True
    for a in A.T:
        if a[0] == a[1] == a[2] == -1:
            return True
    if A[0][0] == A[1][1] == A[2][2] == -1:
        return True
    if A[0][2] == A[1][1] == A[2][0] == -1:
        return True
    return False



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

# for i in range(3):
#     for j in range(3):
#         print(f"{A[i][j]} ", end="")
#     print("")

if bingo(A):
    print("Yes")
else:
    print("No")


#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

def __starting_point():
    main()

__starting_point()

A = [[]]*3
for row in range(3):
    A[row] = list(map(int, input().split()))
n = int(input())
B = [0]*n
for i in range(n):
    B[i] = int(input())
flag = False


def check_bingo(A, B):
    for row in range(3):
        if A[row][0] and A[row][1] and A[row][2]:
            return True

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

    if A[0][0] and A[1][1] and A[2][2]:
        return True
    if A[0][2] and A[1][1] and A[2][0]:
        return True
    return False


for row in range(3):
    for col in range(3):
        if A[row][col] in B:
            A[row][col] = True
        else:
            A[row][col] = False

print("Yes" if check_bingo(A, B) else "No")

a_str = [input().split() for _ in range(3)]
a = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        a[i][j] = int(a_str[i][j])

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

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

#横のビンゴ判定
for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 0:
        print('Yes')
        return

#縦のビンゴ判定
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == 0:
        print('Yes')
        return

#斜めのビンゴ判定
if a[0][0] == a[1][1] == a[2][2] == 0:
    print('Yes')
    return
if a[0][2] == a[1][1] == a[2][0] == 0:
    print('Yes')
    return

print('No')

import numpy as np

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]:
            idx = a[j].index(b)
            a[j][idx] = 0

np_a = np.array(a)
np_t = np_a.T
d = 0
u = 0

for i in range(3):
    r = np_a[i]
    c = np_t[i]
    d += r[i]
    u += r[2-i]

    if r.sum() and c.sum():
        continue

    print("Yes")
    return


if d and u:
    print("No")
else:
    print("Yes")


l=[]
for i in range(3):
    l += list(map(int,input().split()))
N= int(input())
b=set()
for i in range(N):
  c=int(input())
  if c in l:b.add(c)
for i in b:
  l[l.index(i)]=0
if l[0]+l[1]+l[2]==0 or l[3]+l[4]+l[5]==0 or l[6]+l[7]+l[8]==0:print('Yes');return
if l[0]+l[3]+l[6]==0 or l[1]+l[4]+l[7]==0 or l[2]+l[5]+l[8]==0:print('Yes');return
if l[0]+l[4]+l[8]==0 or l[2]+l[4]+l[6]==0:print('Yes');return
print('No')

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def bingo_check(card):
    #横チェック
    for low in card:
        if sum(low)==0:
            print("Yes")
            return
    #縦チェック
    column1=0
    column2=0
    column3=0
    for low in card:
        column1+=low[0]
        column2+=low[1]
        column3+=low[2]
    if column1 == 0 or column2 == 0 or column3==0:
        print("Yes")
        return
    #斜めチェック
    diagonal1=card[0][0]+card[1][1]+card[2][2]
    diagonal2=card[0][2]+card[1][1]+card[2][0]
    if diagonal1 == 0 or diagonal2 == 0:
        print("Yes")
        return
    print("No")

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

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

def __starting_point():
    main()
__starting_point()

a, b, c = list(map(int, input().split()))
e, f, g = list(map(int, input().split()))
h, i, j = list(map(int, input().split()))

bingo_list = [[a, b, c], [e, f, g], [h, i, j], [a, e, h], [b, f, i], [c, g, j], [a, f, j], [c, f, h]]

n = int(input())

n_list = [int(input()) for _ in range(n)]
count = 0
ans = 'No'

for i in bingo_list:
    for j in n_list:
        if j in i:
            count += 1
        if count == 3:
            ans = 'Yes'
            break
    if ans == 'Yes':
        break

    count = 0

print(ans)


a=[input().split() for _ in range(3)]
n=int(input())
b=[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]:
        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)

lst = [ [ int(i) for i in input().split() ] for j in range(3) ]

n = int(input())

for _ in range(n):
  x = int(input())
  for d in lst:
    if d[0] == x:
      d[0] = -1
    elif d[1] == x:
      d[1] = -1
    elif d[2] == x:
      d[2] = -1

for d in lst:
  if d[0] == d[1] == d[2] == -1:
    print('Yes')
    return
for i in range(3):
  if lst[0][i] == lst[1][i] == lst[2][i] == -1:
    print('Yes')
    return
for i in range(3):
  if lst[i][0] == lst[i][1] == lst[i][2] == -1:
    print('Yes')
    return
if lst[0][0] == lst[1][1] == lst[2][2] == -1:
  print('Yes')
  return
if lst[0][2] == lst[1][1] == lst[2][0] == -1:
  print('Yes')
  return
print('No')


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

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

# Check bingo or not
flag = 0
# Check rows
for i in [0, 3, 6]:
  if A[i]==A[i+1] and A[i+1]==A[i+2]:
    flag += 1
# Check colums
for j in range(3):
  if A[j]==A[j+3] and A[j+3]==A[j+6]:
    flag += 1
# Check naname?
if (A[0]==A[4] and A[4]==A[8]) or (A[2]==A[4] and A[4]==A[6]):
  flag += 1

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

ls = []
for i in range(3):
    ls += list(map(int,input().split()))
N = int(input())
lsb = [int(input()) for i in range(N)]
for i in range(N):
    if lsb[i] in ls:
        ls[ls.index(lsb[i])] = '#'
ans = 'No'
for i in range(3):  
    if ls[0+i] == '#' and ls[3+i] == '#' and ls[6+i] == '#':
        ans = 'Yes'
for i in range(3):  
    if ls[3*i] == '#' and ls[3*i+1] == '#' and ls[3*i+2] == '#':
        ans = 'Yes'
if ls[0] == '#' and ls[4] == '#' and ls[8] == '#':
        ans = 'Yes'
if ls[2] == '#' and ls[4] == '#' and ls[6] == '#':
        ans = 'Yes'
print(ans)

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

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

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

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

A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
sheet = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == A[j][k]:
                sheet[j][k] = 1
                break
            else:
                continue

for i in range(3):
    if sheet[0][i] == sheet[1][i] == sheet[2][i] == 1:
        print('Yes')
        return

for i in range(3):
    if sheet[i][0] == sheet[i][1] == sheet[i][2] == 1:
        print('Yes')
        return

if sheet[0][0] == sheet[1][1] == sheet[2][2] == 1:
        print('Yes')
        return
if sheet[0][2] == sheet[1][1] == sheet[2][0] == 1:
        print('Yes')
        return
else:
    print('No')

mat = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(3):
  x, y, z = map(int, input().split())
  mat[i][0] = x
  mat[i][1] = y
  mat[i][2] = z

n = int(input())

for i in range(n):
  x = int(input())
  for j in range(3):
    for k in range(3):
      if mat[j][k] == x:
        mat[j][k] = -1
        break

if mat[0][0] == -1 and mat[0][1] == -1 and mat[0][2] == -1:
  print("Yes")
  return
elif mat[1][0] == -1 and mat[1][1] == -1 and mat[1][2] == -1:
  print("Yes")
  return
elif mat[2][0] == -1 and mat[2][1] == -1 and mat[2][2] == -1:
  print("Yes")
  return
elif mat[0][0] == -1 and mat[1][0] == -1 and mat[2][0] == -1:
  print("Yes")
  return
elif mat[0][1] == -1 and mat[1][1] == -1 and mat[2][1] == -1:
  print("Yes")
  return
elif mat[0][2] == -1 and mat[1][2] == -1 and mat[2][2] == -1:
  print("Yes")
  return
elif mat[0][0] == -1 and mat[1][1] == -1 and mat[2][2] == -1:
  print("Yes")
  return
elif mat[2][0] == -1 and mat[1][1] == -1 and mat[0][2] == -1:
  print("Yes")
  return
else:
  print("No")

sheet = []
for i in range(3):
    sheet.append([int(x) for x in input().split()])
bingo = [[False] * 3 for _ in range(3)]

N = int(input())
for i in range(N):
    a = int(input())
    for x in range(3):
        for y in range(3):
            if sheet[x][y] == a:
                bingo[x][y] = True

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

print('No')


import numpy as np
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
a = [[False]*3 for _ 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[0][2] and a[1][1] and a[2][0]:
    bingo = True
print(('Yes' if bingo else 'No'))



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




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
    if b in a2:
        a2[a2.index(b)] = 0
    if b in a3:
        a3[a3.index(b)] = 0
if (sum(a1) != 0) and (sum(a2) != 0) and (sum(a3) != 0) and (a1[0] + a2[0] + a3[0] != 0) and (a1[1] + a2[1] + a3[1] != 0) and (a1[2] + a2[2] + a3[2] != 0) and a1[0] + a2[1] + a3[2] != 0 and a1[2] + a2[1] + a3[0] != 0:
    print('No')
else:
    print('Yes')

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):
        if A[i][j] in B:
            A[i][j] = -1

for i in range(3):
    ans1, ans2 = 0, 0
    for j in range(3):
        if A[i][j] == -1:
            ans1 += 1
        if A[j][i] == -1:
            ans2 += 1
    if ans1 == 3 or ans2 == 3:
        print("Yes")
        return

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

sheet = []
lines = [[0, 1, 2], [3, 4, 5], [6, 7, 8],
        [0, 3, 6], [1, 4, 7], [2, 5, 8],
        [0, 4, 8], [2, 4, 6]]
sai = []
for i in range(3):
	sheet += [int(j) for j in input().split()]
n = int(input())
for i in range(n):
	sai.append(int(input()))
ret = 'No'
for line in lines:
	bingo = True
	for l in line:
		if sheet[l] not in sai:
			bingo = False
	if bingo:
		ret = 'Yes'
print(ret)

a=[input().split() for _ in range(3)]
n=int(input())
b=[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]:
        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)

import sys
a = 3
A = [list(map(int,input().split())) for c in range(a)]
N = int(input())
b = [int(input()) for c in range(N)]
#print(A)
#print(b)
C = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if b[k] == A[i][j]:
                C[i][j] = 1

for i in range(3):
    if sum(C[i]) == 3:
        print("Yes")
        return

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

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

print("No")


# coding: utf-8

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

    N = int(input())

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

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

    print(ans)


def __starting_point():
    main()

__starting_point()

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] for _ in range(3)]

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

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


import os, sys, re, math

A = []

for i in range(3):
    A += [int(n) for n in input().split()]

N = int(input())
for i in range(N):
    b = int(input())
    A = [0 if a == b else a for a in A]

bingo = 'No'
for x in range(3):
    if A[x * 3] == A[x * 3 + 1] == A[x * 3 + 2] == 0:
        bingo = 'Yes'
for y in range(3):
    if A[y] == A[y + 3] == A[y + 3 * 2] == 0:
        bingo = 'Yes'
if (A[0] == A[4] == A[8] == 0) or (A[2] == A[4] == A[6] == 0):
    bingo = 'Yes'

print(bingo)


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

#横
for i in range(3):
    if board[i][0] == board[i][1] == board[i][2] == 0:
        print("Yes")
        return
#縦
for i in range(3):
    if board[0][i] == board[1][i] == board[2][i] == 0:
        print("Yes")
        return

if board[0][0] == board[1][1] == board[2][2] == 0:
    print("Yes")
    return
if board[0][2] == board[1][1] == board[2][0] == 0:
    print("Yes")
    return

print("No")