Problem: You are given a permutation of odd integers from to and a permutation of integers from to .
An array of length is defined as follows:
for all and all
For example, if and , then .
Note that all arrays in the statement are zero-indexed. Note that each element of the array is uniquely determined.
Find the number of inversions in the array . Since this number can be very large, you should find only its remainder modulo .
An inversion in array is a pair () such that .
Input Format: The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers and () — the lengths of arrays and .
The second line of each test case contains distinct integers (, is odd) — the array .
The third line of each test case contains distinct integers () — the array .
It is guaranteed that the sum of over all test cases doesn't exceed and the sum of over all test cases doesn't exceed .
Output Format: For each test case, output one integer: the number of inversions in array modulo .
Note: In the first test case, array is equal to . There are inversions in it: , , , , , , , , . Note that these are pairs such that and .
In the second test case, array is equal to . There are inversions in it.
In the third test case, array is equal to . There are no inversions in it.