import numpy as np



n = int(input())

pn = np.array(list(map(lambda x: int(x), input().split(' '))))

diff = np.count_nonzero(pn != np.arange(1, n + 1, dtype='int'))

print('YES') if diff in [0, 2] else print('NO')

import numpy as np

print('YES') if np.count_nonzero(np.array(np.arange(1, int(input())+1) != list(map(int, input().split())))) < 3 else print('NO')

import numpy as np

n = int(input())
pn = np.array(list(map(lambda x: int(x), input().split(" "))))
diff = np.count_nonzero(pn != np.arange(1, n + 1, dtype="int"))
print("YES") if diff in [0, 2] else print("NO")

import numpy as np

print("YES") if np.count_nonzero(
    np.array(np.arange(1, int(input()) + 1) != list(map(int, input().split())))
) < 3 else print("NO")

-n = int(input()) -pn = np.array(list(map(lambda x: int(x), input().split(" ")))) -diff = np.count_nonzero(pn != np.arange(1, n + 1, dtype="int")) -print("YES") if diff in [0, 2] else print("NO") +print("YES") if np.count_nonzero( +    np.array(np.arange(1, int(input()) + 1) != list(map(int, input().split()))) +) < 3 else print("NO")