#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); } 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; }