#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 5;
int a[N];
int b[N];
int p[N];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      ++cnt;
    }
  }
  if (cnt == 1) {
    map<int, int> mp;
    int loc = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] != b[i]) {
        loc = i;
      } else {
        p[i] = a[i];
        ++mp[p[i]];
      }
    }
    for (int i = 1; i <= 1000; ++i) {
      if (i != a[loc] && i != b[loc]) {
        if (mp[i] == 0) {
          p[loc] = i;
          break;
        }
      }
    }
  } else {
    int cnt1 = 0;
    int loc1 = 0, loc2 = 0;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
      if (a[i] == b[i]) {
        p[i] = a[i];
        ++mp[p[i]];
      } else if (cnt1 == 0) {
        loc1 = i;
        p[i] = b[i];
        ++mp[p[i]];
        ++cnt1;
      } else if (cnt1 == 1) {
        loc2 = i;
        p[i] = a[i];
        ++mp[p[i]];
      }
    }
    bool flag = true;
    map<int, int>::iterator it;
    for (it = mp.begin(); it != mp.end(); ++it) {
      if (it->second > 1) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      p[loc1] = a[loc1];
      p[loc2] = b[loc2];
    }
  }
  cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (cnt > 0) printf(" ");
    printf("%d", p[i]);
    ++cnt;
  }
  printf("\n");
  return 0;
}
