#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000 + 10;
int n;
int arr[MAXN], c[MAXN], idx[MAXN], rev[MAXN], ans[MAXN];
bool comp(int i, int j) { return c[i] < c[j]; }
bool great(int i, int j) { return i > j; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  sort(arr + 1, arr + n + 1, great);
  for (int i = 1; i <= n; i++) cin >> c[i], idx[i] = i;
  sort(idx + 1, idx + n + 1, comp);
  for (int i = 1; i <= n; i++) rev[idx[i]] = i;
  for (int i = 1; i <= n; i++) cout << arr[rev[i]] << ' ';
}
