CodeEff/ECCO huggingface dataset:
# Original solution
A = sum([list(map(int, input().split())) for _ in range(3)], [])
N = int(eval(input()))

ans = 0

for _ in range(N):
    b = int(eval(input()))
    if b in A:
        A[A.index(b)] = 0
    if (
        A[0] + A[1] + A[2] == 0
        or A[3] + A[4] + A[5] == 0
        or A[6] + A[7] + A[8] == 0
        or A[0] + A[3] + A[6] == 0
        or A[1] + A[4] + A[7] == 0
        or A[2] + A[5] + A[8] == 0
        or A[0] + A[4] + A[8] == 0
        or A[2] + A[4] + A[6] == 0
    ):
        print("Yes")
        break
else:
    print("No")

# Optimized solution
A = sum([list(map(int, input().split())) for _ in range(3)], [])
N = int(eval(input()))

for _ in range(N):
    b = int(eval(input()))
    if b in A:
        A[A.index(b)] = 0
    if (
        A[0] + A[1] + A[2] == 0
        or A[3] + A[4] + A[5] == 0
        or A[6] + A[7] + A[8] == 0
        or A[0] + A[3] + A[6] == 0
        or A[1] + A[4] + A[7] == 0
        or A[2] + A[5] + A[8] == 0
        or A[0] + A[4] + A[8] == 0
        or A[2] + A[4] + A[6] == 0
    ):
        print("Yes")
        break
else:
    print("No")
# Original solution
A=[]
for _ in range(3):
    A+=list(map(int,input().split()))

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

