#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  char ch;
  bool flag = false;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') flag = true;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  x = flag ? -x : x;
}
inline void write(int x) {
  static const int maxlen = 100;
  static char s[maxlen];
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  int len = 0;
  for (; x; x /= 10) s[len++] = x % 10 + '0';
  for (int i = len - 1; i >= 0; --i) putchar(s[i]);
}
const int maxn = 1000200;
struct zy {
  int id, v;
};
zy a[maxn];
zy b[maxn];
int ans[maxn];
int n;
bool vcmp(zy A, zy B) { return A.v < B.v; }
bool idcmp(zy A, zy B) { return A.id < B.id; }
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i].v);
    a[i].id = i;
  }
  for (int i = 1; i <= n; i++) {
    read(b[i].v);
    b[i].id = i;
  }
  sort(b + 1, b + 1 + n, vcmp);
  sort(a + 1, a + 1 + n, vcmp);
  int j = 1;
  int k = n;
  while ((j <= n) && (a[j].v == b[k].v)) {
    ans[b[k].id] = a[j].v;
    k--;
    j++;
  }
  for (int i = j; i <= n; i++) {
    ans[b[n - i + 1].id] = a[i].v;
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
