Problem:
 Score : 200 points    Problem Statement 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.      Constraints  1≦N≦1000  2≦K≦1000  The correct answer is at most 2^{31}-1 .         Input The input is given from Standard Input in the following format:  N  K       Output Print the number of the possible ways to paint the balls.        Sample Input 1 2 2      Sample Output 1 2  We will denote the colors by 0 and 1 . There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1 , or paint the left in color 1 and the right in color 0 .       Sample Input 2 1 10      Sample Output 2 10  Since there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())

    return K * (K-1)**(N-1)


if __name__ == '__main__':
    print(main())

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

Solution (Python):
N, K = map(int, input().split())
print(K * (K - 1) ** (N - 1))

Solution (Python):
N, K = map(int, input().split())
print(K * pow(K-1, N-1))

Solution (Python):

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

print(k*(k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split())
print(K * (K - 1) ** (N - 1))

Solution (Python):
n,k = map(int,input().split())
print((k-1)**(n-1)*k)

Solution (Python):


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

print(k*((k-1)**(n-1)))

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N,K = map(int,input().split())

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

Solution (Python):
a = [int(n) for n in input().split()]
if a[0]==1:
  print (a[1])
else:
  print (a[1]*(a[1]-1)**(a[0]-1))

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):

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

print(k*(k-1)**(n-1))

Solution (Python):
N, K = [int(i) for i in input().split()]
print(K * ((K-1) ** (N-1)))

Solution (Python):
n,k=map(int,input().split())
ans=k
for i in range(n-1):
  ans = ans*(k-1)
print(ans)

Solution (Python):
N, K =map(int, open(0).read().split())
a = K * ((K - 1) ** (N - 1))
print(a)

Solution (Python):
N,K = map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
x,y=map(int,input().split())
print(y*(y-1)**(x-1))

Solution (Python):


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

if n==1:
    print(n*k)
else:
   print(k*(k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split(' '))

res = K
for i in range(N-1):
    res *= K-1

print(res)

Solution (Python):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
N,K = map(int, input().split())
print(K * (K - 1) ** (N - 1))

Solution (Python):
N, K = map(int, input().split())
print(K * (K-1)**(N-1))

Solution (Python):
n, k = map(int, input().split())
print( k * ((k-1)**(n-1)))

Solution (Python):
n,k = map(int,input().split())
print( k * ((k-1)**(n-1)) )

Solution (Python):
N,K = map(int, input().split())
print(K * (K-1) ** (N-1))

Solution (Python):
n, k = map(int, input().split())

print(k * (k - 1) ** (n - 1))

Solution (Python):
def painting_balls_with_atcodeer(N: int, K: int) -> int:
    return K * ((K-1) ** (N-1))


if __name__ == "__main__":
    N, K = map(int, input().split())
    ans = painting_balls_with_atcodeer(N, K)
    print(ans)

Solution (Python):
N, K = map(int, input().split())
print(K*(K-1)**(N-1))

Solution (Python):
N, K = map(int, input().split())

ans = 0
for i in range(N):
    if i == 0:
        ans += K
    else:
        ans *= (K-1)

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
print(K*(K-1)**(N-1))

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
from functools import reduce

def main():
    
    

    
    

    
    
    
    
    

    
    
    
    
    X = [int(_) for _ in input().split()]
    N = X[0]
    K = X[1]
    print(K*(K-1)**(N-1))
if __name__ == '__main__':
    main()

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split(" "))
N = k
for _ in range(1, n):
   N*= (k-1)
print(N)

Solution (Python):
n, k = map(int, input().split())
total = 1
for i in range(n):
  if i == 0:
    total *= k
  else:
    total *= (k-1)
  
print(total)

Solution (Python):
n, k = map(int, input().split())
ans = k * ((k-1)**(n-1))
print(ans)

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
N,K = map(int, input().split())

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

Solution (Python):
N,k = map(int,input().split())
     
a = k*((k-1)**(N-1))
     
print(a)

