import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){
}
void jury(){
}
struct S{ long index; long value; }
void solve(){
    int n = scan!int;

    long[] as = scan!long(n);
    long[] bs = scan!long(n);
    log("as:", as);
    log("bs:", bs);

    // A、B 合わせての出現回数
    int[long] cnt;
    foreach(a; as){
        if(a !in cnt) cnt[a] = 0;
        cnt[a] += 1;
    }
    foreach(b; bs){
        if(b !in cnt) cnt[b] = 0;
        cnt[b] += 1;
    }
    log("cnt:", cnt);

    // 出現回数が多いものからソートし直す
    S[] us, vs;
    foreach(i, a; as) us ~= S(i, a);
    foreach(i, b; bs) vs ~= S(i, b);

    us.sort!((a, b) => (a.value != b.value) ? (cnt[a.value] > cnt[b.value]) : (a.index < b.index))();
    vs.sort!((a, b) => (a.value != b.value) ? (cnt[a.value] > cnt[b.value]) : (a.index < b.index))();
    log("us:", us);
    log("vs:", vs);

    // ２周して答えを作る
    S[] ws = new S[](n);
    int i = 0;
    foreach(j; 0 .. n){
        if(us[j].value != vs[i].value) ws[j] = vs[i], i += 1;
    }
    foreach(j; 0 .. n){
        if(ws[j].value == 0) ws[j] = vs[i], i += 1;
    }
    log("ws:", ws);

    // ソートしたのをもとに戻す
    long[] ans = new long[](n);
    foreach(j; 0 .. n){
        ans[us[j].index] = ws[j].value;
    }
    log("ans:", ans);

    // できていなければNo
    foreach(j; 0 .. n){
        if(as[j] == ans[j]){
            "No".print;
            return;
        }
    }

    // できていた
    "Yes".print;
    ans.unsplit.print;
    
}
/*
A = 1 1 1 1 1 2 2 2 3 3 3 4 4 4 5 5 7
B = 1 1 1 2 2 3 3 4 4 5 6 6 6 7 8 8 9 
    だったら
１周目で
A = 1 1 1 1 1 2 2 2 3 3 3 4 4 4 5 5 7 
C = 0 0 0 0 0 1 1 1 2 2 0 3 3 0 4 4 5
みたいな感じにして
２周目で続きを埋める
C = 6 6 6 7 8 1 1 1 2 2 8 3 3 9 4 4 5

*/
