#include <bits/stdc++.h>

using namespace std;


signed main(){
    int N;cin >> N;
    vector<int> a, b;
    set<int> se;
    for(int i = 0;i < N;i++){
        int c;cin >> c;
        a.push_back(c-1);
    }
    for(int i = 0;i < N;i++){
        int c;cin >> c;
        b.push_back(c-1);
        se.insert(c-1);
    }
    if(se.size() == N){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    vector<int> g(N, 1),h(N, 1);
    for(int i = 0;i < N;i++){
        if(se.find(a.at(i)) == se.end()){
            g.at(i) = 1;
            h.at(i) = 2;
        }
    }
    for(int i = 0;i < N;i++){
        cout<<g.at(i)<<(i != N-1 ? " " : "");
    }
    cout<<endl;
    for(int i = 0;i < N;i++){
        cout<<h.at(i)<<(i != N-1 ? " ": "");
    }
    cout<<endl;
}

