You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai ≤ Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 ≤ N ≤ 10^5, 1 ≤ Ai, Bi ≤ 10^9. Input is given as N followed by the sequences A and B. Output "Yes" if the objective is achievable, and "No" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).

# Buggy version:
n = int(input())
a = [ [int(s),i]  for i,s in enumerate(input().split())]
b = [ [int(s),i]  for i,s in enumerate(input().split())]
a.sort(reverse=True)
b.sort(reverse=True)

go = [-1] * n

b_ind = 0
ans = 'No'
for a_ind, (j,j_ind) in enumerate(a):
    while(b[b_ind][0] >= j ):
        b_ind += 1

        if(b_ind == n)&(a_ind < n-1):
            print('Yes')
            exit()

        if(b_ind == n):
            break

    if(b_ind == a_ind):
        print('No')
        exit()

    if(b_ind > a_ind+1):
        ans = 'Yes'

now = 0
cnt = 0
for _ in range(n-1):
    now = go[now]
    cnt += 1
    if(now==0):
        print('Yes')
        exit()

print(ans)

# Fixed version:
n = int(input())
a = [ [int(s),i]  for i,s in enumerate(input().split())]
b = [ [int(s),i]  for i,s in enumerate(input().split())]
a.sort(reverse=True)
b.sort(reverse=True)

go = [-1] * n

b_ind = 0
ans = 'No'
for a_ind, (j,j_ind) in enumerate(a):
    while(b[b_ind][0] >= j ):
        b_ind += 1

        if(b_ind == n)&(a_ind < n-1):
            print('Yes')
            exit()

        if(b_ind == n):
            break

    if(b_ind == a_ind):
        print('No')
        exit()

    if(b_ind > a_ind+1):
        ans = 'Yes'

    go[j_ind] = b[a_ind][1]


now = 0
cnt = 0
for _ in range(n-1):
    now = go[now]
    cnt += 1
    if(now==0):
        print('Yes')
        exit()

print(ans)

# Buggy version:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
bi = [[b[i],i] for i in range(n)]
bi.sort()
flg = 0
if len(set(b)) == n:
  for i in range(n):
    bi[i][0] = i
  bi.sort(key = lambda x:x[1])
  idc = list(zip(*bi))[0]
  cnt = 0
  plc = 0
  while True:
    plc = idc[plc]
    cnt += 1
    if plc == 0:
      break
  if cnt == n:
    flg = 1
a.sort()
b.sort()
for x,y in zip(a,b):
  if x > y:
    print("No")
    exit()
if not flg:
  print(2/0)
  print("Yes")
else:
  for i in range(1,n):
    if a[i] <= b[i-1]:
      print("Yes")
      exit()
  print("No")

# Fixed version:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ab = [(x,y) for x,y in zip(a,b)]
ab.sort(key = lambda x:x[1])
a = list(list(zip(*ab))[0])
ai = [[a[i],i] for i in range(n)]
flg = 0
if len(set(b)) == n:
  ai.sort()
  for i in range(n):
    ai[i][0] = i
  ai.sort(key = lambda x:x[1])
  idc = list(zip(*ai))[0]
  cnt = 0
  plc = 0
  while True:
    plc = idc[plc]
    cnt += 1
    if plc == 0:
      break
  if cnt == n:
    flg = 1
a.sort()
b.sort()
for x,y in zip(a,b):
  if x > y:
    print("No")
    exit()
if not flg:
  print("Yes")
else:
  for i in range(1,n):
    if a[i] <= b[i-1]:
      print("Yes")
      exit()
  print("No")

# Buggy version:
import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])
a = [(x[0], i) for i, x in enumerate(c)]
b = [x[1] for x in c]
a.sort()
print(a)
for i in range(n):
	if a[i][0] > b[i]:
		print("No")
		sys.exit()
cur, cnt = 0, 0
while a[cur][1] != 0:
	cnt += 1
	cur = a[cur][1]
if cnt < n-1:
	print("Yes")
else:
	for i in range(n-1):
		if a[i][0] <= b[i+1]:
			print("Yes")
			break
	else:
		print("No")

# Fixed version:
import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])
a = [(x[0], i) for i, x in enumerate(c)]
b = [x[1] for x in c]
a.sort()
for i in range(n):
	if a[i][0] > b[i]:
		print("No")
		sys.exit()
