Problem:
Score : 600 points

Problem 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.

Constraints

1\leq N \leq 2 \times 10^5

1\leq A_i,B_i \leq N

A and B are each sorted in the ascending order.

All values in input are integers.

Input

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

Output

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.

Sample Input 1

6
1 1 1 2 2 3
1 1 1 2 2 3

Sample Output 1

Yes
2 2 3 1 1 1

Sample Input 2

3
1 1 2
1 1 3

Sample Output 2

No

Sample Input 3

4
1 1 2 3
1 2 3 3

Sample Output 3

Yes
3 3 1 2

Solution in PyPy3 (7.3.0) (judge verdict: Time Limit Exceeded)

def LI():return list(map(int,input().split()))
def II():return int(input())
#def yes():return print("Yes")
#def no():return print("No")
#INF=float("inf")
from collections import deque, defaultdict, Counter
# from heapq import heappop, heappush
# from itertools import product, combinations
# from functools import reduce, lru_cache
# from math import pi, gcd
# from decimal import Decimal

# class Combination:
#     """
#     O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
#     n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
#     使用例：
#     comb = Combination(1000000)
#     print(comb(5, 3))  # 10
#     """
#     def __init__(self, n_max, mod=10**9+7):
#         self.mod = mod
#         self.modinv = self.make_modinv_list(n_max)
#         self.fac, self.facinv = self.make_factorial_list(n_max)

#     def __call__(self, n, r):
#         return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

#     def make_factorial_list(self, n):
#         # 階乗のリストと階乗のmod逆元のリストを返す O(n)
#         # self.make_modinv_list()が先に実行されている必要がある
#         fac = [1]
#         facinv = [1]
#         for i in range(1, n+1):
#             fac.append(fac[i-1] * i % self.mod)
#             facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
#         return fac, facinv

#     def make_modinv_list(self, n):
#         # 0からnまでのmod逆元のリストを返す O(n)
#         modinv = [0] * (n+1)
#         modinv[1] = 1
#         for i in range(2, n+1):
#             modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
#         return modinv

# class Unionfind:
#     def __init__(self, N):
#         self.p = list(range(N))
#         self.rank = [0] * N
#         self.size = [1] * N

#     def root(self, x):
#         if self.p[x] != x:
#             self.p[x] = self.root(self.p[x])

#         return self.p[x]

#     def same(self, x, y):
#         return self.root(x) == self.root(y)

#     def unite(self, x, y):
#         u = self.root(x)
#         v = self.root(y)

#         if u == v: return

#         if self.rank[u] < self.rank[v]:
#             self.p[u] = v
#             self.size[v] += self.size[u]
#             self.size[u] = 0
#         else:
#             self.p[v] = u
#             self.size[u] += self.size[v]
#             self.size[v] = 0

#             if self.rank[u] == self.rank[v]:
#                 self.rank[u] += 1

#     def count(self, x):
#         return self.size[self.root(x)]

n=II()
a=LI()
b=LI()

ac=Counter(a)
bc=Counter(b)

for i in range(n):
    if ac[i]+bc[i]>n:
        print("No")
        exit()
        
import random
while True:
    random.shuffle(b)
    if any(d==e for d,e in zip(a,b)):
        continue
    print("Yes")
    print(*b)
    exit()