#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int n;
vector<int> p;
vector<int> f;
int ma = 0;
bool bs(int i, int mid, vector<int> tmpp) {
  int cnt = 0;
  if(f[mid] > p[0]) cnt++;
  int pos = 0;
  for(int j=0;j<n-i-1;++j) {
    while(pos == mid || (pos != n-i && f[pos] <= tmpp[j])) {
      pos++;
    }
    if(pos == n-i) break;
    cnt++;
    pos++;
  }
  return cnt == ma;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> n;
  p.clear();
  f.clear();
  p.resize(n);
  f.resize(n);
  for(int i=0;i<n;++i) {
    cin >> p[i];
  }
  for(int i=0;i<n;++i) {
    cin >> f[i];
  }
  vector<int> tmpp = p;
  sort(tmpp.begin(), tmpp.end());
  sort(f.begin(), f.end());
  ma = 0;
  int pos = 0;
  for(int i=0;i<n;++i) {
    while(pos < n && f[pos] <= tmpp[i]) {
      pos++;
    }
    if(pos == n) break;
    ma++;
    pos++;
  }
  vector<int> ans;
  for(int i=0;i<n;++i) {
    tmpp = p;
    tmpp.erase(tmpp.begin());
    sort(tmpp.begin(), tmpp.end());
    auto it = upper_bound(f.begin(), f.end(), p[0]);
    int pos = distance(f.begin(), it);
    int l1 = 0, r1 = pos;
    while(r1 - l1 > 1) {
      int mid = (l1 + r1) / 2;
      if(bs(i, mid, tmpp)) {
        l1 = mid;
      } else {
        r1 = mid;
      }
    }
    int l = l1;
    if(pos < n-i) {
      int l2 = pos, r2 = n - i;
      while(r2 - l2 > 1) {
        int mid = (l2 + r2) / 2;
        if(bs(i, mid, tmpp)) {
          l2 = mid;
        } else {
          r2 = mid;
        }
      }
      if(pos < n - i && bs(i, l2, tmpp)) l = l2;
    }
    if(f[l] > p[0]) ma--;
    ans.push_back(f[l]);
    p.erase(p.begin() + 0);
    f.erase(f.begin() + l);
  }
  printv(ans);
}

