Let's define the sum of two permutations *p* and *q* of numbers 0, 1, ..., (*n* - 1) as permutation <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/a6967136eb87d05a01f795f6061b884a1a9f4f4b.png" style="max-width: 100.0%;max-height: 100.0%;"/>, where *Perm*(*x*) is the *x*-th lexicographically permutation of numbers 0, 1, ..., (*n* - 1) (counting from zero), and *Ord*(*p*) is the number of permutation *p* in the lexicographical order.

For example, *Perm*(0) = (0, 1, ..., *n* - 2, *n* - 1), *Perm*(*n*! - 1) = (*n* - 1, *n* - 2, ..., 1, 0)

Misha has two permutations, *p* and *q*. Your task is to find their sum.

Permutation *a* = (*a*<sub class="lower-index">0</sub>, *a*<sub class="lower-index">1</sub>, ..., *a*<sub class="lower-index">*n* - 1</sub>) is called to be lexicographically smaller than permutation *b* = (*b*<sub class="lower-index">0</sub>, *b*<sub class="lower-index">1</sub>, ..., *b*<sub class="lower-index">*n* - 1</sub>), if for some *k* following conditions hold: *a*<sub class="lower-index">0</sub> = *b*<sub class="lower-index">0</sub>, *a*<sub class="lower-index">1</sub> = *b*<sub class="lower-index">1</sub>, ..., *a*<sub class="lower-index">*k* - 1</sub> = *b*<sub class="lower-index">*k* - 1</sub>, *a*<sub class="lower-index">*k*</sub> &lt; *b*<sub class="lower-index">*k*</sub>.
The first line contains an integer *n* (1 ≤ *n* ≤ 200 000).

The second line contains *n* distinct integers from 0 to *n* - 1, separated by a space, forming permutation *p*.

The third line contains *n* distinct integers from 0 to *n* - 1, separated by spaces, forming permutation *q*.
#include <bits/stdc++.h>

using namespace std;

// Templates here
template<typename T1, typename T2, typename T3>
class triple {
public:
    T1 first;
    T2 second;
    T3 third;

    triple() {
        first = 0;
        second = 0;
        third = 0;
    }
};

// Typedefs here
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set<int> si;
typedef set<ll> sl;
typedef set<pii> spii;
typedef set<pll> spll;
typedef map<string, int> mpsi;
typedef map<string, ll> mpsl;
typedef map<int, int> mpii;
typedef map<ll, ll> mpll;

// Defines here
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define fora(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define forla(i, a, b) for(ll (i)=(a);(i)<(b);(i)++)
#define for0(i, b) fora((i),0,(b))
#define forl0(i, b) forla((i),0,(b))
#define rofa(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define rofla(i, a, b) for(ll (i)=(a);(i)>=(b);(i)--)
#define rof0(i, a) rofa((i),(a),0)
#define rofl0(i, a) rofla((i),(a),0)
#define forag(i, a, b, g) for(int (i)=(a);(i)<(b);(i)+=(g))
#define forlag(i, a, b, g) for(ll (i)=(a);(i)<(b);(i)+=(g))
#define for0g(i, b, g) forag((i),0,(b),(g))
#define forl0g(i, b, g) forlag((i),0,(b),(g))
#define rofag(i, a, b, g) for(int (i)=(a);(i)>=(b);(i)-=(g))
#define roflag(i, a, b, g) for(ll (i)=(a);(i)>=(b);(i)-=(g))
#define rof0g(i, a, g) rofag((i),(a),0,(g))
#define rofl0g(i, a, g) roflag((i),(a),0,(g))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pf push_front
#define MP make_pair
#define F first
#define S second
#define GraphM1(g, n) int (g)[(n)][(n)]
#define GraphM2(g, n) vi (g)[(n)]


// Const variables here
constexpr int MAXN = 2e5 + 5;

// Before structs global variables and functions here


// Structs here


// Global variables here
int n;
int a[MAXN], b[MAXN], fen[MAXN], c[MAXN], ans[MAXN];
si s;

// Functions here
void add(int u) {
    ++u;

    for (; u <= n; u += u & -u)
        fen[u]++;
}

void sub(int u) {
    ++u;

    for (; u <= n; u += u & -u)
        fen[u]--;
}

int get(int u) {
    int res = 0;

    ++u;

    for (; u > 0; u -= u & -u)
        res += fen[u];


    return res;
}

int solve(int k) {
    k++;
    int l = -1, r = n + 1;

    while (l + 1 < r) {
        int mid = (l + r) >> 1;

        if (get(mid) >= k)
            r = mid;
        else
            l = mid;
    }

    return r;
}

// Main here
int main() {
    IOS

    cin >> n;

    fora(i, 1, n + 1)cin >> a[i];

    fora(i, 1, n + 1)cin >> b[i];

    fora(i, 1, n + 1) {
        int tmp = a[i];

        a[i] = (a[i] - get(a[i]) + n - i + 1) % (n - i + 1);
        add(tmp);
    }

    memset(fen, 0, sizeof(fen));

    fora(i, 1, n + 1) {
        int tmp = b[i];

        b[i] = (b[i] - get(b[i]) + n - i + 1) % (n - i + 1);
        add(tmp);
    }

    memset(fen, 0, sizeof(fen));

    for0(i, n)add(i);

    for0(i, n)s.insert(i);

    fora(i, 1, n + 1)c[i] = a[i] + b[i];

    rofa(i, n - 1, 1) {
        int tmp = c[i] / (n - i + 1);
        int rem = c[i] % (n - i + 1);

        c[i] = rem;
        c[i - 1] += tmp;
    }

    fora(i, 1, n + 1) {
        ans[i] = solve(c[i]);

        sub(ans[i]);
    }

    fora(i, 1, n + 1)cout << ans[i] << " ";

    cout << "\n";
    return 0;
}