#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m*n/gcd(m,n);}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename Iter> ostream& out_container(ostream &os, Iter first, Iter last){
  os << "{"; auto itr = first; while(itr != last){if(itr != first) os << ","; os << *itr; ++itr;} os << "}"; return os;
}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const deque<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const set<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const unordered_set<T> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const unordered_map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

const LLI mod = 1e9+7;

template <typename T> LLI power(T n, T p, T m){if(p==0) return 1LL; if(p==1) return n; LLI k = power(n, p/2, m); return ((k*k)%m*(p%2?n:1))%m;}

template <typename T> LLI mod_inv(T n, T p){return power(n,p-2,p);}

template <LLI mod> class Combination{
public:
  vector<LLI> facto = {1};
  vector<LLI> ifacto = {1};

  LLI factorial(LLI i){
    if(i < 0) throw exception();
    if(facto.size() <= i) facto.resize(i+1, -1);
    if(i == 0) return facto[0] = 1;
    int j = i;
    for(;j>=0;--j) if(facto[j] != -1) break;
    for(int k=j+1; k<=i; ++k) (facto[k] = facto[k-1] * k) %= mod;
    return facto[i];
  }

  LLI factorial_inverse(LLI i){
    if(i < 0) throw exception();
    if(ifacto.size() <= i) ifacto.resize(i+1, -1);
    if(ifacto[i] != -1) return ifacto[i];
    return ifacto[i] = mod_inv(factorial(i), mod);
  }

  LLI P(int n, int k){
    return (factorial(n) * factorial_inverse(n-k)) % mod;
  }

  LLI C(int n, int k){
    return (P(n,k) * factorial_inverse(k)) % mod;
  }

  LLI H(int n, int k){
    return C(n+k-1, n);
  }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  Combination<mod> comb;

  int N;
  while(cin >> N){
    vector<int> a(N), b(N); cin >> a >> b;
    sort(ALL(a));
    sort(ALL(b));


    vector<pair<int,int>> v(2*N);
    REP(i,N){
      v[2*i] = {a[i],-1};
      v[2*i+1] = {-1,b[i]};
    }
    
    sort(ALL(v), [](pair<int,int> &x, pair<int,int> &y){return max(x.fst,x.snd) < max(y.fst, y.snd);});

    vector<pair<int,int>> v2;
    REP(i,2*N){
      if(v2.empty()){
	if(v[i].fst != -1) v2.push_back({1,-1});
	else v2.push_back({-1,1});
      }else{
	if(v[i].fst != -1){
	  if(v2.back().fst != -1) ++(v2.back().fst);
	  else v2.push_back({1,-1});
	}else{
	  if(v2.back().snd != -1) ++(v2.back().snd);
	  else v2.push_back({-1,1});
	}
      }
    }

    stack<int> st;
    for(auto &p : v2) st.push(max(p.fst, p.snd));
    
    LLI ans = 1;

    while(!st.empty()){
      auto x = st.top(); st.pop();
      auto y = st.top(); st.pop();

      if(x == y){
	(ans *= comb.factorial(x)) %= mod;
      }else if(x < y){
	(ans *= comb.factorial(x)) %= mod;
	st.push(y-x);
      }else{
	(ans *= (comb.C(x,y) * comb.factorial(y)) % mod) %= mod;

	auto z = st.top(); st.pop();
	st.push(z+x-y);
      }
    }
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4852