from collections import Counter

n = int(eval(input()))

D = list(map(int,input().split()))

D = Counter(D)

m = int(eval(input()))

T = list(map(int,input().split()))

T = Counter(T)

#print(D)

#print(T)

for key in T:

    if D[key] < T[key]:

        print('NO')

        exit()



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

d = list(map(int,input().split()))

d.sort()

m = int(eval(input()))

t = list(map(int,input().split()))

t.sort()

now = 0

for x in t:

    if now == n:

        print("NO")

        exit()

    while d[now] != x:

        now += 1

        if now == n:

            print("NO")

            exit()

    now += 1



print("YES")
from collections import Counter

n = int(eval(input()))
D = list(map(int, input().split()))
D = Counter(D)
m = int(eval(input()))
T = list(map(int, input().split()))
T = Counter(T)
# print(D)
# print(T)
for key in T:
    if D[key] < T[key]:
        print("NO")
        exit()
print("YES")

n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
m = int(eval(input()))
t = list(map(int, input().split()))
t.sort()
now = 0
for x in t:
    if now == n:
        print("NO")
        exit()
    while d[now] != x:
        now += 1
        if now == n:
            print("NO")
            exit()
    now += 1
print("YES")

-from collections import Counter - -D = list(map(int, input().split())) -D = Counter(D) +d = list(map(int, input().split())) +d.sort() -T = list(map(int, input().split())) -T = Counter(T) -# print(D) -# print(T) -for key in T: -    if D[key] < T[key]: +t = list(map(int, input().split())) +t.sort() +now = 0 +for x in t: +    if now == n: +    while d[now] != x: +        now += 1 +        if now == n: +            print("NO") +            exit() +    now += 1