f=lambda a:any(all(b)for b in a)|all(a[i][i]for i in(0,1,2))   

a=eval('list(map(int,input().split())),'*3)

exec('b=int(input());a=[[u*(u!=b)for u in t]for t in a];'*int(eval(input())))

a=[[not u for u in t]for t in a]

print(('NYoe s'[f(a)|f([t[::-1]for t in zip(*a)])::2]))
f=lambda a:any(all(b)for b in a)|all(a[i][i]for i in(0,1,2))

*t,=list(map(int,open(0).read().split()))

a=t[:9]

s=eval('[0]*3,'*3)

for b in t[10:]:

  if b in a:

    i=a.index(b)

    s[i//3][i%3]=1

print(('NYoe s'[f(s)|f([t[::-1]for t in zip(*s)])::2]))
f = lambda a: any(all(b) for b in a) | all(a[i][i] for i in (0, 1, 2))
a = eval("list(map(int,input().split()))," * 3)
exec("b=int(input());a=[[u*(u!=b)for u in t]for t in a];" * int(eval(input())))
a = [[not u for u in t] for t in a]
print(("NYoe s"[f(a) | f([t[::-1] for t in zip(*a)]) :: 2]))

f = lambda a: any(all(b) for b in a) | all(a[i][i] for i in (0, 1, 2))
(*t,) = list(map(int, open(0).read().split()))
a = t[:9]
s = eval("[0]*3," * 3)
for b in t[10:]:
    if b in a:
        i = a.index(b)
        s[i // 3][i % 3] = 1
print(("NYoe s"[f(s) | f([t[::-1] for t in zip(*s)]) :: 2]))

-a = eval("list(map(int,input().split()))," * 3) -exec("b=int(input());a=[[u*(u!=b)for u in t]for t in a];" * int(eval(input()))) -a = [[not u for u in t] for t in a] -print(("NYoe s"[f(a) | f([t[::-1] for t in zip(*a)]) :: 2])) +(*t,) = list(map(int, open(0).read().split())) +a = t[:9] +s = eval("[0]*3," * 3) +for b in t[10:]: +    if b in a: +        i = a.index(b) +        s[i // 3][i % 3] = 1 +print(("NYoe s"[f(s) | f([t[::-1] for t in zip(*s)]) :: 2]))