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)))

-ans = k * ((k - 1) ** (n - 1)) -print(ans) +print((k * (k - 1) ** (n - 1)))