p=[
  (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,j,k in p:
    if A[i]==A[j]==A[k]==0:
        print('Yes')
        break
else:
    print('No')


# Optimized solution
A=[]
for _ in range(3):
    A+=list(map(int,input().split()))

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

p=[
  (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,j,k in p:
    if A[i]==A[j]==A[k]:
        print('Yes')
        break
else:
    print('No')
# Original solution
def f():
  a1 = list(map(int, input().split()))
  a2 = list(map(int, input().split()))
  a3 = list(map(int, input().split()))
  A = a1+a2+a3

  N = int(eval(input()))

  c = [False]*9

  for i in range(N):
    b = int(eval(input()))
    if b in A:
      c[A.index(b)] = True

  for i in range(3):
    if c[i] and c[3+i] and c[6+i]:
      return 'Yes'
    elif c[3*i] and c[3*i+1] and c[3*i+2]:
      return 'Yes'

  if c[0] and c[4] and c[8]:
    return 'Yes'
  elif c[2] and c[4] and c[6]:
    return 'Yes'

  return 'No'
print((f()))

# Optimized solution
*A, = list(map(int, open(0).read().split()))
N = A[9]
B = A[10:]
A = A[:9]

T = [False]*9

for b in B:
    if b in A:
        T[A.index(b)] = True

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

for a, b, c in bingo:
    if T[a] and T[b] and T[c]:
        print('Yes')
        break
else:
    print('No')
# Original solution
a = [list(map(int, input().split())) for _ in range(3)]
n = int(eval(input()))
b = [int(eval(input())) for _ in range(n)]
mark = [[False, False, False] for _ in range(3)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True
ans = 'No'
for i in range(3):
    if mark[i][0] and mark[i][1] and mark[i][2]:
        ans = 'Yes'
        break

for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break


if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)


# Optimized solution
a = [list(map(int, input().split())) for _ in range(3)]
n = int(eval(input()))
b = [int(eval(input())) for _ in range(n)]
mark = [[False, False, False] for _ in range(3)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True
ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break
        
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
        
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)
# Original solution
A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for _ in range(N)]

field = 0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			field = field | (1 << i)
ans = False
for v in sum([[273,84],sum([[73<<i,7<<i*3]for i in range(3)],[])],[]):
  ans = ans or field&v==v;
print(('Yes' if ans else 'No'))


# Optimized solution
A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for _ in range(N)]

f=0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			f|=1<<i
ans = 0
for v in [7,56,73,84,146,273,292,448]:
  ans |= f&v==v;
print(('Yes' if ans else 'No'))
# Original solution
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
b=[int(p())for _ in r(int(p()))]
print(('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No'))

# Optimized solution
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
b=[int(p())for _ in r(int(p()))]
print(('YNeos'[all([sum(1<<i for i in r(9)if A[i]in b)&v!=v for v in[7,56,73,84,146,273,292,448]])::2]))
# Original solution
A = [list(map(int,input().split())) for i in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for i in range(N)]
cnt = [0]*8
ans = "No"
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            cnt[i] += 1
            cnt[j+3] += 1
            if i== j:
                cnt[-2] += 1
            if i+j == 2:
                cnt[-1] += 1
for k in range(8):
    if cnt[k] >= 3:
        ans = "Yes"
        break
print(ans)

# Optimized solution
A = [list(map(int,input().split())) for i in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for i in range(N)]
cnt = [0]*8
ans = "No"
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            cnt[i] += 1
            cnt[j+3] += 1
            if i == j:
                cnt[-1] += 1
            if i+j == 2:
                cnt[-2] += 1
for k in range(8):
    if cnt[k] >= 3:
        ans = "Yes"
        break
print(ans)
# Original solution
from collections import defaultdict
def a():
    A = []
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    N = int(eval(input()))
    d = defaultdict(int)
    for _ in range(N):
        d[int(eval(input()))] = 1

    B = list([d[x] for x in A])

    if sum(B[::4]) == 3:
        return 1
    
    if sum(B[2:8:2]) == 3:
        return 1
    
    for i in range(3):
        if sum(B[i*3:i*3+3]) == 3:
            return 1
        if sum(B[i::3]) == 3:
            return 1
    
    return 0

print((["No","Yes"][a()]))


# Optimized solution
(lambda A:(lambda N:(lambda
C:(lambda d:(lambda B:print
(["No","Yes"][3 in{sum(B[2:
8:2]),sum(B[::4])}|{sum(B[i
*3:i*3+3])for i in range(3)
} | { sum(B[i::3] )for i in
range(3)} ] ) ) ( list(map(
lambda x:d[x],A))))([x in C
for x in range(101)]))({int
(input())for x in range(N)}
))(int(input())))(list(map(
int,input().split()))+list(
map(int,input().split())) +
list(map(int,input().split())))
# Original solution
array_1 = []
for i in range(3):
    line = input().rstrip().split(' ')
    array_1.append(line)
    
# print(array_1)

bool_array = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(False)
    bool_array.append(tmp)

# print(bool_array)

num = int(input().rstrip())
for i in range(num):
    input_line = input().rstrip()
    for j in range(3):
        for k in range(3):
            if array_1[j][k] == input_line:
                bool_array[j][k] = True

ans = "No"
for i in range(3):
    if bool_array[i][0] and bool_array[i][1] and bool_array[i][2]:
        ans = 'Yes'

for i in range(3):
    if bool_array[0][i] and bool_array[1][i] and bool_array[2][i]:
        ans = 'Yes'

if bool_array[0][0] and bool_array[1][1] and bool_array[2][2]:
    ans = 'Yes'

if bool_array[0][2] and bool_array[1][1] and bool_array[2][0]:
    ans = 'Yes'
    
    
print(ans)

# Optimized solution
array_1 = []
for i in range(3):
    line = input().rstrip().split(' ')
    array_1.append(line)

bool_array = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(False)
    bool_array.append(tmp)
num = int(input().rstrip())
for i in range(num):
    input_line = input().rstrip()
    for j in range(3):
        for k in range(3):
            if array_1[j][k] == input_line:
                bool_array[j][k] = True

ans = "No"
for i in range(3):
    if bool_array[i][0] and bool_array[i][1] and bool_array[i][2]:
        ans = 'Yes'

    if bool_array[0][i] and bool_array[1][i] and bool_array[2][i]:
        ans = 'Yes'

if bool_array[0][0] and bool_array[1][1] and bool_array[2][2]:
    ans = 'Yes'

if bool_array[0][2] and bool_array[1][1] and bool_array[2][0]:
    ans = 'Yes'
print(ans)
# Original solution

def myAnswer(A:list,B:list,N:int) -> str:
   bingo=[[0,0,0] for i in range(3)]
   for b in B:
      for i,a in enumerate(A):
         if(b in a):
            bingo[i][a.index(b)] = 1
            break
   tate=[0,0,0]
   for n,b in enumerate(bingo):
      if(sum(b) == 3):
         return "Yes"
      for i in range(3):
         tate[i] += b[i]
   if(3 in tate): return "Yes"
   if(bingo[1][1] == 1):
      if((bingo[0][0] == 1 and bingo[2][2] == 1) or (bingo[0][2]==1 and bingo[2][0]==1)):
         return "Yes"
   return "No"

def modelAnswer():
   tmp=1
def main():
   A=[]
   B=[]
   for _ in range(3):
      A.append(list(map(int,input().split())))
   N = int(eval(input()))
   for _ in range(N):
      B.append(int(eval(input())))
   print((myAnswer(A[:],B[:],N)))

if __name__ == '__main__':
   main()

# Optimized solution
def myAnswer(A: list, B: list, N: int) -> str:
    bingoCard = [[0, 0, 0] for i in range(3)]
    row = [0, 0, 0]
    # マスが空くがどうかの判定
    for b in B:
        for i, a in enumerate(A):
            if(b in a):
                bingoCard[i][a.index(b)] = 1
                row[a.index(b)] += 1
                break
    for n, b in enumerate(bingoCard):
        if(sum(b) == 3):
            return "Yes"  # 横の判定

    # 縦の判定(列ごとの合計が3である列があったかどうか)
    if(3 in row):
        return "Yes"

    # 斜めの判定
    if(bingoCard[1][1]):
        if((bingoCard[0][0] and bingoCard[2][2]) or (bingoCard[0][2] and bingoCard[2][0])):
            return "Yes"

    # 縦、横、斜めに当てはまらなければ,No
    return "No"


def modelAnswer():
    tmp = 1


def main():
    A = []
    B = []
    for _ in range(3):
        A.append(list(map(int, input().split())))
    N = int(eval(input()))
    for _ in range(N):
        B.append(int(eval(input())))
    print((myAnswer(A[:], B[:], N)))


if __name__ == '__main__':
    main()
# Original solution
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))
n = int(eval(input()))
b = list(int(eval(input())) for i in range(n))

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

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

