#include <bits/stdc++.h>
using namespace std;
long long a[200005] = {0};
long long re[200005] = {0};
long long b[200005] = {0};
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) scanf("%lli", &a[i]);
  for (long long i = 0; i < n; i++) scanf("%lli", &b[i]);
  sort(a, a + n);
  reverse(a, a + n);
  map<long long, vector<long long> > mp;
  for (long long i = 0; i < n; i++) {
    mp[b[i]].push_back(i);
  }
  long long j = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    reverse((*it).second.begin(), (*it).second.end());
    for (long long i = 0; i < (*it).second.size(); i++) {
      re[(*it).second[i]] = a[j];
      j++;
    }
  }
  for (long long i = 0; i < n; i++) cout << re[i] << " ";
  cout << endl;
  return 0;
}
