rich_num

Time limit: 0.2s Memory limit: 256MB Input: Output:

Mariya has come up with the following definition for a rich number. It is given a positive integer XX. Then a positive integer NN is called a rich number (relative to XX) if the sum of its divisors except NN is greater than XX. For example, the number 1010 (whose sum of divisors is 1+2+5=81+2+5 = 8) is rich relative to X=7X=7 but it isn't rich relative to X=12X=12.

Task

Write a program to help Mariya. The program will be given queries that are ordered triples of positive integers (L,R,V)(L, R, V) and for each query it should calculate the number of rich numbers relative to VV, which are greater than or equal to LL and less than or equal to RR.

Input

The first line of the standard input contains one positive integer QQ — the number of queries that your program has to process.

Each of the next QQ lines contains three positive integers LL, RR and VV, which describe a query for your program to process.

Output

Your program should output to the standard output QQ lines — one line for each query in the order of the input. Each line should contain the answer to the corresponding query.

Constraints

  • 1Q1051 ≤ Q ≤ 10^5
  • 1LR1051 ≤ L ≤ R ≤ 10^5
  • 1V1051 ≤ V ≤ 10^5

Subtasks

Subtask 1 (5 points)

  • Q103Q \le 10^3
  • R103R \le 10^3

Subtask 2 (10 points)

  • R104R \le 10^4
  • V=10V = 10

Subtask 3 (30 points)

  • V10V \le 10

Subtask 4 (55 points)

  • No additional constraints

Example

stdin

3
5 15 5
1 20 20
12 20 10

stdout

6
2
4

Log in or sign up to be able to send submissions!