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: from collections import Counter
  
  
  def even(N, A, sA):  # 置換の偶奇性を数える
      d = {}
      for i, Ai in enumerate(A):
          d[Ai] = i  # 重複ある場合に注意
      cnt = 0
      for i in range(N):
          if A[i] != sA[i]:
              A[i], A[d[sA[i]]] = A[d[sA[i]]], A[i]
              cnt += 1
      return cnt % 2 == 0
  
  
  N = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  
  f1 = True
  f2 = True
  f3 = True
  f4 = True
  sA = sorted(A[:])
  sB = sorted(B[:])
  for i in range(N):
      if sA[i] > sB[i]:
          f1 = False
          break
  if f1:
      CA = Counter(A)
      CB = Counter(B)
      vA = CA.values()
      vB = CB.values()
      if max(vA) >= 2 or max(vB) >= 2:
          f2 = True
      else:
          f2 = False
  
  if not f2:
      tA = even(N, A, sA)
      tB = even(N, B, sB)
      if tA != tB:
          f3 = True
      else:
          f3 = False
  
  if not f3:
      if sA[-1] <= sB[-2] and sA[-2] <= sB[-1]:
          f4 = True
      else:
          f4 = False
  
  if not f1:
      f = False
  elif f2:
      f = True
  elif f3:
      f = True
  elif f4:
      f = True
  else:
      f = False
  
  print("Yes" if f else "No")
  
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"}]