# Optimized solution
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))
n = int(eval(input()))
for i in range(n):
    b = int(eval(input()))
    if b in x:
        x[x.index(b)] = 'T'
    if b in y:
        y[y.index(b)] = 'T'
    if b in z:
        z[z.index(b)] = 'T'
if x[0] == 'T' and x[1] == 'T' and x[2] == 'T':
    print('Yes')
elif y[0] == 'T' and y[1] == 'T' and y[2] == 'T':
    print('Yes')
elif z[0] == 'T' and z[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[0] == 'T' and z[0] == 'T':
    print('Yes')
elif x[1] == 'T' and y[1] == 'T' and z[1] == 'T':
    print('Yes')
elif x[2] == 'T' and y[2] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[2] == 'T' and y[1] == 'T' and z[0] == 'T':
    print('Yes')
else:
    print('No')
# Original solution
#Biginner Contest 157 B-Bingo
#二次元配列を使う(3*3)
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = list(map(int,input().split()))

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

for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0] =="True" and bingo[i][1] =="True" and bingo[i][2] =="True":
        IsBingo="Yes"
    elif bingo[0][i] =="True" and bingo[1][i] =="True" and bingo[2][i] =="True":
        IsBingo="Yes"
if (bingo[0][0] =="True" and bingo[1][1] =="True" and bingo[2][2] =="True") or (bingo[0][2] =="True" and bingo[1][1] =="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)



# Optimized solution
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = list(map(int,input().split()))

N = int(eval(input()))
b=[]
for _ in range(N):
    b.append(int(eval(input())))
for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0] =="True" and bingo[i][1] =="True" and bingo[i][2] =="True":
        IsBingo="Yes"
    if bingo[0][i] =="True" and bingo[1][i] =="True" and bingo[2][i] =="True":
        IsBingo="Yes"
if (bingo[0][0] =="True" and bingo[1][1] =="True" and bingo[2][2] =="True") or (bingo[0][2] =="True" and bingo[1][1] =="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)
# Original solution
from collections import defaultdict


def main():

    def is_in(a, b):
        return (a, b) in nums_points

    flag = 0
    row1 = list(map(int, input().split()))
    row2 = list(map(int, input().split()))
    row3 = list(map(int, input().split()))

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

    mat = [row1, row2, row3]
    combs = defaultdict(int)
    for i in range(3):
        for j in range(3):
            combs[mat[i][j]] = (i, j)

    nums_points = []
    for n in nums:
        nums_points.append(combs[n])

    if is_in(0, 0) and is_in(0, 1) and is_in(0, 2):
        flag += 1
    if is_in(1, 0) and is_in(1, 1) and is_in(1, 2):
        flag += 1
    if is_in(2, 0) and is_in(2, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 0) and is_in(2, 0):
        flag += 1
    if is_in(0, 1) and is_in(1, 1) and is_in(2, 1):
        flag += 1
    if is_in(0, 2) and is_in(1, 2) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 2) and is_in(1, 1) and is_in(2, 0):
        flag += 1

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


