#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using ull = unsigned long long; using vi = vector; using vvi = vector; using vc = vector; using vvc = vector; using vb = vector; using vvb = vector; using vs = vector; using pii = pair; using vpii = vector; using mint = modint998244353; // using mint = modint1000000007; #define endl '\n' #define rep(i, a) for (ll i = 0; i < a; i++) #define f(i, a, b) for (ll i = a; i < b; i++) #define rf(i, a, b) for (ll i = a; i > b; i--) const ll INF = LLONG_MAX / 4; void io_setup() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); } template T fact(int n, bool inv = false) { assert(n >= 0); static std::vector> factorials = {{1, 1}}; for (int i = factorials.size(); i <= n; ++i) factorials.emplace_back(i * factorials[i - 1].first, 0); if (inv && factorials[n].second == 0) { if constexpr (std::is_integral_v) factorials[n].second = factorials[n].first <= 1 ? 1 : 0; #ifdef INCLUDED_ACL else if constexpr (atcoder::internal::is_modint::value) factorials[n].second = mint_inv(factorials[n].first); #endif // INCLUDED_ACLq else factorials[n].second = 1 / factorials[n].first; } return inv ? factorials[n].second : factorials[n].first; } int main(void) { io_setup(); int n; cin >> n; vi 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()); mint ans = 1; auto judge = [&](int t) { if (x[t] <= y[t]) return 1; else return 0; }; int ok = 0, ng = n; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (judge(mid)) ok = mid; else ng = mid; } ok++; f(i, 1, ok + 1) { ans *= i; } f(i, 1, n - ok + 1) { ans *= i; } cout << ans.val() << endl; }