A. Permutation counting
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

For a given permutation $$$P$$$ of $$$1,2,\dots,n$$$, denote $$$inv(P)$$$ the number of inversions of the array $$$P_1,P_2,\dots, P_n$$$. For two permutations $$$A$$$ $$$B$$$ of $$$1,2,\dots,n$$$, define $$$ A(B)$$$ the permutation $$$A_{B_1}, A_{B_2},\dots,A_{B_n}$$$. Denote the inverse of permutation $$$P$$$ as $$$P^{-1}$$$, the only permutation such that $$$P(P^{-1})$$$ is the permutation $$$1,2,\dots,n$$$.

You are given two permutations $$$A,B$$$ of $$$1,2,\dots,n$$$. You have to choose a permutation $$$P$$$ of $$$1,2,\dots,n$$$ such that $$$inv(A(P^{-1}))+inv(P(B^{-1}))$$$ is minimized. How many such permutations exist?

Input

The first line contains an integer $$$n$$$ $$$(1 \leq n \leq 20)$$$. The second line contains $$$n$$$ integers $$$a_1,a_2,\dots,a_n$$$ $$$(1 \leq a_i \leq n)$$$. The third line contains $$$n$$$ integers $$$b_1,b_2,\dots,b_n$$$ $$$(1 \leq b_i \leq n)$$$.

Output

A single integer containing the number of permutations $$$P$$$.

Examples
Input
4
3 1 2 4
2 1 4 3
Output
3
Input
6
3 2 6 1 5 4
1 2 5 6 4 3
Output
12
Input
1
1
1
Output
1