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: import os
  from io import BytesIO, IOBase
  import sys
  from collections import Counter
  
  
  def main():
      n = int(input())
      ans = "Yes"
      a = list(map(int, input().split()))
      b = list(map(int, input().split()))
      c = Counter(a)
      d = Counter(b)
      for i in c:
          if (n - c[i]) < d[i]:
              ans = "No"
              break
      if ans == "Yes":
          for i in d:
              if (n - d[i]) < c[i]:
                  ans = "No"
                  break
      if ans == "Yes":
          b.reverse()
          e = []
          for i in range(n):
              if a[i] == b[i]:
                  e.append(i)
          if e != []:
              e.reverse()
              for i in range(n):
                  if a[i] != b[i] and a[i] != b[e[-1]]:
                      b[e[-1]], b[i] = b[i], b[e[-1]]
                      e.pop()
                      if e == []:
                          break
              for i in range(n):
                  if a[i] != b[i] and a[i] != b[e[-1]]:
                      b[e[-1]], b[i] = b[i], b[e[-1]]
                      e.pop()
                      if e == []:
                          break
              if e == []:
                  ans = "Yes"
              else:
                  ans = "No"
      print(ans)
      if ans == "Yes":
          print(*b)
  
  
  # region fastio
  BUFSIZE = 8192
  
  
  class FastIO(IOBase):
      newlines = 0
  
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
  
      def read(self):
          while True:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
  
      def readline(self):
          while self.newlines == 0:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
  
      def flush(self):
          if self.writable:
              os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
  
  
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  
  if __name__ == "__main__":
      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"}]