output_description: If there exist no reorderings that satisfy the condition, print `No`.
  
  If there exists a reordering that satisfies the condition, print `Yes` on the
  first line. After that, print a reordering of B on the second line, separating
  terms with a whitespace.
  
  If there are multiple reorderings that satisfy the condition, you can print
  any of them.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 \cdots A_N
      B_1 B_2 \cdots B_N
attempt: #!/usr/bin/env python3
  from heapq import heappush, heappop
  import sys
  
  sys.setrecursionlimit(10**6)
  INF = 10**9 + 1  # sys.maxsize # float("inf")
  MOD = 10**9 + 7
  
  
  def debug(*x):
      print(*x, file=sys.stderr)
  
  
  def solve(N, AS, BS):
      acount = [0] * (N + 10)
      bcount = [0] * (N + 10)
      for i in range(N):
          acount[AS[i]] += 1
          bcount[BS[i]] += 1
  
      overlap = []
      queue = []
      for i in range(N + 10):
          if acount[i] + bcount[i] > N:
              print("No")
              return
          if acount[i] and bcount[i]:
              overlap.append(i)
          if bcount[i]:
              heappush(queue, (-acount[i] - bcount[i], i))
  
      ret = []
      for i in range(N):
          cx, x = heappop(queue)
          if x == AS[i]:
              # use another number
              try:
                  cy, y = heappop(queue)
              except:
                  print("No")
                  return
              ret.append(y)
              bcount[y] -= 1
              if bcount[y]:
                  heappush(queue, (cy + 1, y))
              heappush(queue, (cx, x))
          else:
              ret.append(x)
              bcount[x] -= 1
              if bcount[x]:
                  heappush(queue, (cx + 1, x))
  
      print("Yes")
      print(*ret, sep=" ")
  
  
  def main():
      # parse input
      N = int(input())
      AS = list(map(int, input().split()))
      BS = list(map(int, input().split()))
      solve(N, AS, BS)
  
  
  # tests
  T01 = """
  2
  1 1
  1 1
  """
  TEST_T01 = """
  >>> as_input(T01)
  >>> main()
  No
  """
  
  T02 = """
  2
  1 1
  1 2
  """
  TEST_T02 = """
  >>> as_input(T02)
  >>> main()
  No
  """
  
  T03 = """
  2
  1 3
  2 3
  """
  TEST_T03 = """
  >>> as_input(T03)
  >>> main()
  Yes
  3 2
  """
  
  T04 = """
  2
  1 2
  1 3
  """
  TEST_T04 = """
  >>> as_input(T04)
  >>> main()
  Yes
  3 1
  """
  
  T05 = """
  2
  1 2
  1 2
  """
  TEST_T05 = """
  >>> as_input(T05)
  >>> main()
  Yes
  2 1
  """
  
  T1 = """
  6
  1 1 1 2 2 3
  1 1 1 2 2 3
  """
  TEST_T1 = """
  >>> as_input(T1)
  >>> main()
  Yes
  2 2 3 1 1 1
  """
  
  
  def _test():
      import doctest
  
      doctest.testmod()
      g = globals()
      for k in sorted(g):
          if k.startswith("TEST_"):
              doctest.run_docstring_examples(g[k], g, name=k)
  
  
  def as_input(s):
      "use in test, use given string as input file"
      import io
  
      f = io.StringIO(s.strip())
      g = globals()
      g["input"] = lambda: bytes(f.readline(), "ascii")
      g["read"] = lambda: bytes(f.read(), "ascii")
  
  
  input = sys.stdin.buffer.readline
  read = sys.stdin.buffer.read
  
  if sys.argv[-1] == "-t":
      print("testing")
      _test()
      sys.exit()
  
  main()
  
problem_description: Statement
  
  Given are two sequences A and B, both of length N. A and B are each sorted in
  the ascending order. Check if it is possible to reorder the terms of B so that
  for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output
  any of the reorderings that achieve it.
samples: [{"input": "6\n    1 1 1 2 2 3\n    1 1 1 2 2 3", "output": "Yes\n    2 2 3 1 1 1\n    \n\n* * *"}, {"input": "3\n    1 1 2\n    1 1 3", "output": "No\n    \n\n* * *"}, {"input": "4\n    1 1 2 3\n    1 2 3 3", "output": "Yes\n    3 3 1 2"}]