// #define _DEBUG
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//デバッグ
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug1(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug5,debug4,debug3,debug2,debug1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll N;
    cin>>N;
    vl A(N),B(N);
    map<ll,ll> mp,mpA,mpB;

    REP(i,N){
        cin>>A[i];
        mp[A[i]]++;
        mpA[A[i]]++;
    }

    REP(i,N){
        cin>>B[i];
        mp[B[i]]++;
        mpB[B[i]]++;
    }

    priority_queue<pll> que;//first:登場数の和 second:中身
    ll saidai=0;
    REP2(i,1,N+1){
        if(mp.count(i)) saidai=max(saidai,mp[i]);
        if(mpB.count(i)&&mpA.count(i)){
            que.push(make_pair(mp[i],i));
        }
    }

    if(saidai>N){
        cout<<"No"<<endl;
        return 0;
    }

    priority_queue<pll,vector<pll>,greater<pll>> pair_AB;
    queue<ll> listA;
    while(!que.empty()){
        pll tmp=que.top();
        que.pop();
        ll wa1 = tmp.first;
        ll val1 = tmp.second;

        ll nokori1B = mpB[val1];
        
        if(!que.empty()){
            tmp=que.top();
            que.pop();
            ll wa2=tmp.first;
            ll val2=tmp.second;

            ll nokori2A = mpA[val2];

            debug(val1,mpB[val1]);
            debug(val2,mpB[val2]);
            pair_AB.push(make_pair(val2,val1));
            wa1--;
            wa2--;
            mpA[val2]--;
            mpB[val1]--;

            nokori1B = mpB[val1];
            nokori2A = mpA[val2];
            
            if(nokori1B>0){
                que.push(make_pair(wa1,val1));
            }
            if(nokori2A>0){
                que.push(make_pair(wa2,val2));
            }

        }else{
            //Aの残りの選択肢を追加
            for(auto itr=mpA.begin();itr!=mpA.end();itr++){
                if(itr->first==val1) continue;
                REP(j,itr->second){
                    listA.push(itr->first);
                }
            }

            REP(j,nokori1B){
                ll val2=listA.front();
                listA.pop();
                pair_AB.push(make_pair(val2,val1));
                mpA[val2]--;
                mpB[val1]--;
            }

            REP(j,mpA[val1]){
                listA.push(val1);
            }
        }
    }

    if(listA.empty()){
        //Aの残りの選択肢を追加
        for(auto itr=mpA.begin();itr!=mpA.end();itr++){
            REP(j,itr->second){
                listA.push(itr->first);
            }
        }
    }

    //最後にBとAのペア作成
    for(auto itr=mpB.begin();itr!=mpB.end();itr++){
        REP(j,itr->second){
            listA.push(itr->first);
            ll val2=listA.front();
            listA.pop();
            pair_AB.push(make_pair(val2,itr->first));
        }
    }
    
    cout<<"Yes"<<endl;
    while(!pair_AB.empty()){
        pll tmp=pair_AB.top();
        pair_AB.pop();
        cout<<tmp.second;
        if(pair_AB.empty()){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
}

Measured memory_bytes: 53980