#include <bits/stdc++.h>
using namespace std;
void inputArray(int *array, int size) {
  for (int i = 0; i < size; i++) cin >> array[i];
}
void test1(int *p, int *a, int *b, int n, map<int, bool> &perfect) {
  for (int i = 0; i < n; i++)
    if (p[i] == a[i]) {
      b[i] = a[i];
      perfect[b[i]] = true;
    }
}
void test2(int *p, int *a, int *b, int n, map<int, bool> &perfect) {
  for (int i = 0; i < n; i++) {
    if (b[i] == -1) {
      if (!perfect[a[i]] && perfect[p[i]]) {
        b[i] = a[i];
        perfect[a[i]] = true;
      } else if (!perfect[p[i]] && perfect[a[i]]) {
        b[i] = p[i];
        perfect[p[i]] = true;
      }
    }
  }
}
void test3(int *b, int n, map<int, bool> &perfect) {
  for (int i = 0; i < n; i++)
    if (b[i] == -1)
      for (int j = 1; j <= n; j++)
        if (!perfect[j]) {
          b[i] = j;
          perfect[j] = true;
          break;
        }
}
void parseOutput(int *p, int *a, int n) {
  int b[n];
  memset(b, -1, sizeof(b));
  map<int, bool> perfect;
  test1(p, a, b, n, perfect);
  test2(p, a, b, n, perfect);
  test3(b, n, perfect);
  for (int i = 0; i < n; i++) cout << b[i] << " ";
  cout << endl;
}
void inputValues(int *array1, int *array2, int size) {
  inputArray(array1, size);
  inputArray(array2, size);
}
int main(void) {
  int n;
  cin >> n;
  int p[n], a[n];
  inputValues(p, a, n);
  parseOutput(p, a, n);
  return 0;
}
