#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v, v2, vis(n, 0);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v2.push_back(x);
    }
    reverse(v2.begin(), v2.end());
    int j = 0;
    vector<int>cur;
    for(int i = 0; i < n; i++){
        while(j < n && v2[j] == v[i]){
            j++;
        }
        if(j < n){
            cur.push_back(v2[j]);
            vis[j] = 1;
            j++;
        }
    }
    for(int i = 0; i < n; i++){
        if(vis[i] == 0){
            cur.push_back(v2[i]);
        }
    }
    int y = 1;
    for(int i = 0; i < n; i++){
        if(v[i] == cur[i]){
            y = 0;
        }
    }
    if(y == 1){
        cout << "Yes\n";
        for(int i = 0; i < n; i++){
            cout << cur[i] << ' ';
        }
        return 0;
    }
    reverse(v2.begin(), v2.end());
    multiset<int>st;
    for(int i = 0; i < n; i++){
        st.insert(v2[i]);
    }
    int x = 1;
    for(int i = 0; i < n; i++){
        if(v[i] == v2[i]){
            x = 0;
        }
    }
    if(x == 1){
        cout << "Yes\n";
        for(int i = 0; i < n; i++){
            cout << v2[i] << ' ';
        }
        return 0;
    }
    int k = 1;
    vector<int>ans;
    for(int i = 0; i < n; i++){
        multiset<int>::iterator it = st.upper_bound(v[i]);
        if(it == st.end()){
            it = st.begin();
        }
        ans.push_back(*it);
        st.erase(it);
    }
    for(int i = 0; i < n; i++){
        if(ans[i] == v[i]){
            k = 0;
        }
    }
    int r = 1;
    if(k == 1){
        cout << "Yes\n";
        for(int i = 0; i < n; i++){
            cout << ans[i] << ' ';
        }
    }
    else{
        vector<int>cnt(n + 3, 0);
        for(int i = 0; i < n; i++){
            cnt[v2[i]]++;
        }
        int p = -1, mx = 0;
        for(int i = 1; i <= n; i++){
            if(cnt[i] > mx){
                mx = cnt[i];
                p = i;
            }
        }
        int idx = -1;
        for(int i = 0; i < n; i++){
            if(v2[i] == p && idx == -1){
                idx = i;
            }
            v2.push_back(v2[i]);
        }
        vector<int>ans2;
        for(int i = idx; i < idx + n; i++){
            ans2.push_back(v2[i]);
        }
        int r = 1;
        for(int i = 0; i < n; i++){
            if(v[i] == ans2[i]){
                r = 0;
            }
        }
        if(r == 1){
            cout << "Yes\n";
            for(int i = 0; i < n; i++){
                cout << ans2[i] << ' ';
            }
        }
        else{
            for(int i = 0; i < n; i++){
                v2.push_back(v2[i]);
            }
            int idx2 = -1;
            for(int i = 0; i < n; i++){
                if(v2[i] == v2[n - 1] && idx2 == -1){
                    idx2 = i;
                }
                v2.push_back(v2[i]);
            }
            vector<int>res;
            for(int i = idx2; i < idx2 + n; i++){
                res.push_back(v2[i]);
            }
            int p2 = 1;
            for(int i = 0; i < n; i++){
                if(res[i] == v[i]){
                    p2 = 0;
                }
            }
            if(p2 == 1){
                cout << "Yes\n";
                for(int i = 0; i < n; i++){
                    cout << res[i] << ' ';
                }
            }
            else{
                int b = 1;
                vector<int>vx;
                for(int i = n/2; i < n; i++){
                    vx.push_back(v2[i]);
                }
                for(int i = 0; i < n/2; i++){
                    vx.push_back(v2[i]);
                }
                for(int i = 0; i < n; i++){
                    if(v[i] == vx[i]){
                        b = 0;
                    }
                }
                if(b == 1){
                    for(int i = 0; i < n; i++){
                        cout << vx[i] << ' ';
                    }
                }
                else{
                    reverse(v2.begin(), v2.end());
                    int a = 1;
                    for(int i = 0; i < n; i++){
                        if(v[i] == v2[i]){
                            a = 0;
                        }
                    }
                    if(a == 1){
                        cout << "Yes\n";
                    }
                    else{
                        cout << "No\n";
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 15840