local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local LazyRangeSeg = {}
LazyRangeSeg.create = function(self, n)
  local stagenum, mul = 1, 1
  self.stage = {{true}}
  self.lazy = {{false}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
    self.lazy[stagenum] = {}
    for i = 1, mul do
      self.stage[stagenum][i] = false
      self.lazy[stagenum][i] = false
    end
  end
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, n do
    self.stage[stagenum][i] = true
  end
  self.stagenum = stagenum
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.stage[i + 1][j * 2 - 1] or self.stage[i + 1][j * 2]
    end
  end
end
LazyRangeSeg.resolve = function(self, right)
  local stagenum = self.stagenum
  local offset = 0
  for i = 1, stagenum - 1 do
    local p = offset + bls(1, stagenum - i)
    if p < right then
      offset = p
      p = p + bls(1, stagenum - i)
    end
    if right < p then
      local curidx = brs(p, stagenum - i)
      if self.lazy[i][curidx] then
        self:resolveRange(i + 1, curidx * 2 - 1, true)
        self:resolveRange(i + 1, curidx * 2, true)
        self.lazy[i + 1][curidx * 2 - 1] = true
        self.lazy[i + 1][curidx * 2] = true
        self.lazy[i][curidx] = false
      end
    elseif p == right then
      break
    else
      assert(false)
    end
  end
end
LazyRangeSeg.resolveRange = function(self, stagepos, idx, shallow)
  self.stage[stagepos][idx] = false
  if shallow then return end
  for i = stagepos - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.stage[i + 1][idx] or self.stage[i + 1][rem]
    idx = dst
  end
end
LazyRangeSeg.getRange = function(self, left, right)
  if 1 < left then self:resolve(left - 1) end
  self:resolve(right)
  local stagenum = self.stagenum
  local ret = false
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = ret or self.stage[stage][1 + brs(left - 1, stagenum - stage)]
    left = left + sz
  end
  return ret
end
LazyRangeSeg.setRange = function(self, left, right)
  if 1 < left then self:resolve(left - 1) end
  self:resolve(right)
  local stagenum = self.stagenum
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    local len = right - left + 1
    local idx = 1 + brs(left - 1, stagenum - stage)
    self:resolveRange(stage, idx)
    self.lazy[stage][idx] = true
    left = left + sz
  end
end
LazyRangeSeg.addAll = function(self, value)
  self.stage[1][1] = self.stage[1][1] + value * bls(1, self.stagenum - 1)
  self.lazy[1][1] = self.lazy[1][1] + value * bls(1, self.stagenum - 1)
end
LazyRangeSeg.new = function(n)
  local obj = {}
  setmetatable(obj, {__index = LazyRangeSeg})
  obj:create(n)
  return obj
end


local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local b = {}
for i = 1, n do
  b[i] = io.read("*n")
end
local left, right = {}, {}
for i = 1, n do
  if not left[a[i]] then
    left[a[i]] = i
  end
  right[a[i]] = i
end

local lzst = LazyRangeSeg.new(n)

for i = 1, n do
  local l = left[b[i]]
  if l then
    local r = right[b[i]]
    if r < i then
      local ng_move_1 = i - r
      local ng_move_2 = i - l
      lzst:setRange(ng_move_1, ng_move_2)
    elseif i < l then
      local ng_move_1 = i + n - r
      local ng_move_2 = i + n - l
      lzst:setRange(ng_move_1, ng_move_2)
    else
      local ng_move_1 = i - l
      if 1 <= ng_move_1 then
        lzst:setRange(1, ng_move_1)
      end
      local ng_move_2 = i + n - r
      lzst:setRange(ng_move_2, n)
    end
  end
end
if lzst:getRange(1, n) then
  print("Yes")
  for i = 1, n do
    if lzst:getRange(i, i) then
      local c = {}
      for j = 1, n do
        c[j] = 0
      end
      for src = 1, n do
        local dst = src - i
        if dst <= 0 then dst = dst + n end
        c[dst] = b[src]
      end
      print(table.concat(c, " "))
      break
    end
  end
else
  print("No")
end


Measured memory_bytes: 27904