#P5842. [SCOI2012] Blinker 的仰慕者

[SCOI2012] Blinker 的仰慕者

Problem Description

Blinker has many admirers, and he gives each admirer a positive integer ID. These IDs also hide a special meaning: the product of the digits of an ID represents how important this admirer is to Blinker. Now Blinker wants to know the sum of all admirer IDs between two values AA and BB, whose importance equals a fixed value KK.

Input Format

The first line contains an integer NN, which represents the number of queries Blinker wants to ask.

The next NN lines each contain three numbers AA, BB, and KK, meaning Blinker wants the sum of all admirer IDs between AA and BB whose importance is KK.

Output Format

Output NN lines. For each query, output the sum of all admirer IDs between AA and BB whose importance is KK. Since the result may be very large, take it modulo 2012042720120427.

3
1 14 4
1 30 4
10 60 5

18
40
66

Hint

Constraints

  • For 20%20\% of the testdata: 2AB1092 \le A \le B \le 10^9, 1N301 \le N \le 30.
  • For 50%50\% of the testdata: 2AB10182 \le A \le B \le 10^{18}, 1N301 \le N \le 30.
  • For 100%100\% of the testdata: 2AB10182 \le A \le B \le 10^{18}, 1N50001 \le N \le 5000.

Translated by ChatGPT 5