M=998244353 n=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) C=A+B C.sort() C=C[:n] A=set(A) B=set(B) a=0 for i in C: if i in A: a+=1 ans=1 for i in range(1,a+1): ans*=i ans%=M for i in range(1,n-a+1): ans*=i ans%=M print(ans%M)