def factorial(n): res = 1 for i in range(1, n+1): res *= i res %= MOD return res MOD = 998244353 N = int(input()) X = list(map(int, input().split())) Y = list(map(int, input().split())) X.sort() Y.sort(reverse=True) ans = 1 for i in reversed(range(N)): if X[i] < Y[i]: ans = factorial(i+1) * factorial(N-i-1) % MOD break print(ans)