def binary_search(arr,target):     l,r = 0,len(arr)-1     while l <= r:         mid = (l+r)//2         if arr[mid] < target:             l = mid + 1         else:             r = mid - 1     return l def func(count_list, n, mod):     res = 1     for i in range(n):         curr = count[i]-i         if curr<=0:             return 0         res = (res * curr)%mod     return res    n = int(input().strip()) A = list(map(int, input().split())) B = list(map(int, input().split())) A.sort(reverse = True) B.sort() count = [] for i in A:     idx = binary_search(B, i)     count.append(n-idx) mod = 100000007 print(func(count,n,mod))