Solution (Python):
n, k = map(int, input().split())
print(k * (k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())
for i in range(n):
    if i == 0:
        ans = k
    else:
        ans *= (k-1)
print(ans)

Solution (Python):
N,K=map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
N, K = map(int, input().split())
print(K * ((K-1) ** (N-1)))

Solution (Python):
n, k = map(int, input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
N,K = map(int,input().split())
ans =K
for _ in range(N-1):
    ans *= (K-1)

print(ans)

Solution (Python):

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

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

Solution (Python):
n,k=map(int, input().split())
print(k * ((k-1)**(n-1)))

Solution (Python):
N,K = map(int, input().split())

answer = 1

for i in range(N):
	if i == 0:
		answer = K
	else:
		answer = answer * (K-1)

print(answer)

Solution (Python):
n, k = map(int, input().split())
print(k * (k-1)**(n-1))

Solution (Python):

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

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

Solution (Python):
n,k = (int(i) for i in input().split())

print(k*(k-1)**(n-1))

Solution (Python):
def main():
    N, K = map(int, input().split())
    print(K * (K-1)**(N-1))


if __name__ == "__main__":
    main()

Solution (Python):
n,k = map(int,input().split())

ans = k

for i in range(n-1):
    ans*=(k-1)

print(ans)

Solution (Python):
N, K = map(int, input().split())
print(K*((K-1)**(N-1)))

Solution (Python):
n,k=[int(i) for i in input().split()]
ans=k
for i in range(1,n ):
    ans*=(k-1)
print(ans)

Solution (Python):
n,k = map(int,input().split())
sum = k
for i in range(n-1):
    sum *= k-1

print(sum)

Solution (Python):

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

print(k * ((k-1)**(n-1)))

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

Solution (Python):
N, K = list(map(int, input().split()))
result = K * ((K-1)**(N-1))
print(result)

Solution (Python):
a,b=map(int,input().split());print(b*((b-1)**(a-1)))

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):


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

Solution (Python):
N, K = list(map(int, input().split()))
ans = 1

for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= (K-1)

print(ans)

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

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

Solution (Python):
N,K = map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):



def main():
    n, k = map(int, input().split())
    print(k*(k-1)**(n-1))


if __name__ == '__main__':
    main()

Solution (Python):
N,K=map(int,input().split(' '))
print(str(K*((K-1)**(N-1))))

Solution (Python):
N, K = map(int, input().split())
pattern = K

for i in range(N-1):
    pattern *= K - 1

print(pattern)

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

Solution (Python):
n,k=map(int,input().split())
print(k * ((k - 1) ** (n - 1)))

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

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N,K = map(int,input().split())
print(K*((K-1)**(N-1)))

Solution (Python):
n, k = map(int, input().split())

print(k * ((k - 1) ** (n - 1)))

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

rem = pow(10,9)+7


x,y= (int(i) for i in input().split())       









print(y * pow(y-1,x-1))

Solution (Python):
a,b = map(int, input().split())
print(b*((b-1)**(a-1)))

Solution (Python):
N, K = [int(_) for _ in input().split()]
print(K * ((K - 1) ** (N - 1)))

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

Solution (Python):
N, K = map(int, input().split())
print(K*(K-1)**(N-1))

Solution (Python):
N, K = map(int,input().split())

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

print(ans)

Solution (Python):
N, K=map(int, input().split())
print(K*(K-1)**(N-1))

