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
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    print(K*((K-1)**(N-1)))
if __name__ == '__main__':
    main()

Solution (Python):
import math
from string import ascii_lowercase

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

Solution (Python):
import sys

data = sys.stdin.readline().rstrip()
N, K = data.split(" ")
N = int(N)
K = int(K)

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())
ans = k * pow(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, K = map(int,input().split())

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

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

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

Solution (Python):
N,K = 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())
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(item) for item 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 itertools

N, K = [int(i) for i in input().split()]
a = [0] * K
c = [0] * (K - 1)
b = len(list(itertools.combinations(a,1)))

e = len(list(itertools.combinations(a,1)))

for i in range(N - 1):
    e *= len(list(itertools.combinations(c,1)))
    
print(e)

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

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
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):
def examB():
    N, K = LI()
    ans = K*((K-1)**(N-1))
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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

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

print(ans)

Solution (Python):

n, k = [int(s) for s in input().split()]

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

Solution (Python):
a=list(map(int,input().split()))
print(((a[1]-1)**(a[0]-1))*a[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())
S = K * (K-1) ** (N-1)
print(S)

Solution (Python):
import sys
sys.setrecursionlimit(10000)


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

    TABLE = [[-1 for x in range(K + 3)] for y in range(N + 3)]

    def recur(i, k):
        if not i < N:
            return 1

        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)

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

    TABLE = [[-1 for x in range(K + 3)] for y in range(N + 3)]

    def recur(i, k):
        if not i < N:
            return 1

        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)

Solution (Python):


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

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

Solution (Python):
import itertools
N,K=[int(i) for i in input().split()]
seq=[i for i in range(K)]
lst=[]
'''for i in itertools.product(seq, repeat=N):
    lst.append(i)

ans=[]
for tup in lst:
    f=0
    for ind,color in enumerate(tup):
        if(ind==len(tup)-1):
            break
        if(tup[ind+1]==color):
            f=1
            break
    if(f==0):
        ans.append(tup)
print(len(ans))'''

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

Solution (Python):
A = list(map(int, input().split()))
a = A[0]
b = A[1]
s = 0
for n in range(1, a+1):
  if n == 1:
    s = s + (n * b)
  else:
    s = s * (b-1)
print(s)

Solution (Python):


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

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

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

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

print(s)

Solution (Python):
n, k = map(int, input().rstrip("\n").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())
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())
print(K*(K-1)**(N-1))

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

if K == 1 and N != 1:
    x = 0
else:
    x = K * (K-1)**(N-1)

print(x)

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

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

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

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

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

Solution (Python):
n,k=map(lambda x: int(x), 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())
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())

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

ans = k

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

print(ans)

Solution (Python):
S = input().split()
N,K = int(S[0]),int(S[1])
ans = K
if N == 1:
    print(K)
    exit(0)
for i in range(N-1):
    ans *= K - 1
print(ans)

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

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N,K = nm()

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):
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
print(K*(K-1)**(N-1))

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

main()

Solution (Python):
n,k=map(int,input().split())
tot=n//2+n%2 
h=n//2 
ans=pow(k,1) *pow(k-1,n-1) 
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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

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

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

ans = K

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

Solution (Python):
if __name__ == "__main__":
    inputs = list(input().split())
    n = int(inputs[0])
    k = int(inputs[1])

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

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

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

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

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

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

out = k

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

print(out)

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

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 * (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):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    t = 1
    for i in range(n):
        if i == 0:
            t *= k
        else:
            t *= (k - 1)
    print(t)


if __name__ == '__main__':
    slove()

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

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
res = 1
for i in range(n):
    if i == 0:
        res *= k
    else:
        res *= k-1
print(res)

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

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

print(K * (K - 1) ** max(0, (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=K
answer*=(K-1)**(N-1)
print(answer)

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

answer=K
if N>1:
  for _ in range(N-1):
    answer*=(K-1)

print(answer)

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

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):
a, b = map(int,input().split())
print(b*((b-1)**(a-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:
    result = k
  else:
    result = result * (k - 1)
print(result)

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

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

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

print(b)

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

Solution (Python):


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

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

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

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

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

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

Solution (Python):
def main():
  n, k = [int(x) for x in raw_input().split()]
  result = k
  for x in xrange(1, n):
      result *= (k-1)
  print(result)

main()

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):
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
n, k = na()

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

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

Solution (Python):
import math
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())

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



if __name__ == '__main__':
    AtCoder().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):
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())
answer = k * (k - 1) ** (n - 1)
print(answer)

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

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):
import sys
input = sys.stdin.readline

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

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

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

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

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

Solution (Python):
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
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())




result = K

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

print(result)

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

p=0
for i in range(n): 
    if(i == 0):
        p= k
    else:
        p=p*(k-1)
print(p)

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

import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N, K = ISI()
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):
SA = input().split()
SB = [int(z) for z in SA]
a = SB[0]
b = SB[1]




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

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

Solution (Python):
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

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

Solution (Python):
ball_count, color_count = (int(x) for x in input().split())
print(color_count*(color_count-1)**(ball_count-1))

Solution (Python):
n, k = [int(num) for num in 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())
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):
line = input().split()
n,k = int(line[0]),int(line[1])

pat = 1
for i in range(n):
    if i == 0:
        pat *= k
    else:
        pat *= k-1
print(pat)

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

R = 0

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

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):
def main():

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

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

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)) if N > 2 else K)

Solution (Python):
import sys
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

if K < 2:
    raise Exception('Error!')

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

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

"""
def myfunc(n, k):
    if n <= 0:
        return k
    n = int(n-1)
    k = k*(k-1)
    return myfunc( n,k )

if __name__ == '__main__':
    print(int(myfunc(N, K)))
"""

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

Solution (Python):


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

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

print(result)

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

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


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

    print(ans)


if __name__ == "__main__":
    resolve()

Solution (Python):
n, k = map(int, 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())
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())
print(k*(k-1)**(n-1))

Solution (Python):
N,K = (int(i) for i in 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, 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):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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=input().split()
n,k=int(n),int(k)
c=k
for i in range(n-1):
    c*=(k-1)
print(c)

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

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

Solution (Python):
nums, types = map(int,input().split())

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

Solution (Python):
n, k = list(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):
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(str(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 *= k
    else:
        cnt *= (k - 1)
print(cnt)

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

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

kakeru = 1
for i in range(n):
  if i == 0:
    kakeru = k
  else:
    kakeru *= (k-1)
    
print(kakeru)

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

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

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