#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], b[maxn];
map<int, vector<int> > m;
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    m[x].push_back(i);
  }
  sort(a + 1, a + n + 1);
  map<int, vector<int> >::iterator it;
  int t = n;
  for (it = m.begin(); it != m.end(); it++) {
    for (int j = 0; j < m[it->first].size(); j++) {
      int p = m[it->first][j];
      b[p] = a[t--];
    }
  }
  printf("%d", b[1]);
  for (int i = 2; i <= n; i++) printf(" %d", b[i]);
  return 0;
}
