#include <bits/stdc++.h>
using namespace std;
using Int = long long;
signed main() {
  Int n;
  cin >> n;
  vector<Int> a(n), b(n);
  for (Int i = 0; i < n; i++) cin >> a[i];
  for (Int i = 0; i < n; i++) cin >> b[i];
  vector<Int> r(n + 1);
  for (Int i = 0; i < n; i++) r[a[i]] = i;
  set<Int> s;
  for (Int i = 0; i < n; i++) s.emplace(b[i]);
  if ((Int)s.size() == n) {
    cout << "Yes" << endl;
    return 0;
  }
  Int p = 1;
  while (s.count(p)) p++;
  cout << "No" << endl;
  for (Int i = 0; i < n; i++) {
    if (i) cout << " ";
    if (i == r[p])
      cout << 1;
    else
      cout << i + 1;
  }
  cout << endl;
  for (Int i = 0; i < n; i++) {
    if (i) cout << " ";
    if (i == r[p])
      cout << 2;
    else
      cout << i + 1;
  }
  cout << endl;
  return 0;
}
