#include #include #include #include #define MOD 998244353 using namespace std; constexpr unsigned int permutation_mod(const unsigned int a, const unsigned int b, const unsigned int mod) { return (a < b) ? 0 : ((b == 0) ? 1 : static_cast(a) * permutation_mod(a - 1, b - 1, mod) % mod); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, i; cin >> N; vector X(N), Y(N); for (i = 0; i != N; ++i) cin >> X[i]; for (i = 0; i != N; ++i) cin >> Y[i]; sort(X.begin(), X.end()); sort(Y.begin(), Y.end(), greater()); for (i = 0; i != N && X[i] < Y[i]; ++i); cout << static_cast(permutation_mod(i, i, MOD)) * permutation_mod(N - i, N - i, MOD) % MOD << '\n'; return 0; }