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