There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors.  Find the number of the possible ways to paint the balls.
N,K = map(int,input().split())

print(K*((K-1)^(N-1)))

N,K = map(int,input().split())

print(K*((K-1)**(N-1)))
