P16859 [HackerEarth] Asha is an aspiring mathematician. One day she discovered numbers that she calls prosperous numbers. A prosperous number is a positive integer such that its every digit is greater than o
提高-
题目描述

Asha is an aspiring mathematician. One day she discovered numbers that she calls prosperous numbers. A prosperous number is a positive integer such that its every digit is greater than or equal to the digit preceeding it (if it exists). The first prosperous number is 1. Notice that this means that none of the prosperous numbers may contain the digit 0. She defines the following attributes of these numbers -

a) degree - the maximum difference of two consecutive digits of the prosperous number.

b) strength - the sum of all digits of the number

For example - some of the prosperous numbers with their degree and strength are:

Prosperous number Degree Strength
5 0 5
28 6 10
399 6 21
444 0 12
5789 2 29
12345 1 15

You are helping her find the number of prosperous numbers that exist given the degree and strength.

Input Format :
The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with one line with two integers, S and D, which represent the strength and degree respectively.

Output Format:
For each test case, output one line containing "Case #x:", where x is the test case number (starting from 1). Then, for every test case, output the total number of possible prosperous numbers of strength S and degree D. Because this number can be quite large, you only need to print the answer modulo 1000000007.

Constraints:
0 < T ≤ 20

0 < S ≤ 10^5

SAMPLE INPUT
4
2 0
10 1
12 4
15 8

SAMPLE OUTPUT
Case #1: 2
Case #2: 11
Case #3: 9
Case #4: 1

Explanation

For the first test case, there are two possible prosperous numbers - 2 and 11.

For the second test case, there are eleven possible prosperous numbers - 334, 1234, 2233, 11233, 12223, 111223, 112222, 1111123, 1111222, 11111122 and 111111112.

For the third test case, there are nine possible prosperous numbers - 48, 156, 237, 1137, 1155, 2226, 11226, 111126 and 11111115.

For the fourth test case, there is only one possible prosperous number - 1111119.

输入格式

见题面

输出格式

见题面

样例输入
20 12 3 11 3 19 8 20 8 100 8 199 8 1000 7 2000 7 5544 7 10000 7 12000 7 29000 8 31000 7 5000 6 8888 7 9999 3 10009 8 20007 7 30012 3 50000 4
样例输出
Case #1: 1 Case #2: 1 Case #3: 2 Case #4: 475723 Case #5: 736382421 Case #6: 548289018 Case #7: 530408452 Case #8: 218997846 Case #9: 723210146 Case #10: 435002227 Case #11: 680114866 Case #12: 101255806 Case #13: 545178478 Case #14: 86791666 Case #15: 154524481 Case #16: 149887758 Case #17: 800835848 Case #18: 98050270 Case #19: 607262533 Case #20: 98050270