import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline n = int(input()) mod = 998244353 x = list(map(int,input().split())) y = list(map(int,input().split())) z = x + y z.sort() xx = set(x) yy = set(y) xxx = 0 yyy = 0 for i in range(n): if z[i] in x: xxx += 1 else: yyy += 1 zzz = max(xxx,yyy) ans = 1 for i in range(1,xxx+1): ans *= i ans %= mod for i in range(1,yyy+1): ans *= i ans %= mod print(ans)