N = int(input()) X = list(map(int,input().split())) Y = list(map(int,input().split())) mod = 998244353 Z = [] for x in X: Z.append((x,0)) for y in Y: Z.append((y,1)) Z.sort() x = 0 y = 0 for i in range(N): c,j = Z[i] if j == 0: x += 1 else: y += 1 ans = 1 for i in range(1,x+1): ans *= i ans %= mod for i in range(1,y+1): ans *= i ans %= mod print(ans)