#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n), b(n);
  for (auto &it : a) cin >> it;
  for (auto &it : b) cin >> it;
  vector<long long int> v(n, 0);
  for (long long int i = 0; i < n; i++) {
    if (a[i] == b[i]) v[i] = a[i];
  }
  long long int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    if (v[i] == 0) cnt++;
  }
  set<long long int> s;
  for (long long int i = 0; i < n; i++) {
    s.insert(v[i]);
  }
  if (cnt == 1) {
    long long int x = 0;
    for (long long int i = 1; i <= n; i++) {
      if (s.find(i) == s.end()) {
        x = i;
        break;
      }
    }
    for (long long int i = 0; i < n; i++) {
      if (v[i] == 0) {
        v[i] = x;
        break;
      }
    }
    for (long long int i = 0; i < n; i++) cout << v[i] << " ";
    cout << "\n";
    return;
  }
  if (cnt == 2) {
    for (long long int i = 0; i < n; i++) {
      if (v[i] == 0) {
        if (s.find(a[i]) != s.end() || s.find(b[i]) != s.end()) {
          if (s.find(a[i]) == s.end()) {
            v[i] = a[i];
            s.insert(v[i]);
          } else {
            v[i] = b[i];
            s.insert(v[i]);
          }
        }
      }
    }
    for (long long int i = 0; i < n; i++) {
      if (v[i] == 0) {
        if (s.find(a[i]) == s.end()) {
          v[i] = a[i];
          s.insert(v[i]);
        } else if (s.find(b[i]) == s.end()) {
          v[i] = b[i];
          s.insert(v[i]);
        }
      }
    }
    for (long long int i = 0; i < n; i++) cout << v[i] << " ";
    cout << "\n";
    return;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
