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

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

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

dp=[[0 for _ in range(n+1)] for _ in range(k+1)]

for i in range(n+1):
  for j in range(k+1):
    if i>1 and j>0:
      dp[j][i]=(j-1)*dp[j][i-1]
    elif i==1 and j>0:
      dp[j][i]=j
    else:
      dp[j][i]=0

print(dp[k][n])

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

Solution (Python):
import sys
input = sys.stdin.readline

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=1
for i in range(N):
  if i==0:
    ans*=K
  else:
    ans*=(K-1)
print(ans)

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

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

print(ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, K = mi()
    ans = K
    for i in range(N-1):
        ans *= K-1
    print(ans)


if __name__ == '__main__':
    main()

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

def main(n,k):
    ans=k
    for i in range(1,n):
        ans=ans*(k-1)
        if ans >2**31-1:
            return 2**31-1
    return ans

if __name__=='__main__':
    n,k=readinput()
    ans=main(n,k)
    print(ans)

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):
def ABC046_B():
    import numpy as np
    n,k = map(int,input().split())


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

    print(ans)
    

ABC046_B()

Solution (Python):
n,k = map(int,input().split())
ans = k*(k-1)**(n-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())
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,M = map(int,input().split())
print(M*(M-1)**(N-1))

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


print(K*1*(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-1)**(N-1)*K)

Solution (Python):
s=input().split(' ')

a=[int(s[0]),int(s[1])]

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):
x = list(map(int,input().split()))
a = x[0]
b = x[1]
print(b*((b-1) ** (a-1)))

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

i=1
ans=k
while i<n:

    ans=ans*(k-1)
    i+=1

print(ans)

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

if __name__ == '__main__':
    main()

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

Solution (Python):
N,K = map(int,input().split())
if N ==1:
    ans=K
else:
    ans = K * ((K-1)**(N-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())

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

print(ans)

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

print(M*(M-1)**(N-1))

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

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

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

if N==1:
  ans = K
elif K==1:
  ans = N
else:
  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())
ans=K*(K-1)**(N-1)
print(ans)

Solution (Python):


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

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

Solution (Python):
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,k = readInts()
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())

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

print(pat)

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):
s = input()
slist = s.split(' ')
n = int(slist[0])
k = int(slist[1])

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

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())
ans = K*(K-1)**(N-1)
print(ans)

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

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

print(ans)

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(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*(K-1)**(N-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):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

n, k = ri_()
print(k * ((k - 1) ** (n - 1)))

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

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

Solution (Python):
import sys
INF = 1 << 60
MOD = 10**9 + 7 
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    print(k * pow(k - 1, n - 1))
resolve()

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    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())

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=map(int,input().split()) 
print((k-1)**(n-1)*k)

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

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n, k = LI()
	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())

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

print(ans)

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

Solution (Python):



import os
import sys







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


if __name__ == '__main__':
    main()

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

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())
res = K
for i in range(1, N):
    res *= K-1
print(res)

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

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())
print((k-1)**(n-1)*k)

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

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

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

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

Solution (Python):
import math
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())
res = K
for i in range(N - 1):
    res *= K - 1
print(res)

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

Solution (Python):
nums = [int(e) for e in input().split()]
val = nums[1]
for i in range(nums[0]-1):
    val = val*(nums[1]-1)
print(val)

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):
import math
N, K = map(int, input().split())
ans = K
ans *= 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-1))

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())
ans = k
for i in range(1, n):
    ans *= k-1
print(ans)

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())
sum = K
for i in range(N-1):
        sum *= K-1
print(sum)

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

Solution (Python):
def countpattern(N, K) :
  pattern = K
  for i in range(1, N) : 
    pattern *= K - 1
    
  return pattern

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

print(countpattern(N, K))

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())
print(K*pow(K-1,N-1))

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

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

n ,k = I2()
print(k*(k-1)**(n-1))

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

if K == 2:
    print(2)
else:
    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())
print(k*(k-1)**(n-1))

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    print(pow(k-1,n-1)*k)

