#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
const long long mod = 1e17 + 7;
void unify(vector<long long>& v) {
  auto ip = unique(v.begin(), v.end());
  v.resize(distance(v.begin(), ip));
}
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
bool isPower2(long long x) { return x && (!(x & (x - 1))); }
const int N = 1005;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  int cnt[N] = {0};
  for (auto& x : a) cin >> x;
  for (auto& x : b) cin >> x;
  for (int i = 0; i < n; i++) cnt[a[i]]++;
  int zero = -1, two = -1;
  for (int i = 1; i <= n && (zero == -1 || two == -1); i++) {
    if (!cnt[i]) zero = i;
    if (cnt[i] > 1) two = i;
  }
  vector<int> p(n);
  for (int i = 0; i < n; i++) p[i] = a[i];
  for (int i = 0; i < n; i++) {
    if (p[i] == two) {
      p[i] = zero;
      int cnt_diff = 0;
      for (int j = 0; j < n; j++) {
        if (p[j] != b[j]) cnt_diff++;
      }
      if (cnt_diff == 1) {
        for (auto x : p) cout << x << " ";
        cout << endl;
        return;
      }
      p[i] = two;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
}
