import sys inf = float("inf") input = lambda: sys.stdin.readline().rstrip("\r\n") print = lambda *args, end="\n", sep=" ": sys.stdout.write( sep.join(map(str, args)) + end ) def II(): return int(input()) def MII(b=0): return map(lambda x: int(x) - b, input().split()) def LII(b=0): return list(MII(b)) def comb(n, m, mod=998244353): if m > n or m < 0: return 0 if m == 0 or m == n: return 1 numerator = 1 denominator = 1 for i in range(1, min(m, n - m) + 1): numerator *= n - i + 1 denominator *= i numerator %= mod denominator %= mod return numerator * pow(denominator, mod - 2, mod) % mod def perm(n, m, mod=998244353): if m > n or m < 0: return 0 result = 1 for i in range(n, n - m, -1): result *= i result %= mod return result n = II() a, b = LII(), LII() a.sort() b.sort(reverse=True) x, y = 0, 0 for ai, bi in zip(a, b): if ai > bi: x += 1 elif ai < bi: y += 1 print((perm(x, x) * perm(y, y)) % 998244353)