#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x7FFFFFFF;
const int MAX = 1000000;
inline void read(int &x) {
  int flag = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (flag = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') {
    x = x * 10 + c - '0';
  }
  x *= flag;
}
struct Match {
  int index;
  int val;
} b[200010];
int a[200010];
bool cmp1(int aa, int bb) { return aa > bb; }
bool cmp2(const Match &aa, const Match &bb) {
  return aa.val == bb.val && aa.index > bb.index || aa.val < bb.val;
}
bool cmp3(const Match &aa, const Match &bb) { return aa.index < bb.index; }
int main() {
  int m, i;
  scanf("%d", &m);
  for (i = 0; i < m; ++i) scanf("%d", &a[i]);
  sort(a, a + m, cmp1);
  for (i = 0; i < m; ++i) {
    scanf("%d", &b[i].val);
    b[i].index = i;
  }
  sort(b, b + m, cmp2);
  for (i = 0; i < m; ++i) {
    b[i].val = a[i];
  }
  sort(b, b + m, cmp3);
  for (i = 0; i < m; ++i) {
    printf("%d%c", b[i].val, i == m - 1 ? '\n' : ' ');
  }
  return 0;
}
