#include <bits/stdc++.h>
using namespace std;
map<int, int> mapka;
vector<pair<int, int> > tab;
int ans[200010];
int n, x;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int a = 1; a <= n; a++) {
    cin >> x;
    mapka[x]++;
  }
  for (int a = 1; a <= n; a++) {
    cin >> x;
    if (mapka[x])
      mapka[x]--, ans[a] = x;
    else
      tab.push_back(make_pair(x, a));
  }
  sort(tab.begin(), tab.end());
  reverse(tab.begin(), tab.end());
  int pocz = 0;
  for (map<int, int>::iterator it = mapka.begin(); it != mapka.end(); pocz++) {
    while (it->second == 0 && it != mapka.end()) it++;
    if (it == mapka.end()) break;
    ans[tab[pocz].second] = it->first, it->second--;
  }
  for (int a = 1; a <= n; a++) cout << ans[a] << " ";
  return 0;
}