if __name__ == "__main__":
    main()

# Optimized solution
from collections import defaultdict


def main():

    def is_in(a, b):
        return (a, b) in nums_points

    flag = 0
    mat = [
        list(map(int, input().split())),
        list(map(int, input().split())),
        list(map(int, input().split()))
    ]

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

    combs = defaultdict(int)
    for i in range(3):
        for j in range(3):
            combs[mat[i][j]] = (i, j)

    nums_points = []
    for n in nums:
        nums_points.append(combs[n])

    if is_in(0, 0) and is_in(0, 1) and is_in(0, 2):
        flag += 1
    if is_in(1, 0) and is_in(1, 1) and is_in(1, 2):
        flag += 1
    if is_in(2, 0) and is_in(2, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 0) and is_in(2, 0):
        flag += 1
    if is_in(0, 1) and is_in(1, 1) and is_in(2, 1):
        flag += 1
    if is_in(0, 2) and is_in(1, 2) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 2) and is_in(1, 1) and is_in(2, 0):
        flag += 1

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


if __name__ == "__main__":
    main()
# Original solution
A = [list(map(int, input().split())) for i in range(3)]
N = int(eval(input()))
m = [[0]*3 for i in range(3)]
ans,l,r = 0,0,0
for _ in range(N):
  b = int(eval(input()))
  for i in range(3):
    if b in A[i]:
      m[i][A[i].index(b)]=1
                
for i in range(3):
  t = sum(m[i])
  l += m[i][i]
  y = 0
  for j in range(3):
    y += m[j][i]
    if i+j == 2:
      r += m[i][j]
  if t==3 or y==3 or r==3 or l==3:
    ans=1

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

# Optimized solution
A = [list(map(int, input().split())) for i in range(3)]
N = int(eval(input()))
m = [[0]*3 for i in range(3)]
ans,l,r = 0,1,1
for _ in range(N):
  b = int(eval(input()))
  for i in range(3):
    if b in A[i]:
      m[i][A[i].index(b)]=1
                
for i in range(3):
  l *= m[i][i]
  t,y = 1,1
  for j in range(3):
    y *= m[j][i]
    t *= m[i][j]
    if i+j == 2:
      r *= m[i][j]
  if t or y:
    ans=1

print(('Yes' if ans or l or r else 'No'))
# Original solution
bingo = [list(map(int, input().split())) for i in range(3)]
n = int(eval(input()))
nums = [int(eval(input())) for i in range(n)]
res = 'No'
for num in nums:
    for i in range(3):
        if num in bingo[i]:
            j = bingo[i].index(num)
            bingo[i][j] = 0
            if sum(bingo[i]) == 0 or sum([row[j] for row in bingo]) == 0:
                res = 'Yes'
            elif (i + j) % 2 == 0:
                if i + j == 2 and sum([bingo[0][2], bingo[1][1], bingo[2][0]]) == 0:
                    res = 'Yes'
                elif i == j and sum([bingo[0][0], bingo[1][1], bingo[2][2]]) == 0:
                    res = 'Yes'
            break
    if res == 'Yes':
        break
print(res)

# Optimized solution
bingo = [list(map(int, input().split())) for i in range(3)]
n = int(eval(input()))
for i in range(n):
    num = int(eval(input()))
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == num:
                bingo[j][k] = 0
                break;
res = 'No'
for i in range(3):
    if bingo[i][0] == bingo[i][1] == bingo[i][2] == 0:
        res = 'Yes'
        break
    elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 0:
        res = 'Yes'
        break
if bingo[0][2] == bingo[1][1] == bingo[2][0] == 0:
    res = 'Yes'
elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:
    res = 'Yes'
print(res)
# Original solution
b1 = [int(x) for x in input().split()]
b2 = [int(x) for x in input().split()]
b3 = [int(x) for x in input().split()]
n = int(eval(input()))
li = list()
for i in range(n):
    li.append(int(eval(input())))

b1_0 = False
b1_1 = False
b1_2 = False
b2_0 = False
b2_1 = False
b2_2 = False
b3_0 = False
b3_1 = False
b3_2 = False