cur, cnt = 0, 0
while a[cur][1] != 0:
	cnt += 1
	cur = a[cur][1]
if cnt < n-1:
	print("Yes")
else:
	for i in range(n-1):
		if a[i+1][0] <= b[i]:
			print("Yes")
			break
	else:
		print("No")

# Buggy version:
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
ail=[(i,a) for i,a in enumerate(al)]
bil=[(i,b) for i,b in enumerate(bl)]
ail=sorted(ail,key=lambda x:x[1])
bil=sorted(bil,key=lambda x:x[1])
if not all([ail[i][1]<=bil[i][1] for i in range(n)]):
    print('No')
    exit()
if any([ail[i][0]==bil[i][0] for i in range(n)]):
    print('Yes')
    exit()
c=[(ail[i][0],bil[i][0]) for i in range(n)]
c=sorted(c)
print(c)
idx=0
for _ in range(n-1):
    idx=c[idx][1]
    if idx==0:
        print('Yes')
        break
else:
    print('No')

# Fixed version:
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
ail=[(i,a) for i,a in enumerate(al)]
bil=[(i,b) for i,b in enumerate(bl)]
ail=sorted(ail,key=lambda x:x[1])
bil=sorted(bil,key=lambda x:x[1])
if not all([ail[i][1]<=bil[i][1] for i in range(n)]):
    print('No')
    exit()
if any([ail[i+1][1]<=bil[i][1] for i in range(n-1)]):
    print('Yes')
    exit()
c=[(ail[i][0],bil[i][0]) for i in range(n)]
c=sorted(c)
idx=0
for _ in range(n-1):
    idx=c[idx][1]
    if idx==0:
        print('Yes')
        break
else:
    print('No')

# Buggy version:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ba = sorted((y, x) for x, y in zip(a, b))
a = [x for y, x in ba]
b = [y for y, x in ba]


ap = sorted((x, i) for i, x in enumerate(a))

print(ap) 
if any(ap[i][0] > b[i] for i in range(n)):
    print('No')
    exit()
if any(ap[i + 1][0] <= b[i] for i in range(n - 1)):
    print('Yes')
    exit()

rep = [ap[i][1] for i in range(n)]
p = 0
c = 0
print(['No', 'Yes'][rep[n-1] != 0])


# Fixed version:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ba = sorted((y, x) for x, y in zip(a, b))
a = [x for y, x in ba]
b = [y for y, x in ba]

# print(a)
# print(b) 

ap = sorted((x, i) for i, x in enumerate(a))

# print(ap) 
if any(ap[i][0] > b[i] for i in range(n)):
    print('No')
    exit()
if any(ap[i + 1][0] <= b[i] for i in range(n - 1)):
    print('Yes')
    exit()

rep = [ap[i][1] for i in range(n)]
p = 0
c = 0
while True:
    c += 1
    p = rep[p]
    if p == 0:
        break
print(['No', 'Yes'][c != n])

# Buggy version:
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    A = np.array(list(map(int, args[1].split())))
    B = np.array(list(map(int, args[2].split())))

    ret = False

    sA = np.sort(A)
    sB = np.sort(B)

    if any(sA[1:] <= sB[:-1]):
        ret = True

    elif all(sA <= sB):
        nA = np.argsort(A)
        nB = np.argsort(B)
        P = dict(zip(nA, nB))

        count = 0
        x = P[0]
        while x != 0:
            x = P[x]
            count += 1

        ret = count < n-1

    return 'Yes' if ret else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


# Fixed version:
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    A = np.array(list(map(int, args[1].split())))
    B = np.array(list(map(int, args[2].split())))

    ret = False

    sA = np.sort(A)
    sB = np.sort(B)

    if all(sA <= sB):
        if any(sA[1:] <= sB[:-1]):
            ret = True
        else:
            nA = np.argsort(A)
            nB = np.argsort(B)
            P = dict(zip(nA, nB))

            count = 0
            x = P[0]
            while x != 0:
                x = P[x]
                count += 1

            ret = count < n-1

    return 'Yes' if ret else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

# Buggy version:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]
pb = [(bi,i) for i,bi in enumerate(b)]

sa = sorted(a)
sb = sorted(b)
pb.sort()

na = [a[i] for bi,i in pb]


ok = 1
for i,j in zip(sa,sb):
    if i > j: ok = 0

for i,j in zip(sa[1:],sb):
    if i <= j: break
