Limits 1s, 256 MB

Argentina Suffered one of the World Cup’s greatest shocks as Saudi Arabia came from behind to win and you are upset about the match. Sadly you couldn’t think of anything interesting so, you started solving this problem.

Given two straight lines (Parallel to x-axis) AA and BB (distance between these two lines is a positive integer). Line AA contains nn distinct integer coordinate points on it and line BB contains mm distinct integer coordinate points on it. You need to find out the maximum number of intersections possible by drawing straight lines between any two points of line AA and BB.

For example,

Line AA has 3 points on it A1A_1 (-2, 1), A2A_2 (0, 1), A3A_3 (2, 1) and

Line BB has 2 points on it B1B_1 (-1, -1), B2B_2 (1, -1)

Draw a straight line between (A1A_1, B2B_2), (A2A_2, B1B_1), (A2A_2, B2B_2) and (A3A_3, B1B_1)

You will find three intersections between these four lines. You can see, this is the maximum number of intersections. No intersection will occur by any other line.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt.  The description of the test cases follows.

The first line of each test case consists of two integers nn and mm — total number of integer coordinate points on line AA and total number of integer coordinate points on line BB.

The second line of each test case consists of two integers AYA_Y and BYB_Y separated by space.

AYA_Y represents the YY value for all coordinates on line A.A.

BYB_Y represents the YY value for all coordinates on line B.B.

The third line of each test case consists of nn integers AXiA_{X_{i}} — Which represent the value of XX for ithi^{th}coordinate on line A.

The fourth line of each test case consists of mm integers BXiB_{X_{i}} — Which represent the value of XX for ithi^{th} coordinates on line B.

11 tt 1010

11 n,n ,mm 10510^5

102-10^2 AY,A_Y, BYB_Y 10210^2 and AYA_Y BYB_Y

105-10^5 AXiA_{X_{i}} 10510^5

105-10^5 BXiB_{X_{i}} 10510^5

Output

For each test case, output a single integer — Total number of intersections possible by drawing straight lines between any two points of line AA and line BB. The answer may be large, so output it modulo 10910^9 ++ 77.

Sample

InputOutput
1
3 2
1 -1
-2 0 2
-1 1
3

Test case 1 is explained in the statement.


Submit

Login to submit.

Statistics

0% Solution Ratio
Toph uses cookies. By continuing you agree to our Cookie Policy.