#include using namespace std; void fileIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int N = 2e5 + 10; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n), b(n), c; for(int i = 0; i < n; i ++) cin >> a[i]; for(int i = 0; i < n; i ++) cin >> b[i]; c = a; c.insert(c.end(), b.begin(), b.end()); sort(c.begin(), c.end()); int ans = 1, cnt = 0; for(int i = 0; i < n; i ++) { if(a[i] < c[n]) cnt ++; } for(int i = 1; i <= cnt; i ++) ans = (long long)ans * i % 998244353; cnt = n - cnt; for(int i = 1; i <= cnt; i ++) ans = (long long)ans * i % 998244353; cout << ans; return 0; }