Given two positive integers **n** , **m** . The task is to count the number of different array that can be formed of size **n** such that each element is between **1** to **m** and two consecutive element are different. Also, the first and last elements of each array should be same.

Print Answer of modulo of 10^9 + 7.

Expected TC: O(logn)

Contraints: 3 <= N, M <= 10^18

I/p O/p

3 3 --> 6

3 4 --> 12

4 4 --> 24