main()

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().strip().split())


def func(balls, colors):
    combination = colors * (colors - 1) ** (balls - 1)
    print(combination)


func(balls=n, colors=k)

Solution (Python):
import sys
import math
def v():
    n,k=tuple(map(int,sys.stdin.readline().split()))
    res=k*(k-1)**(n-1)
    print(res)
if __name__=='__main__':v()

Solution (Python):
import math

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

print(int(math.pow(k-1, n-1) * k))

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

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

Solution (Python):

import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


n, k = invr()

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

print(c)

Solution (Python):
n,k=map(int,input().split())
sum=k
if n>1:
  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 = map(int, input().split())
print(k * (k - 1) ** (n - 1) if n > 1 else k)

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 *= (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 * pow(K-1, N-1))

Solution (Python):
import sys
import math
import itertools

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

Solution (Python):
import math 
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 = input().split()
N = int(N)
K = int(K)
print(K*pow(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*pow(k-1, n-1))

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

Solution (Python):
a, b = map(int, input().split())

print(b * (b - 1) ** (a - 1))

Solution (Python):
"""解説から
1. Bi(1<=i<=N)のボールの中の左端B1のボールに塗る色を決める(K通り)
2. 2<=i<=Nのボールの塗る色を順に決めていく
    この時、B(i-1)のボールと異なる色であれば何色で塗ってもよい(K-1通り)
3. 1と2の前提からK*(K-1)**(N-1)通りの塗り方ができる
"""
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) if N>=2 else K)

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 * (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):
a=input().split(" ")
part=0
 
for i in range(int(a[0])):
	if i==0:
		part=int(a[1])
	else:
		part=part*(int(a[1])-1)
 
print(part)

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 sys
from math import factorial
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") 

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 = [int(_) for _ in input().split()]

cases = K

for n in range(N-1):
    cases *= (K - 1)

print(cases)

Solution (Python):
import sys

number = sys.stdin.readline().split(' ')

N = int(number[0])
K = int(number[1])

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 *= 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 - 1)**(n - 1))*k
print(ans)

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-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())
ans=k
for i in range(n-1):
    if k>1:
        ans*=k-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())
print((K - 1) ** (N - 1) * K)

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

print(sum)

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

Solution (Python):
import collections
 

def inputStrOnebyOne():
    s = list(input())
    return s
 

def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
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())
answer=K

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

print(answer)

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):
N,K = map(int,input().split())
L = K
for i in range(N-1):
    L *= (K-1)
print(L)

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

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

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 * ((K - 1) ** (N - 1)))

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

Solution (Python):






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





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

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

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


resolve()

Solution (Python):
def combination(n, r):
    res_n = 1
    res_r = 1

    for _ in range(r):
        res_n *= n
        n -= 1

    for _ in range(r):
        res_r *= r
        r += 1

    return res_n // res_r

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

res = 0
for i in range(n):
    if i == 0:
        res = combination(k, 1)
    else:
        res *= combination(k - 1, 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())
ans = K
for i in range(N-1):
  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())
res = K*(K-1)**(N-1)
print(res)

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N,K = IL()

P(K*(K-1)**(N-1))

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

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

print(ret)

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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())
ans = k * (k-1) ** (n-1)
print(ans)

Solution (Python):


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

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

Solution (Python):
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))
li = LI()

n,k = [li.pop(0) for i in range(2)]

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

print(ans)

Solution (Python):
def main():
  num = list(map(int,input().split()))
  ans=num[1]
  for i in range(1,num[0]):
    ans*=(num[1]-1)
  print(ans)
    
main()

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 = list(map(int,input().split()))

if a[0] == 1:
  answer = a[1];
else:
  answer = a[1]*(a[1]-1)**(a[0]-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())


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

print(p)

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

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

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

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

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

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())
print(K * (K - 1) ** (N - 1))

Solution (Python):


import sys



























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    print(k * pow(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())
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())
print(b*(b-1)**(a-1))

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

Solution (Python):
import math
import copy

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

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*pow(K-1,N-1))

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