*a,=list(map(int,open(0).read().split()));print(('NYoe s'[any(t<=set(a.index(b)for b in a[10:])for t in({0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}))::2]))
*a,=list(map(int,open(0).read().split()));print(('YNeos'[all(t-set(a.index(b)for b in a[10:])for t in({0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}))::2]))
(*a,) = list(map(int, open(0).read().split()))
print(
    (
        "NYoe s"[
            any(
                t <= set(a.index(b) for b in a[10:])
                for t in (
                    {0, 1, 2},
                    {0, 3, 6},
                    {0, 4, 8},
                    {1, 4, 7},
                    {2, 4, 6},
                    {2, 5, 8},
                    {3, 4, 5},
                    {6, 7, 8},
                )
            ) :: 2
        ]
    )
)

(*a,) = list(map(int, open(0).read().split()))
print(
    (
        "YNeos"[
            all(
                t - set(a.index(b) for b in a[10:])
                for t in (
                    {0, 1, 2},
                    {0, 3, 6},
                    {0, 4, 8},
                    {1, 4, 7},
                    {2, 4, 6},
                    {2, 5, 8},
                    {3, 4, 5},
                    {6, 7, 8},
                )
            ) :: 2
        ]
    )
)

-        "NYoe s"[ -            any( -                t <= set(a.index(b) for b in a[10:]) +        "YNeos"[ +            all( +                t - set(a.index(b) for b in a[10:])