#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> f(n), p(n);
  for (int i = 0; i < n; i++)
    cin >> f[i];
  for (int i = 0; i < n; i++)
    cin >> p[i];
  vector<bool> win(n);
  sort(p.begin(), p.end());
  auto pp = p;
  int num = 0;
  multiset<ll> s;
  for (int i = 0; i < n; i++) {
    auto it = upper_bound(pp.begin(), pp.end(), f[i]);
    if (it != pp.end()) {
      win[i] = true;
      pp.erase(it);
      num++;
    }
    s.insert(f[i]);
  }
  vector<ll> ans(n);
  auto g = [&](int i) {
    auto it = s.begin();
    vector<ll> t;
    for (int j = 0; t.size() < num; j++) {
      if (p.size() - 1 - j == i)
        continue;
      assert(p.size() - 1 - j >= 0);
      t.push_back(p[p.size() - 1 - j]);
    }
    reverse(t.begin(), t.end());
    for (int j = 0; j < num; j++) {
      assert(it != s.end());
      if (t[j] <= *it) {
        return false;
      }
      it++;
    }
    return true;
  };

  for (int i = 0; i < n; i++) {
    int l = 0, r = p.size();
    while (l < p.size() && p[l] <= f[i])
      l++;
    num--;
    s.erase(s.find(f[i]));
    if (l < r && g(l)) {
      int l = 0, r = p.size();
      while (l < p.size() && p[l] <= f[i])
        l++;
      assert(l < r);

      while (r - l > 1) {
        int m = (l + r) / 2;
        if (g(m)) {
          l = m;
        } else {
          r = m;
        }
      }
      ans[i] = p[l];
      p.erase(p.begin() + l);
    } else {
      num++;
      s.insert(f[i]);
      l = 0;
      while (r - l > 1) {
        int m = (l + r) / 2;
        if (g(m)) {
          l = m;
        } else {
          r = m;
        }
      }
      ans[i] = p[l];
      p.erase(p.begin() + l);
      continue;
    }
  }

  cout << ans[0];
  for (int i = 1; i < n; i++) {
    cout << " " << ans[i];
  }
  cout << endl;

  return 0;
}
