#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;

int main() {
  int N; cin >> N;
  vector<P> vec;
  vector<ll> a(N), b(N);
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    vec.emplace_back(P(a[i], i));
  }
  for(int i = 0; i < N; ++i) {
    cin >> b[i];
    vec.emplace_back(P(b[i], N+i));
  }
  sort(vec.begin(), vec.end());
  ll v = 1, cnt = 0;
  for(int i = 0; i < vec.size(); ++i) {
    if(vec[i].second < N) {
      if(cnt < 0) {
        v *= 1LL * (-cnt);
      }
      cnt++;
    }
    if(vec[i].second >= N) {
      if(cnt > 0) {
        v *= 1LL * cnt;
      }
      cnt--;
    }
    v %= mod;
  }
  std::cout << v << std::endl;
  return 0;
}
