n = int(input()) x = list(map(int,input().split())) y = list(map(int,input().split())) mod = 998244353 lis = [] for i in range(n): lis.append([x[i],"x"]) lis.append([y[i],"y"]) lis.sort() cntx,cnty = n,n for i in range(n): if lis[i][1] == "x": cntx -= 1 else: cnty -= 1 ans = 1 for i in range(n): if lis[i][1] == "x": ans *= cnty cnty -= 1 else: ans *= cntx cntx -= 1 ans %= mod print(ans)