Bessie has an N unit long strip of canvas (1≤N≤106), and she intends to paint it. She was unable to acquire any paint brushes. In their place she has M rubber stamps of different colors (1≤M≤106), each stamp K units wide (1≤K≤106). She wants to know exactly how many different paintings she could create by stamping her stamps on the canvas in some order.
To use a stamp, align it with exactly K neighboring units of the canvas. The stamp cannot extend beyond the ends of the canvas, and it cannot cover a fraction of a unit. Once placed, the stamp paints the K covered units with its color. Any given stamp may be used many times, once, or never at all. By the time Bessie is finished, every unit of the canvas must have been painted at least once.
Count the paintings Bessie could produce, modulo 109+7. Two paintings that look identical but were made by different sequences of stamping operations count as the same painting.