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

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

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

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

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