SP16282 TAP2013H - Horace and his primes

Description

**_\[The original version of this problem (in Spanish) can be found at [http://www.dc.uba.ar/events/icpc/download/problems/tap2013-problems.pdf](http://www.dc.uba.ar/events/icpc/download/problems/tap2013-problems.pdf "http://www.dc.uba.ar/events/icpc/download/problems/tap2013-problems.pdf")\]_** Horace likes to play writing natural numbers in the blackboard in his bedroom. One of his favourite games consists in first writing a number **n**, then the sum of all the different prime numbers that divide **n**, and so on until the number written on the board becomes a prime number. For example, if Horace begins writing the number **n = 90**, because **90 = 2 × 3 $ ^{2} $ × 5** the next number to be written will be **2 + 3 + 5 = 10**; then, as **10 = 2 × 5** Horace will write the number **2 + 5 = 7**; finally, because **7** is a prime number the game will end here. Formally, in this game each natural number n >= 2 defines a sequence whose first element is n, and each new element is the sum of all the prime numbers that divide the previous element in the sequence. The order of the game is the position of the first prime number in the sequence, and coincides with the total number of numbers written on the blackboard one the game has ended. In the example from the previous paragraph, with n = 90 the order of the game is K = 3, because the numbers that are written will be 90, 10 and 7.

Input Format

The first line contains an integer **P** which indicates the number of questions Horace wants to ask you (**1** ****P ). Each of the next **P** lines describes a question using three integer numbers **A**, **B** and **K**, which mean that Horace would like to know how many different values of **n** satisfy that **A** ****n** ****B** and the order of the game beginning with **n** is **K** (**2** ****A** ****B** ****10 $ ^{6} $** and **1** ****K** ****10 $ ^{6} $** ).******************

Output Format

You should print **P** lines, each one containing an integer number with the answer to one of the questions made by Horace, in the order in which they appear in the input.