//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
using namespace std;
const int N   = 3e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,n) for (int i=1;i<=n;++i)
#define repp(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,a[N],b[N],c[N],d[N];
signed main()
{
	read(n);
	rep(i,n)  read(a[i]),++c[a[i]];
	rep(i,n) read(b[i]),++d[b[i]];
	reverse(b+1,b+1+n);
	rep(i,n ) if (c[i]+d[i]>n) 
	{
		printf("No");
		return 0;
	}
	int l=n,r=1;
	rep(i,n) if (a[i]==b[i])  l=min(l,i),r=max(r,i);
	int pos=l;
	for (int i=1;i<l&&pos<=r;++i) if (b[i]!=a[l]&&a[i]!=a[l]) swap(b[i],b[pos]),++pos;
	for (int i=r+1;i<=n&&pos<=r;++i) if (b[i]!=a[l]&&a[i]!=a[l]) swap(b[i],b[pos]),++pos;

	printf("Yes\n");
	rep(i,n) printf("%d ",b[i]);
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

// KMP
template <class T>
std::vector<int> KMP(T& S)
{
    std::vector<int> A(S.size()+1);
    A[0] = -1;
    int j = -1;

    for(int i=0; i<S.size(); i++){
        while(j > -1 && S[j] != S[i]) j = A[j];
        j++;
        A[i+1] = j;
    }

    return A;
}

// detect T from S
template <class Type>
std::vector<int> matchedIndex(Type& S, Type& T)
{
    std::vector<int> ret;
    std::vector<int> A = KMP(T);

    for(int m = 0, i = 0; m + T.size() <= S.size();){
        while(m+i < S.size() && i < T.size() && S[m+i] == T[i]) i++;
        if(i == T.size()) ret.push_back(m);
        m += std::max(i - A[i], 1);
        i = std::max(A[i], 0);
    }

    return ret;
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for(auto& x: a) cin >> x;
    for(auto& x: b) cin >> x;
    a.push_back(a[0]);
    b.push_back(b[0]);
    
    vector<int> c(N), d(2*N);
    for(int i=0; i<N; i++){
        c[i] = a[i] ^ a[i+1];
        d[i] = b[i] ^ b[i+1];
        d[N+i] = d[i];
    }
    d.pop_back();

    vector<int> index = matchedIndex(d, c);
    for(auto& k: index){
        k = (N-k)%N;
    }
    sort(index.begin(), index.end());

    for(auto& k: index){
        cout << k << " " << (a[k] ^ b[0]) << endl;
    }
}