#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

#include <deque>
template <class T>
ostream &operator<<(ostream &os, const vector<T> &rhs) {
  os << "[ ";
  FORIT(it, rhs) {
    if (it != rhs.begin()) { os << ", "; }
    os << *it;
  }
  os << " ]";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const deque<T> &rhs) {
  os << "[ ";
  FORIT(it, rhs) {
    if (it != rhs.begin()) { os << ", "; }
    os << *it;
  }
  os << " ]";
  return os;
}
template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &rhs) {
  os << "{" << endl;
  FORIT(it, rhs) {
    if (it != rhs.begin()) { os << "," << endl; }
    os << "  " << it->first << " : " << it->second;
  }
  os << endl << "}";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &rhs) {
  os << "{ ";
  FORIT(it, rhs) {
    if (it != rhs.begin()) { os << ", "; }
    os << *it;
  }
  os << " }";
  return os;
}
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
  os << "( " << rhs.first << ", " << rhs.second << " )";
  return os;
}

int n;
int max_cnt;
int sum;
int aseq[6000];
int bseq[6000];

vector<int> asort_seq;
vector<int> bsort_seq;

int calc_cnt(int skip) {
        int m = asort_seq.size();
        int b = 0;
        int ret = 0;
        bool skip_flag = true;
        REP(i, m) {
                while (b < (int)bsort_seq.size()) {
                        if (skip_flag && bsort_seq[b] == skip) {
                                skip_flag = false;
                                b++;
                                continue;
                        }
                        if (bsort_seq[b] > asort_seq[i]) { break; }
                        b++;
                }
                if (b == (int)bsort_seq.size()) { break; }
                b++;
                ret++;
        }
        return ret;
}

void remove_value(vector<int> &seq, int v) {
        FORIT(it, seq) {
                if (*it == v) {
                        seq.erase(it);
                        return;
                }
        }
        assert(false);
}

int find_index(int a) {
        REP(i, bsort_seq.size()) {
                if (a < bsort_seq[i]) {
                        return i;
                }
        }
        return bsort_seq.size();
}

int is_ok(int a, int index) {
        int skip = bsort_seq[index];
        int plus = (skip > a) ? 1 : 0;
        return sum + calc_cnt(skip) + plus >= max_cnt;
}

int main() {
        while (scanf("%d", &n) > 0 && n) {
                vector<int> ans;
                asort_seq.clear();
                bsort_seq.clear();
                REP(i, n) {
                        scanf("%d", &aseq[i]);
                        asort_seq.push_back(aseq[i]);
                }
                REP(i, n) {
                        scanf("%d", &bseq[i]);
                        bsort_seq.push_back(bseq[i]);
                }
                sort(asort_seq.begin(), asort_seq.end());
                sort(bsort_seq.begin(), bsort_seq.end());
                max_cnt = calc_cnt(-1);
                sum = 0;
                REP(i, n) {
                        remove_value(asort_seq, aseq[i]);
                        int pos = find_index(aseq[i]);
                        int left = 0;
                        int right = pos;
                        // cout << asort_seq << endl;
                        // cout << bsort_seq << endl;
                        // cout << pos << endl;
                        int nsum = sum;
                        if (pos != (int)bsort_seq.size() && is_ok(aseq[i], pos)) {
                                left = pos;
                                right = bsort_seq.size();
                                nsum = sum + 1;
                        }
                        while (right - left > 1) {
                                int mid = (left + right) / 2;
                                if (is_ok(aseq[i], mid)) {
                                        left = mid;
                                } else {
                                        right = mid;
                                }
                        }
                        ans.push_back(bsort_seq[left]);
                        remove_value(bsort_seq, bsort_seq[left]);
                        sum = nsum;
                }
                REP(i, n) {
                        if (i != 0) { putchar(' '); }
                        printf("%d", ans[i]);
                }
                puts("");
        }
}


Measured memory_bytes: 3424