N = int(input()) X = list(map(int, input().split())) Y = list(map(int, input().split())) mod = 998244353 P = [1] for i in range(1,N+1): P.append(P[-1]*i) SX = set(X) XYH = sorted(X+Y)[:N] x_cnt = 0 for xyh in XYH: if xyh in SX: x_cnt+=1 print(P[x_cnt]*P[N-x_cnt]%mod)