eolymp
bolt
Try our new interface for solving problems
Məsələlər

Happy ending with happy painting

Happy ending with happy painting

Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB

After the police caught Barish, they fined him.Barish has found himself in possession of an N-unit long strip of canvas ( 1N10^6), and he intends to paint it. However, he has been unable to acquire paint brushes. In their place he has M rubber stamps of different colors (1M10^6 ), each stamp K units wide (1K10^6 ). Astounded by the possibilities that lie before him, he wishes to know exactly how many different paintings he could conceivably create, by stamping his stamps in some order on the canvas. To use a stamp, it must first be aligned with exactly K neighboring units on the canvas. The stamp cannot extend beyond the ends of the canvas, nor can it cover fractions of units. Once placed, the stamp paints the K covered units with its color. Any given stamp may be used multiple times, once, or even never at all. But by the time Barish is finished, every unit of canvas must have been painted at least once.Help Barish find the number of different paintings that he could paint, modulo 10^9+7. Two paintings that look identical but were painted by different sequences of stamping operations are counted as the same.

####Input:The numbers N, M, K are given in the first line. KN .

####Output format:A single integer: the number of possible paintings, modulo 10^9 + 7 .

####Explanation for first test case

If the two stamps have colors A and B, the possible paintings are AAA, AAB,ABB, BAA, BBA, and BBB.

Nümunə

Giriş verilənləri #1
3 2 2
Çıxış verilənləri #1
6
Mənbə IZHO 2019-2020 Azerbaijan selection contest