#P9006. [入门赛 #9] 神树大人挥动魔杖 (Hard Version)

[入门赛 #9] 神树大人挥动魔杖 (Hard Version)

Background

This problem has exactly the same meaning as the Easy Version, and only the constraints for n,kn, k are different.

Problem Description

Lord Divine Tree swings the wand and summons 9×10n19 \times 10^{n-1} domesticated fairies. Each domesticated fairy has a unique nn-digit ID number aia_i.

Lord Divine Tree wants to divide these domesticated fairies into kk groups. All fairies in group pp satisfy that their ID number aia_i leaves remainder p1p-1 when taken modulo kk, that is, aip1(modk)a_i \equiv p-1 \pmod k.

Lord Divine Tree wants to know how many fairies are in each group. Since the answer may be very large, you only need to output the result modulo 100,000,007100,000,007.

Input Format

The input consists of one line with two integers, in order n,kn, k.

Output Format

Output one line with kk integers separated by spaces. The ii-th integer represents the number of fairies in the ii-th group.

3 10
90 90 90 90 90 90 90 90 90 90

Hint

For 100%100\% of the testdata, 1n50001 \le n \le 5000, 1k10001 \le k \le 1000.

Translated by ChatGPT 5