from sys import stdin
import numpy as np

lines = stdin.readlines()

a1 = [int(x) for x in lines[0].rstrip().split()]
a2 = [int(x) for x in lines[1].rstrip().split()]
a3 = [int(x) for x in lines[2].rstrip().split()]

counter = 0
n = int(lines[3].rstrip())
for i in range(n):
    if a1[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a1[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a1[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a2[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a2[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a3[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a3[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[0] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[0] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[1] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[1] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[2] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[2] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[0] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[2] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

for i in range(n):
    if a1[2] == int(lines[4+i].rstrip()):
        for j in range(n):
            if a2[1] == int(lines[4+j].rstrip()):
                for k in range(n):
                    if a3[0] == int(lines[4+k].rstrip()):
                        counter += 1
                        break
                else:
                    continue
                break
        else:
            continue
        break

if counter > 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 12720