else:
    #sa => na が巡回置換か？
    d = {ai:i for i,ai in enumerate(sa)}
    ra = [d[ai] for ai in na]
    
    print(ra)    
    now = 0
    for i in range(n-1):
        now = ra[now]
        #print(now)
        if now == 0:
            break
    else: ok = 0    

    
    
    

    

#print(a,b,sa,sb,na)

if ok: print("Yes")    
else: print("No")
    
    
    
    
    
    

# Fixed version:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]
pb = [(bi,i) for i,bi in enumerate(b)]

sa = sorted(a)
sb = sorted(b)
pb.sort()

na = [a[i] for bi,i in pb]


ok = 1
for i,j in zip(sa,sb):
    if i > j: ok = 0

for i,j in zip(sa[1:],sb):
    if i <= j: break
else:
    #sa => na が巡回置換か？
    d = {ai:i for i,ai in enumerate(sa)}
    ra = [d[ai] for ai in na]
    
    #print(ra,ok)    
    now = 0
    for i in range(n-1):
        now = ra[now]
        #print(now)
        if now == 0:
            break
    else: ok = 0    


    

#print(a,b,sa,sb,na)

if ok: print("Yes")    
else: print("No")

# Buggy version:
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
A = [(A[i]<<18) + i for i in range(N)]
B = [(B[i]<<18) + i + (1<<17) for i in range(N)]
AA = sorted(A)
BB = sorted(B)

IA = {}
IB = {}
for i in range(N):
    IA[AA[i]] = i
    IB[BB[i]] = i

for i in range(N):
    if AA[i] > BB[i]:
        print("No")
        break
else:
    for i in range(1, N):
        if AA[i] <= BB[i-1]:
            print("No")
            break
    else:
        for i in range(N):
            if IA[A[i]] == IB[B[i]]:
                print("Yes")
                break
        else:
            c = 1
            i = IA[A[0]]
            i = IA[A[IB[B[i]]]]
            while i != IA[A[0]]:
                i = IA[A[IB[B[i]]]]
                c += 1
            if c < N:
                print("Yes")
            else:
                print("No")

# Fixed version:
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
A = [(A[i]<<18) + i for i in range(N)]
B = [(B[i]<<18) + i + (1<<17) for i in range(N)]
AA = sorted(A)
BB = sorted(B)

IA = {}
IB = {}
for i in range(N):
    IA[AA[i]] = i
    IB[BB[i]] = i

for i in range(N):
    if AA[i] > BB[i]:
        print("No")
        break
else:
    for i in range(1, N):
        if AA[i] <= BB[i-1]:
            print("Yes")
            break
    else:
        for i in range(N):
            if IA[A[i]] == IB[B[i]]:
                print("Yes")
                break
        else:
            c = 1
            i = 0
            P = [-1] * N
            for i in range(N):
                P[IA[A[i]]] = IB[B[i]]
            i = P[0]
            while i != 0:
                i = P[i]
                c += 1
            if c < N:
                print("Yes")
            else:
                print("No")

# Buggy version:
N=int(input())
A1=[int(s) for s in input().split()]
B1=[int(s) for s in input().split()]
A2=[(A1[i],i) for i in range(N)]
B2=[(B1[i],i) for i in range(N)]
A=sorted(A2)
B=sorted(B2)
print(A)
print(B)
for i in range(N):
  if B[i][0]<A[i][0]:
    print("No")
    break
else:
  for i in range(N-1):
    if B[i][0]>=A[i+1][0]:
      print("Yes")
      break
  else:
    k=0
    for i in range(N-1):
      k=B[k][1]
      if k==0:
        print("Yes")
        break
    else:
      print("No")
        


# Fixed version:
N=int(input())
A1=[int(s) for s in input().split()]
B1=[int(s) for s in input().split()]
A2=[(A1[i],i) for i in range(N)]
B2=[(B1[i],i) for i in range(N)]
A=sorted(A2)
B=sorted(B2)
#print(A)
#print(B)
for i in range(N):
  if B[i][0]<A[i][0]:
    print("No")
    break
else:
  for i in range(N-1):
    if B[i][0]>=A[i+1][0]:
      print("Yes")
      break
  else:
    C=[(A[i][1],B[i][1]) for i in range(N)]
    C.sort()
#    print(C)
    k=0
    for i in range(N-1):
      k=C[k][1]
      if k==0:
        print("Yes")
        break
    else:
      print("No")