Bobo has two permutations: P=p_1,p_2,…,p_n and Q=q_1,q_2,q_3,q_4. He would like to partition P into four non-empty and contiguous parts in such a manner that:
Bobo wants to know the number of such partitions. As the number may be very large, you just need to print the answer modulo (109+7).
The input contains zero or more test cases, and is terminated by end-of-file. For each test case:
The first line contains an integer n, the length of the first permutation (4≤n≤106).
The second line contains n integers p_1,p_2,…,p_n.
The third line contains four integers q_1,q_2,q_3,q_4.
It is guaranteed that the sum of all n does not exceed 106.
For each test case, output an integer denoting the answer.