n,k = list(map(int, input().split()))

print(((k-1)**(n-1)*k))
s=input().split()

N=int(s[0])

K=int(s[1])

print(((K-1)**(N-1)*K))
n, k = list(map(int, input().split()))
print(((k - 1) ** (n - 1) * k))

s = input().split()
N = int(s[0])
K = int(s[1])
print(((K - 1) ** (N - 1) * K))

-n, k = list(map(int, input().split())) -print(((k - 1) ** (n - 1) * k)) +s = input().split() +N = int(s[0]) +K = int(s[1]) +print(((K - 1) ** (N - 1) * K))