Score : $800$ points
In this problem, you will be given $T$ test cases for each input.
Given integers $A$, $B$, $C$, and $D$, find the number of positive integers $i$ satisfying the following condition:
We can prove from the constraints that the count is finite.
Input is given from Standard Input in the following format:
$T$ $A_1$ $B_1$ $C_1$ $D_1$ $:$ $A_T$ $B_T$ $C_T$ $D_T$
Print $T$ lines.
The $i$-th line should contain the answer for the $i$-th case ($A_i$, $B_i$, $C_i$, $D_i$).
2 3 1 2 5 99 101 103 105
1 25
The pairs $(A + B \times i, A + C \times i)$ for the first case are listed below. We can see that only $i = 3$ satisfies the condition.