Kids and Integers
시간 제한1초메모리 제한2048 MB
N 이하의 양의 정수 중 각 자리 숫자의 합을 k번 반복 적용한 값이 m이 되는 수의 개수를 10^9+7로 나눈 나머지를 구한다.
문제
This is the fourth time that Little I and Little J have played the counting game, so they have decided not to create lengthy problem statements anymore. You only need to know that they have come up with another strange rule for selecting the numbers to count, and want to figure out how many such numbers are there.
For any positive integer , we define the function as the sum of its decimal digits, for example, . Obviously, is also a positive integer, so the function can be applied repeatedly as , , and so on. For positive integers and , we define the function as with applications of .
To make the counting game different each time, the kids decided to set two positive integers and for each round, and then to specify the rule: in this round, the numbers to count are all positive integers satisfying .
As both of them are game experts, they can find arbitrarily many such integers. To prevent the game from going on forever, they also pick a positive integer in each round as the upper bound for counting. They want to know: among positive integers not exceeding , how many numbers satisfy ? Since the answer may be very large, find it modulo .
입력
The first line of the input contains one integer , representing the number of rounds Little I and Little J will play ().
Each of the next lines contains three positive integers , , describing a single round of the game (, ).
출력
For each of the rounds, print a line with a single integer: the number of numbers that cannot be counted in this round of the game, modulo .