#P7836. Decision
Decision
Decision
Problem Description
Notice:Don't output extra spaces at the end of one line. Dodo and ddd rent a house together. The house has several bedrooms of different sizes. They all want to get the biggest one, so they come up with a strategy to allocate the biggest room. The strategy is as follows:
- Each of them chooses an integer in randomly, where is a constant value. Call the number chosen by them and respectively.
- Generate an array : define , for , define , where are constant values.
- If is an odd number, Dodo gets the biggest room. Otherwise, ddd gets it. ddd wants to know the probability of him getting the biggest room. Please help him to calculate it. Please output the probability by using an irreducible fraction.
Input
The first line contains an integer , indicating the number of test cases. Each test case contains one line, which contains integers $t, a, c, m(2 \leq m \leq 10^6, 0 \leq a, c < m, 0 \leq t < \frac{m}{2})$. It is guaranteed that there are at most test cases with .
Output
lines, each line contains an irreducible fraction, indicating the answer.
Sample Input
5
7 1 0 29
7 0 1 29
77 77 77 777
84 74 26 363
10 15 76 9479
Sample Output
1/2
1/8
84/169
3729/7225
71/121
Source
2020 Multi-University Training Contest 7