n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) a.sort(reverse=True) b.sort() ans = 1 for i in range(n): if a[i] < b[i]: for k in range(1,i): ans *= k for k in range(1,n-i+1): ans *= k print(ans) exit()