#include using namespace std; typedef long long ll; typedef pair pii; const int N = 1e5+10; const int MOD = 998244353; int a[N], b[N], n; ll fac(ll n) { if (n == 0) return 1; return (n*fac(n-1))%MOD; } void solve() { cin>>n; for (int i=1; i<=n; ++i) cin>>a[i]; for (int i=1; i<=n; ++i) cin>>b[i]; sort(a+1, a+n+1), sort(b+1, b+n+1, greater()); for (int i=1; i<=n; ++i) { if (b[i] < a[i]) { cout<<(fac(i-1)*fac(n-i+1))%MOD<<"\n"; return; } } } int main() { int t=1; //cin>>t; while (t--) solve(); }