Gats's Growing Jumps
Gats starts at position on an infinite path. Fish stalls are located at every position divisible by .
His first jump has length . Every subsequent jump is times as long as the preceding jump. Therefore, the -th jump has length , and after exactly jumps Gats is at position
A jump count is called successful if Gats is at a fish stall after exactly jumps; equivalently, .
For each test case, determine how many successful jump counts satisfy .
Input
The first line contains an integer (), the number of test cases.
Each of the next lines contains four integers , , , and (, , , ).
Output
For each test case, print one integer: the number of successful jump counts satisfying .
Samples
Sample 1
Input
4 10 3 7 20 10 6 12 20 3 2 8 10 5 4 4 7
Output
3 0 5 7
In the first test case, the successful jump counts are , , and . In the second test case, there are no successful jump counts. In the third test case, they are , , , , and . In the final test case, every jump count from through is successful.