Question
Last Survivor
In a different world, there live two violent groups of people, say Group X and Group Y. One day, a fight starts between the two groups, and they start killing people of other groups. As soon as two people from different groups encounter each other, one kills the other. Any person in group X kills any other person in group Y with probability Pxy, and any person in group Y kills any other person in group Y with probability 1 - Pxy. Assume at once only one fight takes place between two people.
You have been given Pxy as a fraction x/y and the initial population of group X and group Y as Nx and Ny.
Calculate the probabilities as a fraction that
- at the end of the fight, only people of group X survive and
- at the end of the fight, only people of group Y survive.
Input
The first line contains a single integer T, the number of test cases. The description of the test cases follows.
The first line contains two integers x and y, where x/y equals Pxy, the probability that any person of group X kills any other person of group Y in a fight.
The second line of each test case contains two integers Nx and Ny, the initial populations of group X and group Y respectively.
Constraints
1 ≤ T ≤ 5
1 ≤ Nx ≤ 103
1 ≤ Ny ≤ 103
0 ≤ x ≤ y
1 ≤ y ≤ 104
The first line contains two integers x and y, where x/y equals Pxy, the probability that any person of group X kills any other person of group Y in a fight.
The second line of each test case contains two integers Nx and Ny, the initial populations of group X and group Y respectively.
Constraints
1 ≤ T ≤ 5
1 ≤ Nx ≤ 103
1 ≤ Ny ≤ 103
0 ≤ x ≤ y
1 ≤ y ≤ 104
Output
If your final calculated fraction is X/Y then output a single integer I = X . Y-1 (mod 109 + 7), where Y-1 denotes the modular multiplicative inverse of Y modulo 109 + 7.
Output two integers C and D, where C and D are integers corresponding to each fraction (as stated above), where the first fraction is the probability that only Group X survives at the end and the second fraction is the probability that only Group Y survives at the end.
Output two integers C and D, where C and D are integers corresponding to each fraction (as stated above), where the first fraction is the probability that only Group X survives at the end and the second fraction is the probability that only Group Y survives at the end.
Example
Sample Input
2
2 5
10 6
1 2
99 99
Sample Output
763421656 236578352
500000004 500000004
2
2 5
10 6
1 2
99 99
Sample Output
763421656 236578352
500000004 500000004