//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int n;

void try1(vector <int> a, vector <int> b) {
    vector <vector <int>> idxs(n + 1);
    forn (i, 0, n) {
        idxs[a[i]].pb(i);
    }
    set <int> free;
    forn (i, 0, n)
        free.insert(i);
    vector <int> used(n, -1);
    forn (i, 0, n) {
        for (int j : idxs[b[i]])
            if (used[j] == -1)
                free.erase(j);

        int k = i;
        while (b[i] == b[k])
            ++k;

        forn (j, 0, k - i) {
            if (free.empty())
                return;
            else {
                used[*free.rbegin()] = b[i];
                free.erase(*free.rbegin());
            }
        }

        for (int j : idxs[b[i]])
            if (used[j] == -1)
                free.insert(j);

        i = k - 1;
    }
    cout << "Yes\n" << used;
    exit(0);
}

void try2(vector <int> a, vector <int> b) {
    vector <vector <int>> idxs(n + 1);
    forn (i, 0, n) {
        idxs[a[i]].pb(i);
    }
    set <int> free;
    forn (i, 0, n)
        free.insert(i);
    vector <int> used(n, -1);
    forn (i, 0, n) {
        for (int j : idxs[b[i]])
            if (used[j] == -1)
                free.erase(j);

        int k = i;
        while (b[i] == b[k])
            ++k;

        forn (j, 0, k - i) {
            if (free.empty())
                return;
            else {
                used[*free.begin()] = b[i];
                free.erase(*free.begin());
            }
        }

        for (int j : idxs[b[i]])
            if (used[j] == -1)
                free.insert(j);

        i = k - 1;
    }
    cout << "Yes\n" << used;
    exit(0);
}

void try3(vector <int> a, vector <int> b) {
    vector <int> ans(n);
    forn (i, 0, n)
        ans[i] = b[(i + n / 2) % n];
    forn (i, 0, n)
        if (ans[i] == a[i])
            return;
    cout << "Yes\n" << ans;
    exit(0);
}

void try4(vector <int> a, vector <int> b) {
    vector <int> ans(n);
    forn (i, 0, n)
        ans[i] = b[(i + (n + 1) / 2) % n];
    forn (i, 0, n) 
        if (ans[i] == a[i])
            return;
    cout << "Yes\n" << ans;
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    vector <int> a(n), b(n);
    cin >> a >> b;
    try1(a, b);
    try2(a, b);
    try3(a, b);
    try4(a, b);
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 27896