#include using namespace std; using ll = long long; using ld = long double; using pll = pair; const ll INF = LLONG_MAX / 4; const ll mod1 = 1000000007; const ll mod9 = 998244353; const ll Hash = 10000000000000061; #define all(a) (a).begin(),(a).end() #define rep(i, n) for (ll i = 0; (i) < (n); ++(i)) #define reps(i, l, r) for(ll i = (l); (i) < (r); ++(i)) ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; ll dy[8] = {0, -1, -1, -1, 0, 1, 1, 1}; template bool chmax(T &a, const T& b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T& b) { if (a > b) { a = b; return true; } return false; } #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: ld x; ld y; Point(ld _x = 0, ld _y = 0) : x(_x), y(_y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(ld a) { return Point(a * x, a * y); } Point operator/(ld a) { return Point(x / a, y / a); } ld abs() { return sqrt(norm()); } ld norm() { return x * x + y * y; } bool operator<(const Point& p) const { return !equals(x, p.x) ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10); } }; typedef Point Vector; struct Segment { Point A; Point B; }; typedef Segment Line; class Circle { public: Point C; ld r; Circle(Point C = Point(), ld r = 0.0) : C(C), r(r) {} }; typedef vector Polygon; void solve(){ ll N; cin >> N; vector x(N), y(N); rep(i, N) cin >> x[i]; rep(i, N) cin >> y[i]; sort(all(x), greater()); sort(all(y), greater()); ll t = 0; rep(i, N){ if(x.back() < y.back()){ t++; x.pop_back(); }else{ y.pop_back(); } } ll ans = 1; ll MOD = 998244353; rep(i, t){ ans *= (i+1); ans %= MOD; } rep(i, N-t){ ans *= (i+1); ans %= MOD; } cout << ans << endl; } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); solve(); }