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: """
  
  和がN以下なら恐れくYES
  過半数にならないようにとっていけばいい
  和がちょうどNなのが2つあったら、それを取る
  
  和がNになるやつが現れるまでは自由にとり
  N個になったら、それ+1個を取る
  
  """
  
  import sys
  from sys import stdin
  
  
  # 0-indexed , 半開区間[a,b)
  # calc変更で演算変更
  class SegTree:
  
      def __init__(self, N, first):
          self.NO = 2 ** (N - 1).bit_length()
          self.First = first
          self.data = [first] * (2 * self.NO)
  
      def calc(self, l, r):
          return max(l, r)
  
      def update(self, ind, x):
          ind += self.NO - 1
          self.data[ind] = x
          while ind >= 0:
              ind = (ind - 1) // 2
              self.data[ind] = self.calc(self.data[2 * ind + 1], self.data[2 * ind + 2])
  
      def query(self, l, r):
          L = l + self.NO
          R = r + self.NO
          s = self.First
          while L < R:
              if R & 1:
                  R -= 1
                  s = self.calc(s, self.data[R - 1])
              if L & 1:
                  s = self.calc(s, self.data[L - 1])
                  L += 1
              L >>= 1
              R >>= 1
          return s
  
      def get(self, ind):
          ind += self.NO - 1
          return self.data[ind]
  
  
  N = int(stdin.readline())
  A = list(map(int, stdin.readline().split()))
  B = list(map(int, stdin.readline().split()))
  
  nA = [0] * (N + 1)
  nB = [0] * (N + 1)
  nS = [0] * (N + 1)
  
  for i in A:
      nA[i] += 1
      nS[i] += 1
  for i in B:
      nB[i] += 1
      nS[i] += 1
  
  if max(nS) > N:
      print("No")
      sys.exit()
  
  print("Yes")
  
  ST = SegTree(N + 1, (float("-inf"), 0))
  for i in range(N):
      ST.update(i, (nS[i], i))
  
  B.sort()
  B.reverse()
  
  out = None
  ans = []
  for i in range(N):
  
      num, inds = ST.query(0, N + 1)
      if num == N - i:
          out = inds
          break
  
      if A[-1] == B[-1]:
          B.reverse()
  
      nas, tmp = ST.get(A[-1])
      ST.update(A[-1], (nas - 1, A[-1]))
      nab, tmp = ST.get(B[-1])
      ST.update(B[-1], (nab - 1, B[-1]))
      ans.append((A[-1], B[-1]))
      del A[-1]
      del B[-1]
  
  if out != None:
      for i in A:
          if i != out:
              ans.append((i, out))
      for i in B:
          if i != out:
              ans.append((out, i))
  
  ans.sort()
  pla = []
  for aa, bb in ans:
      pla.append(bb)
  print(*pla)
  
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"}]