#d11206. LCM与GCD

LCM与GCD

LCM and GCD

Problem Description

Given three positive integers x,y,kx, y, k, find the number of ordered pairs (a,b)(a, b) satisfying

$$x \times \operatorname{lcm}(a,b) - y \times \gcd(a,b) = k$$

where lcm⁡(a,b)\operatorname{lcm}(a,b) is the least common multiple of aa and bb, and gcd⁡(a,b)\gcd(a,b) is their greatest common divisor.

If a≠ba \neq b, then (a,b)(a,b) and (b,a)(b,a) are considered two different ordered pairs.

Input Format

The first line contains an integer tt, the number of test cases (1≤t≤1031 \le t \le 10^3).

Each of the next tt lines contains three integers x,y,kx, y, k as described above (1≤x,y,k≤1071 \le x, y, k \le 10^7).

Output Format

Output tt lines, each containing one integer: the number of valid ordered pairs.

Sample Input

4
1 1 3
4 2 6
3 3 7
2 7 25

Sample Output

4
3
0
8