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

ans = K * ((K - 1) ** (N - 1))

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

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

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

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