#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
long long main() {
cin.sync_with_stdio(false);
long long onum, num;
vector<long long> uList, mList, newList, retList;
cin >> onum;
num = onum;
while (num--) {
long long a;
cin >> a;
uList.push_back(a-1);
}
num = onum;
while (num--) {
long long a;
cin >> a;
mList.push_back(a-1);
}
vector<long long> alive;
map<long long, long long> iddata, iddata2;
map<long long, long long> bldata;
for (long long i = 0; i < onum; i++) {
alive.push_back(i);
iddata[i] = 0;
iddata2[i] = 0;
bldata[i] = 0;
}
for (long long h = 0; h < onum; h++) {
bldata[uList[h]] = 1;
bldata[mList[h]] = 1;
iddata[uList[h]]++;
iddata[mList[h]]++;
if (h == 0) {
iddata2[uList[h+1]] = bldata[uList[h]] + 1;
iddata2[mList[h+1]] = bldata[mList[h]] + 1;
}
else if (h != onum - 1) {
iddata2[uList[h+1]]++;
iddata2[mList[h+1]]++;
}
long long max = onum;
long long maxid = 0;
for (long long i = 0; i < onum - h; i++) {
if (bldata[alive[i]] == 0 && iddata2[alive[i]] < max) {
max = iddata[alive[i]];
maxid = i;
}
}
bldata[uList[h]] = 0;
bldata[mList[h]] = 0;
retList.push_back(alive[maxid]+1);
alive.erase(alive.begin() + maxid);
}
for (long long i = 0; i < onum; i++){
cout << (long long)retList[i] << " ";
}
}