#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	vi a(n);
	for(int& x : a)cin >> x;
	
	vi b(n);
	for(int& x : b)cin >> x;
	
	reverse(all(b));
	
	int l=0, r=n-1;
	for(int i=0 ; i<n ; ++i){
		if(a[i] == b[i]){
			if(a[l] != b[i] && b[l] != b[i]){
				swap(b[i], b[l]);
				++l;
			}
			else if(a[r] != b[i] && b[r] != b[i]){
				swap(b[i], b[r]);
				--r;
			}
			else{
				cout << "No\n";
				return;
			}
		}
	}
	
	for(int i=0 ; i<n ; ++i){
		if(a[i] == b[i]){
			cout << "No\n";
			return;
		}
	}
	
	cout << "Yes\n";
	for(int& x : b)cout << x << " ";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}

#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        --A[i];
    }
    vector<int> B(n);
    for (int i = 0; i < n; ++i) {
        cin >> B[i];
        --B[i];
    }

    const int INF = 1 << 24;
    vector<pair<int,int>> rangesA(n, make_pair(INF, -INF));
    vector<pair<int,int>> rangesB(n, make_pair(INF, -INF));

    for (int i = 0; i < n; ++i) {
        int l = i;
        int x = A[i];
        while (i + 1 < n && A[i + 1] == x) {
            ++i;
        }
        int r = i;
        rangesA[x] = make_pair(l, r);
    }
    for (int i = 0; i < n; ++i) {
        int l = i;
        int x = B[i];
        while (i + 1 < n && B[i + 1] == x) {
            ++i;
        }
        int r = i;
        rangesB[x] = make_pair(l, r);
    }

    bool ok = true;
    for (int i = 0; i < n; ++i) {
        int cntA = rangesA[i].second - rangesA[i].first + 1;
        int cntB = rangesB[i].second - rangesB[i].first + 1;
        if (cntA > 0 && cntB > 0 && cntA > n - cntB) {
            ok = false;
            break;
        }
    }

    if (!ok) {
        cout << "No\n";
        return 0;
    }


    vector<int> cnts(2 * n + 1, 0);

    for (int i = 0; i < n; ++i) {
        int la = rangesA[i].first, ra = rangesA[i].second;
        int lb = rangesB[i].first, rb = rangesB[i].second;
        if (la >= n || lb >= n) {
            continue;
        }

        int r = ra - lb;
        if (r < 0) {
            r += n;
        }
        int l = (la - (rb - lb)) - lb;
        while (l < 0) {
            l += n;
        }
        while (l > r) {
            r += n;
        }
        // cout << i << " : " << l << " - " << r << endl;
        cnts[l] += 1;
        cnts[r + 1] -= 1;
    }
    for (int i = 1; i < cnts.size(); ++i) {
        cnts[i] += cnts[i - 1];
    }

    int offset = -1;
    for (int i = 0; i < n; ++i) {
        if (cnts[i] + cnts[i + n]== 0) {
            offset = i;
            break;
        }
    }

    vector<int> res(n, 0);
    for (int i = 0; i < n; ++i) {
        res[i] = (B[(i - offset + n) % n]);
    }


    cout << "Yes\n";
    for (int i = 0; i < n; ++i) {
        cout << res[i] + 1 << (i == n - 1 ? '\n' : ' '); 
    }
    return 0;
}