insignificant trolling

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Because people like to troll on P1, insignificant is very worried about LCC. He realized that each of his N teammates has a \frac{1}{M} chance to troll during the contest. Help him find the chance that at least 1 person does not troll during the contest.

Assume that trolling is an independent event. Then, P(A \cap B) = P(A) \times P(B). In other words, the chance that event A and B occurs at the same time is the probability of A occurring multiplied by the probability of B occurring.

Input Specification

The first line will contain N, M\ (1 \le N, M \le 10^6).

Output Specification

Calculate the probability times M^N (which will be an integer). Because this number can be very large, print it modulo 10^9 + 7.

Sample Input

5 6

Sample Output

7775

Comments

There are no comments at the moment.