N = int(eval(input()))

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

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



def count_loop(start, idx_map):

    count = 1

    idx = start

    while True:

        idx = idx_map[idx]

        count += 1

        if idx == 0:

            break

    return count



X = list(zip(A, B))

X.sort(key=lambda x: x[1])



C = sorted((x[0], i) for i, x in enumerate(X))

idx_map = [C[i][1] for i in range(N)]

A = sorted(A)

B = sorted(B)



if any(A[i] > B[i] for i in range(N)):

    print("No")

    exit()



if any(A[i + 1] <= B[i] for i in range(N - 1)):

    print("Yes")

    exit()



if count_loop(0, idx_map) < N:

    print("Yes")

    exit()



print("No")



N = int(eval(input()))

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

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



def count_loop(start, idx_map):

    count = 0

    idx = start

    while True:

        idx = idx_map[idx]

        count += 1

        if idx == 0:

            break

    return count



A, B = list(zip(*sorted(zip(A, B), key=lambda x: x[1])))

idx_map = sorted(list(range(N)), key=lambda i: A[i])

A = sorted(A)



check_1 = all(A[i] <= B[i] for i in range(N))

check_2 = any(A[i + 1] <= B[i] for i in range(N - 1))

check_3 = count_loop(0, idx_map) <= N - 2

print(("Yes" if (check_1 and (check_2 or check_3)) else "No"))

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))


def count_loop(start, idx_map):
    count = 1
    idx = start
    while True:
        idx = idx_map[idx]
        count += 1
        if idx == 0:
            break
    return count


X = list(zip(A, B))
X.sort(key=lambda x: x[1])
C = sorted((x[0], i) for i, x in enumerate(X))
idx_map = [C[i][1] for i in range(N)]
A = sorted(A)
B = sorted(B)
if any(A[i] > B[i] for i in range(N)):
    print("No")
    exit()
if any(A[i + 1] <= B[i] for i in range(N - 1)):
    print("Yes")
    exit()
if count_loop(0, idx_map) < N:
    print("Yes")
    exit()
print("No")

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))


def count_loop(start, idx_map):
    count = 0
    idx = start
    while True:
        idx = idx_map[idx]
        count += 1
        if idx == 0:
            break
    return count


A, B = list(zip(*sorted(zip(A, B), key=lambda x: x[1])))
idx_map = sorted(list(range(N)), key=lambda i: A[i])
A = sorted(A)
check_1 = all(A[i] <= B[i] for i in range(N))
check_2 = any(A[i + 1] <= B[i] for i in range(N - 1))
check_3 = count_loop(0, idx_map) <= N - 2
print(("Yes" if (check_1 and (check_2 or check_3)) else "No"))

-    count = 1 +    count = 0 -X = list(zip(A, B)) -X.sort(key=lambda x: x[1]) -C = sorted((x[0], i) for i, x in enumerate(X)) -idx_map = [C[i][1] for i in range(N)] +A, B = list(zip(*sorted(zip(A, B), key=lambda x: x[1]))) +idx_map = sorted(list(range(N)), key=lambda i: A[i]) -B = sorted(B) -if any(A[i] > B[i] for i in range(N)): -    print("No") -    exit() -if any(A[i + 1] <= B[i] for i in range(N - 1)): -    print("Yes") -    exit() -if count_loop(0, idx_map) < N: -    print("Yes") -    exit() -print("No") +check_1 = all(A[i] <= B[i] for i in range(N)) +check_2 = any(A[i + 1] <= B[i] for i in range(N - 1)) +check_3 = count_loop(0, idx_map) <= N - 2 +print(("Yes" if (check_1 and (check_2 or check_3)) else "No"))