#include using namespace std; long long mod = 998244353; //入力が必ずmod未満の時に使う. struct mint{ long long v = 0; mint(){} mint(int a){v = a;} mint(long long a){v = a;} long long val(){return v;} void modu(){v %= mod;} mint repeat2mint(long long a,long long b){ mint ret = 1,p = a; int Log = 60; if(b <= 2e9) Log = 30; for(int i=0; i(mint b){if(v > b.v) return true; else return false;} bool operator>=(mint b){if(v >= b.v) return true; else return false;} bool operator<(mint b){if(v < b.v) return true; else return false;} bool operator<=(mint b){if(v <= b.v) return true; else return false;} mint pow(long long x){return repeat2mint(v,x);} mint inv(){return mint(1)/v;} }; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector X(N),Y(N); for(auto &x : X) cin >> x; for(auto &y : Y) cin >> y; sort(X.begin(),X.end()); sort(Y.rbegin(),Y.rend()); vector fac(N+1,1),inv(N+1,1),facinv(N+1,1); for(int i=1; i<=N; i++) fac.at(i).v = fac.at(i-1).v*i %mod; for(int i=2; i<=N; i++) inv.at(i).v = mod-(mod/i*inv.at(mod%i).v %mod); for(int i=2; i<=N; i++) facinv.at(i).v = facinv.at(i-1).v*inv.at(i).v %mod; auto nCr = [&](int n, int r) -> mint { return fac.at(n)*facinv.at(r)*facinv.at(n-r); }; int pos = 0; while(pos != N){ if(X.at(pos) < Y.at(pos)) pos++; else break; } mint answer = fac.at(pos)*fac.at(N-pos); cout << answer.v << endl; }