#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second

typedef pair<int, int> ii;

const long long MOD = 1E9 + 7;

int n;
long long ans = 1;
vector<ii> a;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int j = 0; j < 2; ++j)
        for (int i = 1; i <= n; ++i) {
            int t;
            cin >> t;
            a.push_back({t, j});
        }
    sort(a.begin(), a.end());
    int cnt[2] = {0, 0};
    for (ii i : a) {
        if (cnt[i.se ^ 1] == 0) ++cnt[i.se];
        else (ans *= cnt[i.se ^ 1]--) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}