/*
   Username : moondancer
   Name : Moon Dancer
*/


#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n==1){
        int x,y;
        cin>>x>>y;
        if(x!=y) cout<<"Yes\n"<<y;
        else cout<<"No\n";
        return 0;
    }
    int a[n];
    for(int i=0; i<n; ++i){
        cin>>a[i];
    }
    int c[n+1]={};
    int b[10*n];
    int bb[10*n];
    multiset<int> ss;
    for(int i=0; i<n; ++i){
        cin>>b[i];
        bb[i]=b[i];
        bb[i+n]=b[i+n]=b[i];
        bb[i+2*n]=b[i+2*n]=b[i];
        bb[i+3*n]=b[i+3*n]=b[i];
        bb[i+4*n]=b[i+4*n]=b[i];
        bb[i+5*n]=b[i+5*n]=b[i];
        bb[i+6*n]=b[i+6*n]=b[i];
        bb[i+7*n]=b[i+7*n]=b[i];
        bb[i+8*n]=b[i+8*n]=b[i];
        bb[i+9*n]=b[i+9*n]=b[i];
        c[b[i]]++;
        ss.insert(b[i]);
    }
    bool f=1;
    int ans[n];
    memset(ans,-1,sizeof(ans));
    set<pair<int,int>> s;
    for(int i=1; i<=n; ++i){
        if(c[i])
            s.insert({c[i], -i});
    }
    for(int i=0; i<n; ++i){
        if(s.empty()){
            f=0;
            break;
            // cout<<"No\n";
            // return 0;
        }
        auto it=s.begin();
        int y=-it->second;
        if(y== a[i]){
            it++;
            if(it==s.end()){
                f=0;
                break;
                // cout<<"No\n";
                // return 0;
            }
        }
        y=-it->second;
        // cout<<y<<"\n";
        // cout<<c[y]<<" "<<y<<" ";
        s.erase(it);
        c[y]--;
        if(c[y])
            s.insert({c[y], -y});
        // cout<<c[y]<<" "<<y<<"\n";
        ans[i] = y;
    }
    if(f==0){
        int l=0;
        for(int i=0; i<n; ++i){
            while(l<10*n && (b[l] == a[i] || b[l] == -1))
                l++;
            if(l==10*n) break;
            if(b[l] != a[i] && b[l] != -1){
                ans[i]=b[l];
                int x=l%n;
                b[x]=b[x+n]=b[x+2*n]=b[x+3*n]=b[x+4*n]=-1;
                b[x+5*n]=b[x+6*n]=b[x+7*n]=b[x+8*n]=b[x+9*n]=-1;
                l++;
            }
            else
                break;
        }
        bool f=1;
        for(int i=0; i<n; ++i){
            if(ans[i] == -1){
                f=0;
                break;
                // cout<<"No";
                // return 0;
            }
        }
        if(f==0){
            bool f=1;
            for(int i=0; i<n; ++i){
                auto it=ss.upper_bound(a[i]);
                if(it == ss.end())
                    it=ss.begin();
                int x=*it;
                ss.erase(it);
                if(a[i] != x)
                    ans[i]=x;
                else{
                    f=0;
                    break;
                }
            }
            if(f==0){
                int l=10*n-1;
                for(int i=0; i<n; ++i){
                    while(l>=0 && (bb[l] == a[i] || bb[l] == -1))
                        l--;
                    if(l==-1) break;
                    if(bb[l] != a[i] && bb[l] != -1){
                        ans[i]=bb[l];
                        int x=l%n;
                        bb[x]=bb[x+n]=bb[x+2*n]=bb[x+3*n]=bb[x+4*n]=-1;
                        bb[x+5*n]=bb[x+6*n]=bb[x+7*n]=bb[x+8*n]=bb[x+9*n]=-1;
                        l--;
                    }
                    else
                        break;
                }
                for(int i=0; i<n; ++i){
                    if(ans[i] == -1){
                        cout<<"No";
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"Yes\n";
    for(int i=0; i<n; ++i)
        cout<<ans[i]<<" ";
    return 0;
}


Measured memory_bytes: 61424