n=int(eval(input()))

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

c=0

for i in range(n-1):

  if a[i]!=i+1:

    c+=1

print(("YES" if c<3 else "NO"))

  

n = int(eval(input()))

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



cnt = 0

for i in range(n):

  if p[i] != i+1:

    cnt += 1

    

print(("YES" if cnt < 3 else "NO"))
n = int(eval(input()))
a = list(map(int, input().split()))
c = 0
for i in range(n - 1):
    if a[i] != i + 1:
        c += 1
print(("YES" if c < 3 else "NO"))

n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if p[i] != i + 1:
        cnt += 1
print(("YES" if cnt < 3 else "NO"))

-a = list(map(int, input().split())) -c = 0 -for i in range(n - 1): -    if a[i] != i + 1: -        c += 1 -print(("YES" if c < 3 else "NO")) +p = list(map(int, input().split())) +cnt = 0 +for i in range(n): +    if p[i] != i + 1: +        cnt += 1 +print(("YES" if cnt < 3 else "NO"))