#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void*wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void my_putchar_unlocked(const int k){
  putchar_unlocked(k);
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
template <class T> struct LHeap{
  int*hp;
  int*place;
  int size;
  T*val;
  void malloc(int N){
    hp = (int*)std::malloc(N*sizeof(int));
    place=(int*)std::malloc(N*sizeof(int));
    val=(T*)std::malloc(N*sizeof(T));
  }
  void walloc(int N, void **mem=&wmem){
    walloc1d(&hp, N, mem);
    walloc1d(&place, N, mem);
    walloc1d(&val, N, mem);
  }
  void free(){
    std::free(hp);
    std::free(place);
    std::free(val);
  }
  void init(int N){
    int i;
    size=0;
    for(i=(0);i<(N);i++){
      place[i]=-1;
    }
  }
  void up(int n){
    int m;
    while(n){
      m=(n-1)/2;
      if(val[hp[m]]<=val[hp[n]]){
        break;
      }
      swap(hp[m],hp[n]);
      swap(place[hp[m]],place[hp[n]]);
      n=m;
    }
  }
  void down(int n){
    int m;
    for(;;){
      m=2*n+1;
      if(m>=size){
        break;
      }
      if(m+1<size&&val[hp[m]]>val[hp[m+1]]){
        m++;
      }
      if(val[hp[m]]>=val[hp[n]]){
        break;
      }
      swap(hp[m],hp[n]);
      swap(place[hp[m]],place[hp[n]]);
      n=m;
    }
  }
  void change(int n, T v){
    T f = val[n];
    val[n] = v;
    if(place[n]==-1){
      place[n] = size;
      hp[size++] = n;
      up(place[n]);
    }
    else{
      if(f < v){
        down(place[n]);
      }
      else if(f > v){
        up(place[n]);
      }
    }
  }
  int pop(void){
    int res = hp[0];
    place[res] = -1;
    size--;
    if(size){
      hp[0]=hp[size];
      place[hp[0]]=0;
      down(0);
    }
    return res;
  }
}
;
int N;
int A[200000];
int B[200000];
vector<int> ai[200000+1];
vector<int> bi[200000+1];
int sz;
int aa[10];
int bb[10];
int pm[10];
int res[200000];
int main(){
  wmem = memarr;
  int i;
  int j;
  int k;
  int x;
  int y;
  int r;
  int sa;
  int sb;
  LHeap<int> ha;
  LHeap<int> hb;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY=(0);e98WHCEY<(N);e98WHCEY++){
      rd(B[e98WHCEY]);
    }
  }
  for(i=(0);i<(N);i++){
    ai[A[i]].push_back(i);
  }
  for(i=(0);i<(N);i++){
    bi[B[i]].push_back(i);
  }
  for(i=(0);i<(200000+1);i++){
    if(ai[i].size() + bi[i].size() > N){
      wt_L("No");
      wt_L('\n');
      return 0;
    }
  }
  puts("Yes");
  ha.walloc(N);
  ha.init(N);
  hb.walloc(N);
  hb.init(N);
  for(i=(0);i<(N);i++){
    ha.change(i, -(int)ai[i].size());
  }
  for(i=(0);i<(N);i++){
    hb.change(i, -(int)bi[i].size());
  }
  r = N;
  while(r > 5){
    i = ha.pop();
    j = hb.pop();
    k = hb.pop();
    x = j;
    if(i==j){
      x = k;
    }
    sa = ai[i].back();
    ai[i].pop_back();
    sb = bi[x].back();
    bi[x].pop_back();
    res[sa] = x;
    r--;
    ha.change(i, -(int)ai[i].size());
    hb.change(j, -(int)bi[j].size());
    hb.change(k, -(int)bi[k].size());
  }
  sz = 0;
  for(i=(0);i<(200000+1);i++){
    for(j=(0);j<(ai[i].size());j++){
      aa[sz++] = i;
    }
  }
  sz = 0;
  for(i=(0);i<(200000+1);i++){
    for(j=(0);j<(bi[i].size());j++){
      bb[sz++] = i;
    }
  }
  int Q5rsz4fz;
  for(Q5rsz4fz=(0);Q5rsz4fz<(sz);Q5rsz4fz++){
    pm[Q5rsz4fz] = Q5rsz4fz;
  }
  do{
    {
      for(i=(0);i<(sz);i++){
        if(aa[i] == bb[pm[i]]){
          goto qSsg05KM;
        }
      }
      break;
    }
    qSsg05KM:;
  }
  while(next_permutation(pm,pm+sz));
  for(k=(0);k<(sz);k++){
    i = aa[k];
    x = bb[pm[k]];
    sa = ai[i].back();
    ai[i].pop_back();
    sb = bi[x].back();
    bi[x].pop_back();
    res[sa] = x;
  }
  {
    int ytthggxT;
    if(N==0){
      wt_L('\n');
    }
    else{
      for(ytthggxT=(0);ytthggxT<(N-1);ytthggxT++){
        wt_L(res[ytthggxT]);
        wt_L(' ');
      }
      wt_L(res[ytthggxT]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20200913-1

// --- original code ---
// int N, A[2d5], B[2d5];
// VI ai[2d5+1], bi[2d5+1];
// int sz, aa[10], bb[10], pm[10];
// int res[2d5];
// {
//   int i, j, k, x, y, r;
//   int sa, sb;
//   LHeap<int> ha, hb;
// 
//   rd(N,A(N),B(N));
//   rep(i,N) ai[A[i]].push_back(i);
//   rep(i,N) bi[B[i]].push_back(i);
//   rep(i,2d5+1) if(ai[i].size() + bi[i].size() > N) wt("No"), return 0;
//   puts("Yes");
// 
//   ha.walloc(N); ha.init(N);
//   hb.walloc(N); hb.init(N);
//   rep(i,N) ha.change(i, -(int)ai[i].size());
//   rep(i,N) hb.change(i, -(int)bi[i].size());
// 
//   r = N;
//   while(r > 5){
//     i = ha.pop();
//     j = hb.pop();
//     k = hb.pop();
//     
//     x = j;
//     if(i==j) x = k;
// 
//     sa = ai[i].back(); ai[i].pop_back();
//     sb = bi[x].back(); bi[x].pop_back();
//     res[sa] = x;
//     r--;
// 
//     ha.change(i, -(int)ai[i].size());
//     hb.change(j, -(int)bi[j].size());
//     hb.change(k, -(int)bi[k].size());
//   }
// 
//   sz = 0;
//   rep(i,2d5+1) rep(j,ai[i].size()) aa[sz++] = i;
//   sz = 0;
//   rep(i,2d5+1) rep(j,bi[i].size()) bb[sz++] = i;
// 
//   rep_perm(pm, sz){
//     rep(i,sz) if(aa[i] == bb[pm[i]]) break_continue;
//     break;
//   }
// 
//   rep(k,sz){
//     i = aa[k];
//     x = bb[pm[k]];
// 
//     sa = ai[i].back(); ai[i].pop_back();
//     sb = bi[x].back(); bi[x].pop_back();
//     res[sa] = x;
//   }
// 
//   wt(res(N));
// }


Measured memory_bytes: 33348