#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
const int inf = 0x7fffffff;
int n, a[N], b[N], id[N], ans[N];
bool cmp(int x, int y) { return (b[x] > b[y]) || (b[x] == b[y] && x < y); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), id[i] = i;
  for (int i = 1; i <= n; ++i) scanf("%d", b + i);
  sort(id + 1, id + n + 1, cmp);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) ans[id[i]] = a[i];
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
}
