#U2021JB3. Just Stalling
Just Stalling
Farmer John has NN cows (1≤N≤201≤N≤20) of heights a1**…aNa1…aN. His barn has NN stalls with max height limits b1…bNb1…bN (so for example, if b5=**17b5=17, then a cow of height at most 1717 can reside in stall 55). In how many distinct ways can Farmer John arrange his cows so that each cow is in a different stall, and so that the height limit is satisfied for every stall?
INPUT FORMAT (input arrives from the terminal / stdin):
The first line contains NN. The second line contains NN space-separated integers a1**,a2**,…,aNa1,a2,…,aN. The third line contains NN space-separated integers b1**,b2**,…,bNb1,b2,…,bN. All heights and limits are in the range [1,109][1,109].
OUTPUT FORMAT (print output to the terminal / stdout):
The number of ways Farmer John can place each cow into a different stall such that the height limit is satisfied for every stall. Note that the large size of the output might require the use of a 64-bit integer, like a "long long" in C++.
SAMPLE INPUT:
4
1 2 3 4
2 4 3 4
SAMPLE OUTPUT:
8
In this example, we cannot place the third cow into the first stall since 3=a3**>b1**=23=a3>b1=2. Similarly, we cannot place the fourth cow into the first or third stalls. One way to satisfy the height limits is to assign cow 11 to stall 11, cow 22 to stall 22, cow 33 to stall 33, and cow 44 to stall 44.
SCORING:
- Test cases 1-5 satisfy N≤8N≤8.
- Test cases 6-12 satisfy no additional constraints.