class ModularCombinatorics: def __init__(self, mod=998244353, max_=10**6): self._mod = mod self._fact = [1]*(max_+1) self._finv = [1]*(max_+1) for i in range(2, max_+1): self._fact[i] = i * self._fact[i-1] % mod self._finv[max_] = pow(self._fact[max_], -1, mod) for i in range(max_, 2, -1): self._finv[i-1] = i * self._finv[i] % mod def perm(self, n, r=None): if r is None: return self._fact[n] if n < r: return 0 return self._fact[n] * self._finv[n-r] % self._mod def comb(self, n, r): return self.perm(n, r) * self._finv[r] % self._mod def crep(self, n, r): return self.comb(n+r-1, r) MOD = 998244353 MC = ModularCombinatorics(MOD) N = int(input()) X = set(map(int, input().split())) Y = set(map(int, input().split())) Z = sorted(X|Y) cnt = 0 for z in Z[:N]: if z in X: cnt += 1 a, b = MC.perm(cnt), MC.perm(N - cnt) print(a * b % MOD)