#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define MOD 998244353 using ll = long long int; int factorial (int x) { int ret = 1; while (x > 1) { ret = ((ll)ret * (ll)x) % MOD; x--; } return ret; } int main() { int N; cin >> N; vector X(N), Y(N); rep(i, N) cin >> X[i]; rep(i, N) cin >> Y[i]; sort(X.begin(), X.end()); sort(Y.rbegin(), Y.rend()); int mid = -1; rep(i, N) if (X[i] >= Y[i]) { mid = i; break; } int ans = ((ll)factorial(mid) * (ll)factorial(N - mid)) % MOD; cout << ans << endl; return 0; }