N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) A.sort() B.sort(reverse=True) x=0 y=0 for i in range(N): if A[i]>B[i]: x+=1 else: y+=1 w=1 result=1 mod=998244353 for z in range(1,x+1): w*=z w%=mod result*=w result%=mod w=1 for z in range(1,y+1): w*=z w%=mod result*=w result%=mod print(result)