import math mod = 998244353 n = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) x.sort() y.sort(reverse=True) k = 0 for i in range(n): if x[i] <= y[i]: k += 1 print(math.factorial(k) * math.factorial(n-k) % mod)