#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define inf 9000000000000000000
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define PI 3.14159265359
#define endl '\n'
#define itn int
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
typedef priority_queue<pair<pll,pll>,vector<pair<pll,pll> >,greater<pair<pll,pll> > > pqset;
typedef priority_queue<pll,vector<pll>,greater<pll> > pqset_ll;
#define pb push_back
#define pf push_front
#define fi first
#define mkp make_pair
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define repeat(i,start,n) for(ll i=(ll)start;i<(ll)n;i++)
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);}
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll power(ll a,ll b){
	if(a==1||b==0)	return 1;
	ll c=power(a,b/2);
	ll res=1;
	res=c*c;
	if(res>=mod)	res%=mod;
	if(b%2)	res*=a;
	if(res>=mod)	res%=mod;
	return res;
}
ll power(ll a,ll b,ll mod1){
	if(a==1||b==0)	return 1;
	ll c=power(a,b/2,mod1);
	ll res=1;
	res=c*c;
	if(res>=mod1)	res%=mod1;
	if(b%2)	res*=a;
	if(res>=mod1)	res%=mod1;
	return res;
}
ll modInv(ll a){
	return power(a,mod-2);
}
ll fact[1],inv[1];
void factorial(ll n){
	fact[0]=1;
	for(ll i=1;i<=n;i++){
		fact[i]=fact[i-1]*i;
		if(fact[i]>=mod)	fact[i]%=mod;
	}
}
void InvFactorial(ll n){
	inv[0]=1;
	for(ll i=1;i<=n;i++)	inv[i]=modInv(fact[i]);
}
ll ncr(ll n,ll r){
	if(n<r||n<0||r<0)	return 0;
	ll b=inv[n-r];
	ll c=inv[r];
	ll a=fact[n]*b;
	if(a>=mod)	a%=mod;
	a*=c;
	if(a>=mod)	a%=mod;
	return a;
}
bool prime[1];
vector<ll> primes;
void remove_duplicates(vector<pair<int,pint> > &v){
	sort(v.begin(),v.end());
	int _size=unique(v.begin(),v.end())-v.begin();
	v.resize(_size);
}
unsigned int gcd(unsigned int u, unsigned int v){
    if(u==0||v==0) return max(u,v);
    unsigned int shift=__builtin_ctz(u|v);
	u>>=__builtin_ctz(u);
    do{
    	v>>=__builtin_ctz(v);
    	if(u>v)	swap(u,v);
    	v-=u;
    }while(v!=0);
    return u<<shift;
}
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false;
    for(ll p=2;p*p<=n;p++)	if(prime[p])	for(ll i=p*p;i<=n;i+=p)	prime[i]=false;
    repeat(i,2,n+1)	if(prime[i])	primes.pb(i);
}
struct custom_hash{// Credits: https://codeforces.com/blog/entry/62393
    static uint64_t splitmix64(uint64_t x){
        // http://xorshift.di.unimi.it/splitmix64.c
        x+=0x9e3779b97f4a7c15;
    	x=(x^(x>>30))*0xbf58476d1ce4e5b9;
        x=(x^(x>>27))*0x94d049bb133111eb;
        return x^(x>>31);
    }
    size_t operator()(uint64_t x)const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x+FIXED_RANDOM);
    }
    size_t operator()(pair<int64_t,int64_t> Y) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(Y.first*31+Y.second+FIXED_RANDOM);
    }
};
//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
//Use (<<) for multiplication
//Use (>>) for division
// find_by_order -> value at index
// order_of_key -> index of value
// in Floyd-Warshall Algo, k is outer loop
//__gcd(0,0) gives runtime error
//power(a,b) == power(a,b%phi(a)) Fermet's Theorem
//never use "=" operator in compare function
//For checking odd cycles, check bipartite
//Range in iterative segment tree [a,b)
// no of prime numbers in range : (70,19) , (1000,168) , (100000,1229) , (sqrt(10^9),3409) ;
void solve(){
	int n;
	cin>>n;
	int a[n],b[n];
	rep(i,n)	cin>>a[i];
	rep(i,n)	cin>>b[i];
	map<int,int> mp;
	rep(i,n)	mp[b[i]]++;
	vector<int> v[n+1];
	set<int> s;
	rep(i,n){
		if(mp.count(a[i])){
			mp[a[i]]--;
			if(mp[a[i]]==0)	mp.erase(a[i]);
			v[a[i]].pb(i);
			s.insert(a[i]);
		}
	}
	int it[n+1]={0};
	vector<int> ans(n,-1);
	itn same=0;
	vector<int> v1;
	while(s.size()>0){
		deque<int> temp;
		vector<int> temp1;
		auto it1=s.begin();
		while(it1!=s.end()){
			int i=(*it1);
			temp.pb(v[i][it[i]]);
			temp1.pb(v[i][it[i]]);
			it[i]++;
			if(it[i]==v[i].size())	s.erase(it1++);
			else	it1++;
		}
		if(temp.size()==1){
			if(mp.size()==0){
				ans[temp1[0]]=a[temp1[0]];
				same++;
				continue;
			}
			v1.pb(a[temp1[0]]);
			int u=(mp.begin())->fi;
			ans[temp1[0]]=u;
			mp[u]--;
			if(mp[u]==0)	mp.erase(u);
			continue;
		}
		int u=temp.back();
		temp.pop_back();
		temp.push_front(u);
		int i=0;
		while(!temp.empty()){
			ans[temp1[i]]=a[temp.front()];
			temp.pop_front();
			i++;
		}
	}
	int j=0;
	rep(i,ans.size()){
		if(ans[i]==-1){
			if(mp.size()==0){
				ans[i]=v1[j];
				j++;
				continue;
			}
			int u=(mp.begin())->fi;
			ans[i]=u;
			mp[u]--;
			if(mp[u]==0)	mp.erase(u);
		}
	}
	if(same>n/2){
		cout1("No");
		return;
	}
	rep(i,n){
		if(ans[i]==a[i])	s.insert(a[i]);
	}
	if(s.size()==0){
		cout1("Yes");
		rep	(i,ans.size())	cout<<ans[i]<<' ';
		cout<<endl;
		return;
	}
	v1.clear();
	rep(i,n){
		if(ans[i]!=(*s.begin())&&a[i]!=(*s.begin())){
			v1.pb(i);
		}
	}
	j=0;
	rep(i,n){
		if(a[i]==ans[i]){
			if(j==v1.size()){
				cout1("No");
				return;
			}
			swap(ans[v1[j]],ans[i]);
			j++;
		}
	}
	cout1("Yes");
	rep(i,ans.size())	cout<<ans[i]<<' ';
	cout<<endl;
}
int main(){
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	cin.tie(NULL);cout.tie(NULL);cin.sync_with_stdio(0);cout.sync_with_stdio(0);cout<<fixed;
	srand(time(0));
	//cout.precision(9);
	int t=1;
	//cin>>t;
	int countu=1;
	for(int i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 26580