n = int(eval(input()))



x = dict()

for i in input().split():

    x[i] = x.get(i, 0) + 1



m = int(eval(input()))



y = dict()

for i in input().split():

    y[i] = y.get(i, 0) + 1



for i, j in list(y.items()):

    if x.get(i, 0) < j:

        print("NO")

        exit()

print("YES")
n = int(eval(input()))



x = dict()

for i in input().split():

    x[i] = x.get(i, 0) + 1



m = int(eval(input()))



for i in input().split():

    if i not in x or x[i] == 0:

        print("NO")

        exit()

    else:

        x[i] -= 1

print("YES")
n = int(eval(input()))
x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1
m = int(eval(input()))
y = dict()
for i in input().split():
    y[i] = y.get(i, 0) + 1
for i, j in list(y.items()):
    if x.get(i, 0) < j:
        print("NO")
        exit()
print("YES")

n = int(eval(input()))
x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1
m = int(eval(input()))
for i in input().split():
    if i not in x or x[i] == 0:
        print("NO")
        exit()
    else:
        x[i] -= 1
print("YES")

-y = dict() -    y[i] = y.get(i, 0) + 1 -for i, j in list(y.items()): -    if x.get(i, 0) < j: +    if i not in x or x[i] == 0: +    else: +        x[i] -= 1