#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sz, sz1, sz2, ct, temp, x, y;
  vector<int> c;
  vector<int> d;
  vector<int> e;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    e.push_back(a[i]);
  }
  for (int j = 0; j < n; j++) {
    cin >> b[j];
    e.push_back(b[j]);
  }
  sz2 = e.size();
  for (int k = 0; k < n; k++) {
    if (a[k] != b[k]) {
      d.push_back(k);
      c.push_back(a[k]);
      c.push_back(b[k]);
    }
  }
  for (int r = 1; r <= n; r++) {
    temp = 0;
    for (int s = 0; s < sz2; s++) {
      if (r == e[s]) {
        temp = 1;
        break;
      }
    }
    if (temp == 0) {
      c.push_back(r);
    }
  }
  sz1 = d.size();
  sz = c.size();
  for (int o = 0; o < sz1; o++) {
    x = d[o];
    y = (2 * o);
    for (int p = y; p < (y + 2); p++) {
      ct = 0;
      for (int q = 0; q < n; q++) {
        if (q != x && c[p] == a[q]) {
          ct = 1;
          break;
        }
      }
      if (ct == 0) {
        a[x] = c[p];
        break;
      }
    }
  }
  for (int u = 0; u < sz1; u++) {
    x = d[u];
    for (int v = sz1; v < sz; v++) {
      ct = 0;
      for (int w = 0; w < n; w++) {
        if (w != x && c[v] == a[w]) {
          ct = 1;
          break;
        }
      }
      if (ct == 0) {
        a[x] = c[v];
        break;
      }
    }
  }
  for (int t = 0; t < n; t++) {
    if (t != (n - 1)) {
      cout << a[t] << " ";
    } else {
      cout << a[t];
    }
  }
  return 0;
}
