This problem is a programming version of Problem 214 from projecteuler.net
Let be Euler's totient function, i.e. for a natural number , is the number of , for which .
By iterating , each positive integer generates a decreasing chain of numbers ending in .
E.g. if we start with the sequence is generated.
For an integer , denote the length of its chain. For example, and .
Let be the sequence of prime numbers (, , ...), and consider two positive integers and . We define the set as:
The first line of each test file contains three space-separated integers , (as described above) and which is the number of queries.
Each of the next lines contains a value of .
Print the answer to each query in a new line.
3 2 5