output_description: If the objective is achievable, print `Yes`; if it is not, print `No`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
      B_1 B_2 ... B_N
attempt: import sys
  from bisect import bisect as br
  from collections import Counter
  
  readline = sys.stdin.readline
  
  
  def check(A, B):
      SA = sorted(A)
      SB = sorted(B)
      if any(a > b for a, b in zip(SA, SB)):
          return "No"
      if all(a <= b for a, b in zip(A, B)):
          return "Yes"
      if any(br(SA, SB[i]) != i + 1 for i in range(N)):
          return "Yes"
      if len(set(A)) != N or len(set(B)) != N:
          return "Yes"
      P = [None] * N
      Aidx = Counter()
      Bidx = Counter()
      for i in range(N):
          a = A[i]
          b = B[i]
          Aidx[a] = i
          Bidx[b] = i
  
      for i in range(N):
          sa = SA[i]
          sb = SB[i]
          P[Aidx[sa]] = Bidx[sb]
      visited = set()
      vn = 0
      while vn not in visited:
          visited.add(vn)
          vn = P[vn]
      if len(visited) == N:
          return "No"
      return "Yes"
  
  
  N = int(readline())
  A = list(map(int, readline().split()))
  B = list(map(int, readline().split()))
  print(check(A, B))
  
problem_description: Statement
  
  Given are two integer sequences of N elements each: A_1,...,A_N and
  B_1,...,B_N. Determine if it is possible to do the following operation at most
  N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \leq
  B_i holds:
  
    * Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.
samples: [{"input": "3\n    1 3 2\n    1 2 3", "output": "Yes\n    \n\nWe should swap the values of A_2 and A_3.\n\n* * *"}, {"input": "3\n    1 2 3\n    2 2 2", "output": "No\n    \n\n* * *"}, {"input": "6\n    3 1 2 6 3 4\n    2 2 8 3 4 3", "output": "Yes"}]