Solution (Python):
n, k = map(int, input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
n, k = map(int, input().split())
print(k * (k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split())
result = 1
for i in range(N):
    if 0 == i:
        result *= K
    else:
        result *= K-1
print(result)

Solution (Python):
n,k = map(int, input().split())
print(k*(k-1)**(n-1))

Solution (Python):
""" AtCoder """

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

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

Solution (Python):
n,k=map(int,input().split())
print(k*pow(k-1,n-1))

Solution (Python):
N, K = map(int, input().rstrip().split(' '))
r = K * (K - 1) ** (N - 1)
print(r)

Solution (Python):
N, K = [ int(x) for x in input().split() ]

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

print(ans)

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split())
print(K * (K - 1) ** (N - 1))

Solution (Python):
n,k=map(int,input().split());print(k*(k-1)**~-n)

Solution (Python):
n,k=map(int,input().split());print(k*(k-1)**~-n)

Solution (Python):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
N,K=map(int,input().split())
print(K*((K-1)**(N-1)))

Solution (Python):
def main():
    N, K = [int(_) for _ in input().split()]
    ans = K
    for i in range(N-1):
        ans = ans * (K-1)
    print(ans)
    
main()

Solution (Python):
n,k = map(int,input().split())

ans = k
for i in range(1,n):
  ans = ans*(k-1)
  
print(ans)

Solution (Python):
n,k =(int(i) for i in input().split())
ans = k
for i in range(n-1):
  ans *= (k-1)
print(ans)

Solution (Python):
N, K = map(int, input().split())
print(K*(K-1)**(N-1))

Solution (Python):
import sys

def main():
	n, k = map(int, input().split(" "))

	ans = 1
	ans = ans * k
	k = k-1
	for _ in range(n-1):
		ans = ans * k

	print(ans)

if __name__ == "__main__":
	main()

Solution (Python):
n,k=[int(i) for i in input().split()]
print(k*((k-1)**(n-1)))

Solution (Python):
N, K = map(int, input().split())
print(K*((K-1)**(N-1)))

Solution (Python):
N,K = map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
N,K=map(int,input().split())
A=K*(K-1)**(N-1)
print(A)

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n ,k = map(int, input().split())

print(k*(k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())
print(k * pow(k-1, n-1))

Solution (Python):
n, k = map(int, input().split())
a = k
for i in range(n - 1):
  a *= k - 1
print(a)

Solution (Python):
n, k = map(int, input().split())
print(k * ((k - 1) ** (n - 1)))

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N, K = list(map(int, input().split()))
print(K*pow(K-1, N-1))

Solution (Python):
N, K = map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
N, K = map(int, input().split())
print(K * (K-1)**(N-1))

Solution (Python):
n, k = map(int, input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N,K = map(int,input().split())
print(K*pow(K-1,N-1))

Solution (Python):

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

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N, K = map(int,input().split())
print(K*((K-1)**(N-1)))

Solution (Python):
N, K = map(int, input().split())
print(K*(K-1)**(N-1))

Solution (Python):
a,b=map(int,input().split())
ans=b
for  i in range(a-1):
  ans*=(b-1)
print(ans)

Solution (Python):
N,K = map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
n, k = map(int, input().split())
print(k if n==1 else k*(k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())
print(k*pow(k-1,n-1))

Solution (Python):
n,k=input().split()
N=int(n)
K=int(k)
print(K*((K-1)**(N-1)))

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
n,k=map(int,input().split())
ans=k
for i in range(n-1):
  ans=ans*(k-1)
print(ans)

Solution (Python):
n,k=map(int,input().split())
print(((k-1)**(n-1))*k if n!=1 else k)

Solution (Python):
n,k = map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
nk = list(map(int, input().split()))
print(nk[1]*((nk[1]-1)**(nk[0]-1)))

Solution (Python):
N, K = [int(x) for x in input().split()]
print(K * ((K - 1) ** (N - 1)))

Solution (Python):
N, K = map(int, input().split())

if N==1:
    print(K)
    exit(0)
else:
    print(K*((K-1)**(N-1)))

Solution (Python):
n, k = map(int, input().split())

print(k * ((k - 1) ** (n - 1)))

Solution (Python):
n,k=map(int,input().split())
s=k
k-=1
for i in range(n-1):
    s*=k
print(s)

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split())
print(K * (K - 1) ** (N - 1))

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n,k=map(int,input().split())
ans=k
for s in range(n-1):ans*=(k-1)
print(ans)

Solution (Python):
n,k=map(int,input().split())
ans = k*((k-1)**(n-1))
print(ans)

Solution (Python):
N, K = map(int, input().split())
comb = K*(K-1)**(N-1)
print(comb)

Solution (Python):
a,b=[int(i) for i in input().split()]
print(b*((b-1)**(a-1)))

Solution (Python):
N, K = [int(x) for x in input().split()]

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

print(ans)

Solution (Python):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
n, k = map(int, input().split())
print(k * (k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())
if n == 1:
    print(k)
else:
    print(k * (k - 1) ** (n - 1))

Solution (Python):
N, K = map(int, input().split())
if N > 1:
    print(K * ((K - 1)**(N - 1)))
else:
    print(K)

Solution (Python):
n, k = map(int, input().split())
print(k*pow(k-1, n-1), end="")

Solution (Python):
N,K=map(int,input().split())
if N==1:
     print(K)
else:
     n=K*(K-1)**(N-1)
     print(n)

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

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

print(ans)

Solution (Python):
n,k=map(int,input().split())
ans=k
for i in range(n-1):
    ans*=(k-1)
print(ans)

Solution (Python):
ball,color=map(int,input().split())
if color == 1 and ball ==  1:
	print(str(1))
else:
	print(str(color * ((color-1)**(ball-1))))

Solution (Python):
n,k=(int(i) for i in input().split())

ans=k
for i in range(n-1):
  ans=ans*(k-1)
  
print(ans)

Solution (Python):
n,k = (int(i) for i in input().split())
if n == 1:
  ans = k
else:
  ans = k*(k-1)**(n-1)
print(ans)

Solution (Python):

from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
mod = 1000000007


n,k = LI()
ans = k
for i in range(1,n):
    ans *= k-1
print(ans)

"""
r,n,m = LI()
l = [2*r*math.cos(math.asin((n/2-i)/n*2)) for i in range(n+1)]
ans = 0
for i in range(1,n+m):
    a = 0 if i-m <= 0 else l[i-m]
    b = 0 if i >= n else l[i]
    ans += max(a,b)
print(ans)
"""


"""
n = II()
a = LI()
print(sum(a)-n)
"""


"""
s = list(S())
lis = []
sign = ["","+"]
k = 2**(len(s)-1)
d = 10-len(s)
for i in range(d):
    s.insert(0,"0")
i = 0
for a0 in range(2):
    for a1 in range(2):
        for a2 in range(2):
            for a3 in range(2):
                for a4 in range(2):
                    for a5 in range(2):
                        for a6 in range(2):
                            for a7 in range(2):
                                for a8 in range(2):
                                    if i >= k:break
                                    lis.append(s[0]+sign[a0]+s[1]+sign[a1]+s[2]+sign[a2]+s[3]+sign[a3]+s[4]+sign[a4]+s[5]+sign[a5]+s[6]+sign[a6]+s[7]+sign[a7]+s[8]+sign[a8]+s[9])
                                    i += 1
ans = 0
for i in lis:
    ans += eval(i[d:])
print(ans)
"""

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

Solution (Python):

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

print(k*(k-1)**(n-1))

Solution (Python):

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

print(k*(k-1)**(n-1))

Solution (Python):

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

print(k*(k-1)**(n-1))

Solution (Python):

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

Solution (Python):
N, K = list(map(int, input().strip().split()))

ans = K
for n in range(1, N):
  ans *= (K-1)
  
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, K = il()
    return K * (K - 1) ** (N - 1)


if __name__ == "__main__":
    print(solve())

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N,K = map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
N, K = map(int, input().split())
print(K * ((K - 1) ** (N - 1)))

Solution (Python):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
def execute(n, k):
    return k * (k - 1) ** (n - 1)


if __name__ == '__main__':
    n, k = map(int, input().split())
    print(execute(n, k))

Solution (Python):
N, K = map(int, input().split())

ans = K
for _ in range(N - 1):
    ans *= K - 1

print(ans)

Solution (Python):
N,K = map(int,input().split())
ans = K * pow(K-1,N-1)
print(ans)

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
tmp = list((map(int, input().split())))
N = tmp[0]
K = tmp[1]

def paint(n,k):
    ans = k
    if n == 1:
        return ans
    else:
        for i in range(n-1):
            ans *= k-1
        return ans

print(paint(N,K))

Solution (Python):
n, k = map(int, input().split())
print(k * (k - 1) ** (n - 1))

Solution (Python):

N, K = [int(x) for x in input().split()]

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

Solution (Python):
N,K = map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
a,b=map(int,input().split())
print(b*((b-1)**(a-1)))

Solution (Python):
n,k=map(int,input().split())
if n==1:
    print(k)
else:
    print(k*(k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split())
print(K) if N == 1 else print(K*(K-1)**(N-1))

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

Solution (Python):
n, k = [int(x) for x in input().split()]
print(k * (k - 1) ** (n - 1))

Solution (Python):
n, k = map(int, input().split())

print(k * ((k - 1) ** (n - 1)))

Solution (Python):
a, b = map(int, input().split())
ans = b
for i in range(a-1):
    ans*=(b-1)
print(ans)

Solution (Python):
n, k = map(int, input().split())

print(k * ((k - 1) ** (n - 1)))

Solution (Python):
N,K = map(int,input().split())
S = K
while(1):
    if N==1:
        break
    S *= (K-1)
    N-=1
print(S)

Solution (Python):
N, K = map(int, input().split())

ans = K

for _ in range(N - 1):
    ans *= (K - 1)

print(ans)

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n, k = [int(i) for i in input().split()]

ans = k
for i in range(1, n):
    ans *= (k-1)

print(ans)

Solution (Python):
a,b=map(int,input().split())
print((b-1)**(a-1)*b)

Solution (Python):
a,b =map(int, input().split())
s = b
t = (b-1)**(a-1)
s*=t
print(s)

Solution (Python):
N, K = map(int, input().split())
result = K * (K-1)**(N-1)
print(result)

Solution (Python):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n,k=map(int,input().split())
a=1
f=True
for i in range(n):
  if f:
    a*=k
    f=False
  else:
    a*=k-1
print(a)

Solution (Python):
temp = input().rstrip().split(" ")
N = int(temp[0])
K = int(temp[1])
ans = K * (K - 1)**(N - 1)
print(ans)

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

Solution (Python):
n, k = map(int, input().split())
print(k * (k - 1) ** (n - 1))

Solution (Python):
n,k = map( int, input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
N, K = map(int,input().split())

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

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
def main():
    n, k = map(int, input().split())
    res = k * ((k - 1)**(n - 1))
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
n, k = [int(i) for i in input().split()]
print(k * (k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())
print(k * ((k-1)**(n-1)))

Solution (Python):
N,K=map(int,input().split())
print(K*(K-1)**(N-1))

Solution (Python):
import math
N ,K = map(int, input().split(" "))
print(int(K * math.pow(K-1, N-1)))

Solution (Python):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
line = input().split(" ")
n = int(line[0])
k = int(line[1])

print(((k - 1)**(n - 1)) * k)

Solution (Python):
N, K = map(int, raw_input().split())
print K*((K-1)**(N-1))

Solution (Python):
N, K = [int(i) for i in input().split()]

patterns = K
for i in range(N-1) :
	patterns *= (K-1)

print(patterns)

Solution (Python):
n, k = map(int, input().split())
print(k*(k-1)**(n-1))

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

Solution (Python):
n,k = map(int,input().split())
ans = 1
for i in range(n):
    if i == 0:
        ans = ans*k
    else:
        ans = ans*(k-1)
print(ans)

Solution (Python):
n,k = map(int,input().split())

c = k

for i in range(n-1):
    c *= k-1

print(c)

Solution (Python):
N,K = map(int, input().split())

if N <= 2:
    print(K)
else:
    ans = K*(K-1)
    for i in range(N-2):
        ans *= K-1

    print(ans)

Solution (Python):


import sys

def solve(n, k):
    ans = k
    for i in range(2,n+1):
        ans *= (k-1)
    print(ans)


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    k = int(ws[1])
    return (n, k,)

def main():
    solve(*readQuestion())


main()

Solution (Python):
N, K = map(int, input().split())
ans = 0


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

Solution (Python):
N, K = [int(_) for _ in input().split()]
print(K * (K - 1)**(N - 1))

Solution (Python):
N, K = map( int, input().split())
print(K*pow(K-1,N-1))

Solution (Python):
ball,color = list(map(int,input().split()))
print(color*((color-1)**(ball-1)))

Solution (Python):
n, k = map(int, input().split())
print(k * (k-1) ** (n-1))

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

Solution (Python):
N,K=map(int,input().strip().split(" "))
print(K*((K-1)**(N-1)))

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
n,k = map(int,input().split(" "))
goukei = k*(k-1)**(n-1)
print(goukei)

Solution (Python):
n,k = map(int, input().split())
ans = k
for _ in range(n-1):
    ans *= (k-1)
    
print(ans)

Solution (Python):
N, K = map(int, input().split())
answer = K * ((K-1)**(N-1))
print(answer)

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
N, K = [int(x) for x in input().split()]
print(K * (K - 1) ** (N - 1))

Solution (Python):
ball, color = map(int, input().split())

print(color*(color - 1)**(ball - 1))

Solution (Python):
ball, color = map(int, input().split())

ans = color
for i in range(ball - 1):
    ans *= (color - 1)
print(ans)

Solution (Python):



def abc046_b():
    n, k = map(int, input().split())
    return k * ((k - 1) ** (n - 1))


if __name__ == '__main__':
    print(abc046_b())

Solution (Python):
a,b=map(int,input().split(" "))
print(b*(b-1)**(a-1))

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

Solution (Python):
N, K = map(int, input().split())
print(K * (K-1) ** (N - 1))

Solution (Python):
N,K=input().split()
n=int(N)
k=int(K)
print(k*((k-1)**(n-1)))

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):

n,k = (int(_) for _ in input().split())

ans = k
for i in range(n-1):
    ans *= (k-1)
    
print(ans)

Solution (Python):

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

Solution (Python):
N, K = map(int, raw_input().split())
print K*(K-1)**(N-1)

Solution (Python):
N, K = map(int, input().split())
way = K

for i in range(N-1):
  way *= K-1

print(way)

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split())
print(K * ((K-1) ** (N-1)))

Solution (Python):
n, k = map(int, input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())
print((k - 1) ** (n - 1) * k)

Solution (Python):
N, K = map(int, input().split())
print(K * (K - 1) ** (N - 1))

Solution (Python):
n, k = map(int, input().split())
print(k * (k - 1)**(n-1))

Solution (Python):
N,K=map(int,input().split())
print(K*((K-1)**(N-1)))

Solution (Python):
n, k = map(int, input().split())
ans = k
for x in range(n-1):
    ans *= k-1
print(ans)

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

Solution (Python):
n,k = map(int,input().split())
print(k * (k-1)**(n-1))

Solution (Python):
n,k=map(int,input().split())
a=k
for i in range(n-1):
    a*=(k-1)
print(a)

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n, k = map(int,input().split())
print(k * (k-1)**(n-1))

Solution (Python):
N, K = map(int, input().split())

count = 1
for i in range(N):
    if i == 0:
        count *= K
    else:
        count *= (K-1)

print(count)

Solution (Python):
def main():
    N, K = map(int, input().split())
    res = 0
    if N == 1:
        res = K
    else:
        res = K * (K - 1) ** (N - 1)

    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin


def main():
    n = next_int()
    k = next_int()
    ans = 1

    for i in range(n):
        ans *= k - (i != 0)

    print(ans)


def next_int():
    return int(next_str())


def next_str():
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Solution (Python):

from sys import stdin

n,k = [int(x) for x in stdin.readline().rstrip().split()]

print((k-1)**(n-1) * k)

Solution (Python):
a = input().split(" ")
count = int(a[1])
for i in range(int(a[0])-1):
    count *= int(a[1]) - 1
print(count)

Solution (Python):
def main():
    N, K = map(int, input().split())
    answer = K
    for i in range(N - 1):
        answer *= (K - 1)
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
iN,iK = [int(_) for _ in input().split()]
print(iK*((iK-1)**(iN-1)))

Solution (Python):


"""
    1≦N≦1000
    2≦K≦1000
    答えは 2^(31)−1 以下
"""
test_mode = True

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

Solution (Python):
n,k = map(int,input().split())

print(k*(k-1)**(n-1))

Solution (Python):
N,K=map(int,input().split())
cnt=1
for i in range(N):
    if i==0:
        cnt=cnt*K
    else:
        cnt=cnt*(K-1)
print(cnt)

Solution (Python):
N,K=map(int,input().split())
Ans=K*(K-1)**(N-1)
print(Ans)

Solution (Python):
N, K = map(int, input().split())
if N==1:
    print(K)
else:
    print(K*((K-1)**(N-1)))

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

Solution (Python):
N,K = (int(i) for i in input().split())

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

Solution (Python):
input_list = list(map(int, input().split()))
n = input_list[0]
k = input_list[1]
ans = k

for _ in range(n-1):
    ans = ans * (k-1)
print(ans)

Solution (Python):
n,k = map(int,input().split())
print(k*(k-1)**(n-1))

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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


if __name__ == '__main__':
    main()

Solution (Python):
N,K=map(int, input().split())
print(K*(K-1)**(N-1))

Solution (Python):
n, k = map(int, input().split())

print(int(k*(k-1)**(n-1)))

Solution (Python):
N, K = map(int, input().split())
print(K * (K-1)**(N-1))

Solution (Python):
n,k=map(int,input().split());print(k*(k-1)**(n-1))

Solution (Python):
n, k = map(int, input().split())

ans = 0

for i in range(n):
    if i == 0:
        ans = ans + k

    else:
        ans = ans * (k - 1)

print(ans)

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

print(ans)

Solution (Python):
a, b = map(int, raw_input().split())
print b * ((b - 1) ** (a - 1))

Solution (Python):
a, b = map(int, raw_input().split())
print b * ((b - 1) ** (a - 1))

Solution (Python):
n, k = [int(i) for i in input().split()]
print(k * (k - 1) ** (n - 1))

Solution (Python):
N,K = map(int,input().split())
answer = K * ((K-1)**(N-1))
print(answer)

Solution (Python):
n,k=map(int, input().split())
print(k*(k-1)**(n-1))

Solution (Python):
n,k=map(int,input().split())
print(k*(k-1)**(n-1))