for name in li:
    for j ,name2 in enumerate(b1):
        if(name2 == name):
            if(j == 0):
                b1_0 = True
            elif(j == 1):
                b1_1 = True
            else:
                b1_2 = True
    for k,name3 in enumerate(b2):
        if(name == name3):
            if(k == 0):
                b2_0 = True
            elif(k == 1):
                b2_1 = True
            else:
                b2_2 = True
    for l,name4 in enumerate(b3):
        if(name == name4):
            if(l == 0):
                b3_0 = True
            elif(l == 1):
                b3_1 = True
            else:
                b3_2 = True
            
if (b1_0 and b1_1 and b1_2):
    print("Yes")
elif (b2_0 and b2_1 and b2_2):
    print("Yes")
elif (b3_0 and b3_1 and b3_2):
    print("Yes")
elif (b1_0 and b2_0 and b3_0):
    print("Yes")
elif (b1_1 and b2_1 and b3_1):
    print("Yes")
elif(b1_2 and b2_2 and b3_2):
    print("Yes")
elif (b1_0 and b2_1 and b3_2):
    print("Yes")
elif (b1_2 and b2_1 and b3_0):
    print("Yes")
else:
    print("No")

# Optimized solution
a = list()
for i in range(3):
    a.append([int(x) for x in input().split()])
n = int(eval(input()))
b = list()
for i in range(n):
    b.append(int(eval(input())))
appear = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in b:
            if (a[i][j] == k):
                appear[i][j] = 1

def x ():
    for i in range(3):
        if (appear[i][0] and appear[i][1] and appear[i][2] ):
            return "Yes"
    for i in range(3):
        if (appear[0][i] and appear[1][i] and appear[2][i]):
            return "Yes"
    if (appear[0][0] and appear[1][1] and appear[2][2]):
        return "Yes"
    if (appear[0][2] and appear[1][1] and appear[2][0]):
        return "Yes"
    return "No"
print((x()))
# Original solution
import sys
Field = []
for i in range(3):
    a, b, c = list(map(int, input().split(" ")))
    local = [a,b,c]
    Field.append(local)
N = int(eval(input()))
for i in range(N):
    target = int(eval(input()))
    for i in Field:
        if target in i:
            k = i.index(target)
            i[k] = -1
        else:
            pass
if Field[0][0] == -1 and Field[1][1] == -1 and Field[2][2] == -1:
    print("Yes")
    sys.exit()
if Field[0][2] == -1 and Field[1][1] == -1 and Field[2][0] == -1:
    print("Yes")
    sys.exit()

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


# Optimized solution
Field = [list(map(int, input().split(" "))) for i in range(3)]
N = int(eval(input()))
num =[]
for i in range(N):
    t = int(eval(input()))
    num.append(t)
count=0
for i in Field:
    for t in range(3):
        if i[t] in num:
            i[t] = 0

for i in Field:
    if sum(i) == 0:
        count+=1

for i in range(3):
    if Field[0][i] == 0 and Field[1][i] == 0 and Field[2][i] == 0:
        count+=1

if Field[0][0] == 0 and Field[1][1] == 0 and Field[2][2] == 0:
    count+=1
if Field[0][2] == 0 and Field[1][1] == 0 and Field[2][0] == 0:
    count+=1

if count != 0:
    print("Yes")
else:
    print("No")
# Original solution
A = [list(map(int,input().split())) for _ in range(3)]
N = int(eval(input()))
B = [int(eval(input())) for _ in range(N)]
for i in range(3):
    bng = 1
    for j in range(3):
        if A[i][j] in B:
            continue
        else:
            bng = 0
            break
    if bng ==1:break
if bng==1:
    print("Yes")
else:
    for j in range(3):
        bng = 1
        for i in range(3):
            if A[i][j] in B:
                continue
            else:
                bng = 0
                break
        if bng==1:break
    if bng==1:
        print("Yes")
    else:
        if A[0][0] in B and A[1][1] in B and A[2][2] in B:
            print("Yes")
        elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
            print("Yes")
        else:
            print("No")

# Optimized solution
A = [list(map(int,input().split())) for _ in range(3)]
N = int(eval(input()))
B = [[0 for _ in range(3)] for _ in range(3)]
for _ in range(N):
    b = int(eval(input()))
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                B[i][j] = 1
flag = 0
for i in range(3):
    if sum(B[i])==3:
        flag = 1
        break
for j in range(3):
    cnt = 0
    for i in range(3):
        cnt += B[i][j]
    if cnt==3:
        flag = 1
        break
if B[0][0]+B[1][1]+B[2][2]==3:
    flag = 1
if B[2][0]+B[1][1]+B[0][2]==3:
    flag = 1
if flag==1:
    print("Yes")
else:
    print("No")