N = int(input()) X = list(map(int,input().split())) Y = list(map(int,input().split())) MOD = 998244353 A = [0]*(N+1) A[0]=A[1]=1 for i in range(2,N+1): A[i]=(i*A[i-1])%MOD X = [(X[i],0) for i in range(N)] Y = [(Y[i],1) for i in range(N)] Z = X+Y Z = sorted(Z,key=lambda x:x[0]) n0 = 0 for i in range(N): if Z[i][1]==0: n0 += 1 n1 = N-n0 ans = (A[n0]*A[n1])%MOD print(ans)