#P8825. [传智杯 #3 初赛] 运气

[传智杯 #3 初赛] 运气

Description

Harlan Sweety is a well-known lead-loaded dice enthusiast in YYH Land. One day, he ran into the following problem:

You have a 66-faced die, labeled 1,2,3,4,5,61,2,3,4,5,6, and each face has an equal probability of landing face up.

Now Harlan wants to know: if he rolls the die nn times and writes the results in order on paper to form a number (for example, if Harlan rolls 33 times and gets 3,2,53,2,5, then the final number is 325325), how many possible outcomes make this number a multiple of kk, where kk is a given number.

Since the number of such outcomes may be very large, output the result modulo 109+710^9+7.

Input Format

One line with two integers n,kn,k, as described above.

Output Format

One line with one integer, the answer.

2 11
6

Hint

Sample Explanation

Among the 3636 possible outcomes of rolling the die twice, only ("11","22","33","44","55","66")("11","22","33","44","55","66") meet the condition. Therefore, the answer is 66.

Constraints

For 40%40\% of the testdata, nn is 1,2,3,41,2,3,4, respectively.
For another 30%30\% of the testdata, 1k31 \leq k \leq 3.
For 100%100\% of the testdata, 1n101 \leq n \leq 10 and 1k10001 \leq k \leq 1000.

Translated by ChatGPT 5