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

#define pb push_back
#define loop(i,l,r) for(int i = (l); i < (r); i++)
#define rloop(i,r,l) for(int i = (r-1); i >= (l); i--)
#define refloop(x, v) for(auto& x : (v))
#define exists(m,e) if((m).find(e) != (m).end())
#define nexists(m,e) if((m).find(e) == (m).end())
#define sortaka(v) sort((v).begin(), (v).end())
#define rsort(v) sort((v).rbegin(), (v).rend())
#define lower_bound_index(v, x) (lower_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] >= x
#define upper_bound_index(v, x) (upper_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] > x
#define scanint(x) scanf("%d", &(x))
#define scanfloat(x) scanf("%f", &(x))
#define scanll(x) scanf("%lld", &(x))
#define scanchar(x) scanf("%c", &(x))
#define scanstring(x) scanf("%s", &(x))
#define printint(x) printf("%d", x)
#define printfloat(x) printf("%.9f", x)
#define printll(x) printf("%lld", x)
#define printchar(x) printf("%c", x)
#define printstring(x) printf("%s", x)
#define printintnewline(x) printf("%d\n", x)
#define printfloatnewline(x) printf("%.9f\n", x)
#define printllnewline(x) printf("%lld\n", x)
#define printcharnewline(x) printf("%c\n", x)
#define printstringnewline(x) printf("%s\n", x)
#define square(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))

typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef vector<string> vs;
typedef vector<vector<pair<int, int>>> vvpii;
typedef vector<vector<pair<long long, long long>>> vvpll;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);

    int n; cin >> n;
    vi a(n), b(n);

    mii ma, mb;

    loop(i, 0, n){
        cin >> a[i];
        exists(ma,a[i])ma[a[i]]++;
        else ma[a[i]] = 1;
    }
    loop(i, 0, n){
        cin >> b[i];
        exists(mb,b[i])mb[b[i]]++;
        else mb[b[i]] = 1;
    }

    bool pos = true;
    for(auto it: ma){
        if(it.second+mb[it.first] > n){
            pos=false;
            break;
        }
    }

    if(!pos){
        cout<<"No\n";
    }else{
        cout<<"Yes\n";
        rsort(b);
        int ind = 0;
        while(ind < n && a[ind] != b[ind]){
            ind++;
        }

        if(ind == n){
            loop(i, 0, n){
                cout<<b[i]<<" ";
            }
            cout<<endl;
        }else{
            int eq = a[ind];
            int s = ind, t = ind;
            while(t < n && a[t] == b[t]){
                t++;
            }
            t--;

            int numrem = t-s+1;
            for(int i = 0; b[i] != eq && a[i] != eq && i < s && numrem > 0; i++){
                int temp = b[i];
                b[i] = eq;
                b[t+1-numrem] = temp;
                numrem--;
            }
            for(int i = n-1; b[i] != eq && a[i] != eq && i > t && numrem > 0; i--){
                int temp = b[i];
                b[i] = eq;
                b[t+1-numrem] = temp;
                numrem--;
            }

            assert(numrem == 0);

            loop(i, 0, n){
                cout<<b[i]<<" ";
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 23536