#include <bits/stdc++.h>
using namespace std;

const int N = 100005;
const int MOD = 1000000007;
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)
#define se second
#define fi first

int n, x;
vector<pii> a;
int cnt[2];

int main() {
	scanf("%d", &n);
	for (int s = 0; s < 2; s++) {
		for (int i = 1; i <= n; i++) {
			scanf("%d", &x);
			a.push_back(mp(x, s));
		}
	}
	sort(a.begin(), a.end());
	int ans = 1;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < a.size(); i++) {
		if (cnt[!a[i].se] - cnt[a[i].se] > 0)  
			ans = 1LL * ans * (cnt[!a[i].se] - cnt[a[i].se]) % MOD;
		cnt[a[i].se]++;
	}
	printf("%d\n", ans);
	return 0;
}
