N = int(input()) X = sorted(list(map(int, input().split()))) Y = sorted(list(map(int, input().split())), reverse=True) MOD = 998244353 left = 0 for i in range(N): if X[i] > Y[i]: break left += 1 right = N-left P = [0, 1] for i in range(2, N+1): P.append(P[-1]*i%MOD) if left == 0: print(P[right]) elif right == 0: print(P[left]) else: print(P[left]*P[right]%MOD)