#include <bits/stdc++.h>
using namespace std;
long long int ar[2005];
long long int br[2005];
long long int mp[2005];
long long int cr[2005];
long long int n;
void input() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ar[i], mp[ar[i]]++;
  for (int i = 1; i <= n; i++) cin >> br[i];
}
bool work() {
  int cur, x;
  for (int i = 1; i <= n; i++) {
    if (mp[i] == 2) cur = i;
    if (!mp[i]) x = i;
  }
  for (int i = 1; i <= n; i++) {
    if (ar[i] == cur) {
      memcpy(cr, ar, sizeof cr);
      cr[i] = x;
      int a = 0, b = 0;
      for (int j = 1; j <= n; j++) {
        a += (ar[j] != cr[j]);
        b += (br[j] != cr[j]);
      }
      if (a == 1 && b == 1) {
        for (int j = 1; j <= n; j++) {
          cout << cr[j] << ' ';
        }
        cout << '\n';
        exit(0);
      }
    }
  }
}
int main() {
  input();
  work();
  return 0;
}
