#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int a[5000], b[5000];
bool used[5000];
int n;
vector<int> u[5000];
void init() {
	rep(i, n) {
		Rep(j, i, n) {
			u[i].push_back(a[j]);
		}
	    sort(u[i].begin(), u[i].end());
	}
}
vector<P> v;
int calc(int id) {
	int c = 0; int le = u[id].size()-1;
	per(i, v.size()) {
		if (used[v[i].second])continue;
		while (le>=0 && u[id][le]>=v[i].first) {
			le--;
		}
		if (le<0)break;
		c++; le--;
	}
	return c;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
		v.push_back({ b[i],i });
	}
	sort(v.begin(), v.end());
	init();
	vector<int> ans;
	rep(i, n) {
		int c = calc(i);
		int b = lower_bound(v.begin(), v.end(), P{ a[i] + 1,-1 }) - v.begin();
		int le = b; int ri = v.size();
		while (ri - le > 1) {
			int mid = (ri + le) >> 1;
			used[v[mid].second] = true;
			int z = calc(i + 1);
			used[v[mid].second] = false;
			if (a[i] < v[mid].first)z++;
			if (z == c) {
				le = mid;
			}
			else {
				ri = mid;
			}
		}
		if (le < v.size()) {
			used[v[le].second] = true;
			int cz = calc(i + 1);
			if (cz + 1 == c) {
				ans.push_back(v[le].first);
				v.erase(v.begin() + le);
				continue;
			}
		    used[v[le].second] = false;
		}
		ri = b; le = 0;
		while (ri - le > 1) {
			int mid = (ri + le) >> 1;
			used[v[mid].second] = true;
			int z = calc(i + 1);
			used[v[mid].second] = false;
			if (a[i] < v[mid].first)z++;
			if (z == c) {
				le = mid;
			}
			else {
				ri = mid;
			}
		}
		used[v[le].second] = true;
		ans.push_back(v[le].first);
		v.erase(v.begin() + le);
	}
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}
