There are ( N ) balls placed in a row. AtCoDeer, the deer, is painting each of these balls using one of his ( K ) paint colors. For aesthetic reasons, any two adjacent balls must be painted in different colors.
Your task is to determine the number of possible ways to paint the balls according to these constraints.
Input Format
The first line contains two integers, ( N ) and ( K ):
( N ) (1 ≤ ( N ) ≤ 10^5): The number of balls.
( K ) (1 ≤ ( K ) ≤ 10^5): The number of available colors.
Output Format
Output a single integer: The number of valid ways to paint the ( N ) balls modulo ( 10^9 + 7 ).
Examples
Example 1
Input:
text
3 2
Output:
text
6
Explanation: There are 6 ways to paint 3 balls with 2 colors:
Color 1, Color 2, Color 1
Color 1, Color 2, Color 2
Color 2, Color 1, Color 2
Color 2, Color 1, Color 1
Color 1, Color 1, Color 2
Color 2, Color 2, Color 1
Example 2
Input:
text
5 3
Output:
text
36
Solution Directory
Please place your solution in the /app/ directory.
Important: place your implementation at /app/solution.py so the verifier can run it.