#include <bits/stdc++.h>
using namespace std;
long long n, a[1100], b[1100], p[1100];
string s;
map<long long, long long> mp;
vector<long long> v;
bool u[1100], ua, ub;
char c;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (a[i] == b[i]) p[i] = a[i], u[a[i]] = true;
  }
  for (int i = 0; i < n; i++)
    if (!p[i]) {
      if (u[a[i]] && u[b[i]]) {
        for (int j = 1; j <= n; j++)
          if (!u[j]) p[i] = j, u[j] = true;
      } else if (u[a[i]])
        p[i] = b[i], ua = true;
      else if (u[b[i]])
        p[i] = a[i], ub = true;
    }
  for (int i = 0; i < n; i++)
    if (!p[i]) {
      if (ua)
        p[i] = a[i];
      else if (ub)
        p[i] = b[i];
      else
        p[i] = a[i], ub = true;
    }
  for (int i = 0; i < n; i++) cout << p[i] << " ";
  cout << endl;
  return 0;
}
