#include <bits/stdc++.h>
using namespace std;

#define R (long long)(1e9 + 7)
#define INF (long long)(1e16L + 5)
#define ll long long
#define grid vector<vector<ll>>
#define L 26

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

struct maths_util
{
    vector<long long> fact;
    vector<bool> is_prime;
    maths_util(int n = 200001, long long q = R)
    {
        fact.resize(n);
        is_prime.assign(n + 1, true);

        fact[0] = 1;
        for(int i = 1; i < n; i++)
            fact[i] = (fact[i-1] * i) % q;

        is_prime[0] = is_prime[1] = false;
        for(int i = 2; i <= n; i++)
            if(is_prime[i])
                for(int j = i + i; j <= n; j += i)
                    is_prime[j] = false;
    }
    long long power_mod_q(long long x, long long n, long long q = R)
    {
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return power_mod_q((x * x) % q, n / 2, q);
        else 
            return (x * power_mod_q((x * x) % q, n / 2, q)) % q; 
    }

    long long inverse_mod_q(long long n, long long q = R)
    {
        return power_mod_q(n, q-2, q);
    }

    long long nCr_mod_q(long long n, long long r, long long q = R)
    {
        return (((fact[n] * inverse_mod_q(fact[r], q)) % q) * inverse_mod_q(fact[n-r], q)) % q;
    }

    long long power(long long x, long long n)
    {
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return power(x * x, n / 2);
        else 
            return x * power(x * x, n / 2); 
    }

    grid multiply(grid& a, grid& b)
    {
        int p = a.size(), q = b.size(), r = b[0].size();
        grid c(p, vector<long long>(r, 0));
        for(int i = 0; i < p; i++)
            for(int j = 0; j < r; j++)
                for(int k = 0; k < q; k++)
                    c[i][j] += a[i][k] * b[k][j];
        return c;
    }

    grid add(grid& a, grid& b)
    {
        int p = a.size(), q = a[0].size();
        grid c(p, vector<long long>(q));
        for(int i = 0; i < p; i++)
            for(int j = 0; j < q; j++)
                c[i][j] = a[i][j] + b[i][j];
        return c;
    }

    grid power(grid& a, long long n)
    {
        grid c(a.size(), vector<long long>(a.size(), 0));
        if(n == 0)
        {
            for(int i = 0; i < (int)a.size(); i++)
                c[i][i] = 1;
            return c;
        }
        if(n % 2 == 0)
            return power(c = multiply(a, a), n / 2);
        else
            return multiply(a, c = power(c = multiply(a, a), n / 2));
        
    }
};

struct graph
{
    int n;
    vector<vector<pair<int, int>>> adj;
    graph(int n)
    {
        this -> n = n;
        adj.resize(n);
    }
    
    void add_edge(int u, int v, int w)
    {
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    map<int, int> f;
    for(int& x : a)
        cin >> x, f[x]++;
    for(int& y : b)
        cin >> y, f[y]++;
    bool flag = true;
    
    for(auto x: f)
    {
        if(x.second > n)
            flag = false;
    }

    if(flag)
    {
        map<int, vector<int>> mp;
        for(int i = 0; i < n; i++)   
        {
            if(b[i] == a[i])
                mp[b[i]].push_back(i);
        }


        if(mp.size() == 0)
        {
            cout << "Yes\n";
            for(auto x : b)
                cout << x << ' ';
            cout << '\n';
        }
        else
        {
            if(mp.size() == 1)
            {
                auto it = mp.begin();
                int val = it -> first;
                
                set<int> s;
                for(auto x : (it -> second))
                    s.insert(x);


                for(int i = 0; ; i = (i + 1) % n)
                {
                    if(s.size() == 0)
                        break;

                    if(s.find(i) == s.end())
                    {
                        if(b[i] != val)
                        {
                            int x = *s.begin();
                            int y = i;
                            swap(b[x], b[y]);
                            s.erase(s.begin());
                            if(a[i] == b[i])
                                s.insert(i);
                        }
                    }
                }
                
                cout << "Yes\n";
                for(auto x : b)
                    cout << x << ' ';
                cout << '\n';
            }
            else
            {
                auto i = mp.begin();
                auto j = mp.begin();
                // j++;
                while(j != mp.end())
                {
                    if(i == j)
                        j++;
                    if(j == mp.end())
                        break;
                    if((i -> second).size())
                    {
                        while((i -> second).size() && (j -> second).size())
                        {
                            int x = (i -> second).back();
                            int y = (j -> second).back();
                            swap(b[x], b[y]);
                            (i -> second).pop_back();
                            (j -> second).pop_back();
                        }
                        if((i -> second).size() == 0)
                            i++;
                        if((j -> second).size() == 0)
                            j++;
                    }
                    else
                        i++;

                    // for(auto x : mp)
                    // {
                    //     cout << x.first << " : ";
                    //     for(auto y : x.second)
                    //         cout << y << ' ';
                    //     cout << '\n';
                    // }
                }

                map<int, vector<int>> f;
                for(auto x : mp)
                {
                    if(x.second.size())
                    {
                        f.insert(x);
                    }
                }

                if(f.size() == 1)
                {
                    auto it = f.begin();
                    int val = it -> first;
                    
                    set<int> s;
                    for(auto x : (it -> second))
                        s.insert(x);

                    for(int i = 0; ; i = (i + 1) % n)
                    {
                        if(s.size() == 0)
                            break;

                        if(s.find(i) == s.end())
                        {
                            if(b[i] != val)
                            {
                                int x = *s.begin();
                                int y = i;
                                swap(b[x], b[y]);
                                s.erase(s.begin());
                                if(a[i] == b[i])
                                    s.insert(i);
                            }
                        }
                    }
                    
                    cout << "Yes\n";
                    for(auto x : b)
                        cout << x << ' ';
                    cout << '\n';
                }
                else
                {
                    cout << "Yes\n";
                    for(auto x : b)
                        cout << x << ' ';
                    cout << '\n';
                }
                
            }
        }
        
    }
    else
    {
        cout << "No\n";
    }
    
    

    // cout << "        __.....__\n";
    // cout << "     .-'         '-.\n";
    // cout << "   .'               '.\n";
    // cout << "  /                   \\\n";
    // cout << " /        |\\           \\\n";
    // cout << ";        |V \\_          ;\n";
    // cout << "|        |  ' \\         ;\n";
    // cout << ";        )   ,_\\        |\n";
    // cout << ";       /    |          ;\n";
    // cout << " \\     /      \\         /\n";
    // cout << "  \\    |       \\       /\n";
    // cout << "   '.   \\       \\    .'\n";
    // cout << "     '-._|       \\.-'\n";
    // cout << "         | |\\     |    \n";
    // cout << "_________/ |_'.   /_______  \n";
    return 0;
    
}


Measured memory_bytes: 35872