module heapq
  implicit none
  integer, parameter :: intkind = 4
  private :: less, swap
contains
  logical function less(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b(:)
    res = a(1) <= b(1)
  end
  subroutine swap(a, b)
    integer(intkind), intent(inout) :: a(:), b(:)
    integer(intkind) :: c(size(a))
    c = a
    a = b
    b = c
  end
  subroutine heapify(a, n)
    integer(intkind), intent(inout) :: a(:, :)
    integer, intent(in) :: n
    integer :: i, j, k
    do i = 1, n
      j = i
      do while (j > 1)
        k = j / 2
        if (less(a(j, :), a(k, :))) exit
        call swap(a(j, :), a(k, :))
        j = k
      end do
    end do
  end
  subroutine heappush(a, n, b)
    integer(intkind), intent(inout) :: a(:, :)
    integer, intent(inout) :: n
    integer(intkind), intent(in) :: b(:)
    integer :: i, j
    n = n + 1
    a(n, :) = b
    i = n
    do while (i > 1)
      j = i / 2
      if (less(a(i, :), a(j, :))) exit
      call swap(a(i, :), a(j, :))
      i = j
    end do
  end
  function heappop(a, n) result(res)
    integer(intkind), intent(inout) :: a(:, :)
    integer, intent(inout) :: n
    integer(intkind) :: res(size(a, 2))
    integer :: i, j
    res = a(1, :)
    call swap(a(1, :), a(n, :))
    i = 1
    do while (2 * i < n)
      j = 2 * i
      if (j + 1 < n) then
        if (.not.less(a(j + 1, :), a(j, :))) j = j + 1
      end if
      if (less(a(j, :), a(i, :))) exit
      call swap(a(j, :), a(i, :))
      i = j
    end do
    n = n - 1
  end
end module heapq
program contrast
  use heapq
  implicit none
  integer :: n, na, nb, ra(4), rb(2), ta(4), i
  integer, allocatable :: a(:), b(:), ha(:, :), hb(:, :), x(:)
  read(*,*) n
  allocate(a(n), b(n), ha(n, 4), hb(n, 2), x(n))
  read(*,*) a
  read(*,*) b
  ha = 0
  hb = 0
  do i = n, 1, -1
    ha(a(i), 1) = ha(a(i), 1) + 1
    ha(a(i), 2) = a(i)
    ha(a(i), 4) = i
    hb(b(i), 1) = hb(b(i), 1) + 1
    hb(b(i), 2) = b(i)
  end do
  if (any(ha(:, 1) + hb(:, 1) > n)) then
    write(*,'(a)') 'No'
    stop
  end if
  write(*,'(a)') 'Yes'
  ha(:, 3) = ha(:, 1)
  na = n
  nb = n
  call heapify(ha, na)
  call heapify(hb, nb)
  do while (nb > 0 .and. hb(1, 1) > 0)
    rb = heappop(hb, nb)
    ta = -1
    do while (na > 0 .and. ha(1, 1) > 0)
      ra = heappop(ha, na)
      if (ra(2) == rb(2)) then
        ta = ra
        cycle
      end if
      if (ra(3) > rb(1)) then
        i = ra(4) + ra(1) - ra(3)
        x(i:i + rb(1) - 1) = rb(2)
        ra(3) = ra(3) - rb(1)
        call heappush(ha, na, ra)
        exit
      end if
      i = ra(4) + ra(1) - ra(3)
      x(i:i + ra(3) - 1) = rb(2)
      rb(1) = rb(1) - ra(3)
    end do
    if (ta(1) > 0) call heappush(ha, na, ta)
  end do
  write(*,'(i0)',advance='no') x(1)
  do i = 2, n
    write(*,'(x,i0)',advance='no') x(i)
  end do
  write(*,*)
end program contrast