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

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

print(ans)

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

ans=K

for i in range(1,N):

    ans*=K-1

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

N, K = list(map(int, input().split()))
ans = K
for i in range(1, N):
    ans *= K - 1
print(ans)

-ans = K * ((K - 1) ** (N - 1)) +ans = K +for i in range(1, N): +    ans *= K - 1