#include <bits/stdc++.h>
using namespace std;
vector<int> a[2];
int cnt[100007];
int missing(vector<int> v, int& repeated) {
  int miss;
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < v.size(); ++i) {
    cnt[v[i]]++;
  }
  for (int i = 1; i <= v.size(); ++i) {
    if (cnt[i] == 0) miss = i;
    if (cnt[i] == 2) repeated = i;
  }
  return miss;
}
vector<int> build(vector<int> v1, bool back) {
  int miss, two;
  miss = missing(v1, two);
  for (int i = 0; i < v1.size(); ++i) {
    int p = back ? v1.size() - 1 - i : i;
    if (v1[p] == two) {
      v1[p] = miss;
      break;
    }
  }
  return v1;
}
int main() {
  int n;
  vector<int> v[2][2], ans;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    a[0].push_back(k);
  }
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    a[1].push_back(k);
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      v[i][j] = build(a[i], j);
    }
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      if (v[0][i] == v[1][j]) ans = v[0][i];
    }
  }
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
