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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter





j=0
k=0
n=3
r=1
a=[0]






"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''


'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        
        if n % k == 0:
            return False
            
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  

'''

def factorial(x, mod=10**9+7):
    
    
    
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''











'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    
    
    
    n,k=map(int, input().split(" "))
    print(k*(k-1)**(n-1))
    
    
    
    
    
    
    


    for i in range(1,n+1,2):
     pass
     

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')
    
    
    
    

    
        
    
    

    
    
    
    
    DP = np.zeros(w+1, dtype=int)
    exdp=np.zeros((3,4)) 
    
    
    
        
        
    
    
        
        
    


    
    



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]
    

    ls = ["a", "b", "c", "d", "e"]


    
    

    
    

    
    
    
    
    
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

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())
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=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())
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):
import sys
import math
import bisect

def main():
    n, k = map(int, input().split())
    ans = 1
    for i in range(n):
        if i == 0:
            ans *= k
        else:
            ans *= k - 1
    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())
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 sys
input = sys.stdin.readline

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()

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

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

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

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

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

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

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

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

def main():
    n,k = readInts()
    print(k*(k-1)**(n-1))
if __name__ == '__main__':
  main()

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,k=MI()
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 = tuple(map(int,input().split()))

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

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

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

print(ans)

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

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):
from sys import exit

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

ans = K * pow(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):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,k = myinput()

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

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())
ans = 0
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())

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

main()

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))  
    
    cnt = K*(K-1)**(N-1)
    
    print(cnt)

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

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

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

print(ans)

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

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

res = K

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

print(res)

Solution (Python):
n, k = map(int, input().split())
cnt = k
for i in range(n - 1):
    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())
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
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


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

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

Solution (Python):
n, k = map(int, input().split())
c = k
for _ in range(n - 1):
    c = c * (k - 1)
    c = c % (2 ** 31 - 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())
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):
n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  
def Is(): return map(int, input().split())  
def LI(): return list(map(int, input().split()))  
def TI(): return tuple(map(int, input().split()))  
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  
def LS(): return list(input())  
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, k = Is()
ans = k

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

print(ans)

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

print(ans)

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

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

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


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

if __name__ == '__main__':
    main()

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

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

if '__main__' == __name__:
    resolve()

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



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

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

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

    print(sum)


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

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

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

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()))
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):
number, color = map(int, input().split())
answer = 1
for i in range(number):
  if(i ==0):
    answer = answer*color
  else:
    answer = answer*(color - 1)
    
print(answer)

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

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

Solution (Python):
n,m = map(int,input().split())
ans = m
for _ in range(n-1):
	ans *= (m-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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().split())
    ans = K*((K-1)**(N-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(K*((K-1)**(N-1)))

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

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().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

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()

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

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

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

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

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

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

Solution (Python):
def resolve():
    b,c =map(int,input().split())
    if b==1:print(c)
    else:
        print(c*pow(c-1,b-1))
    
        

resolve()

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


if __name__ == '__main__':
    main()

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

if __name__ == "__main__":
  resolve()

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

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    ans=K*pow(K-1,N-1)
    print(ans)

main()

Solution (Python):
def solve():
    n,k = map(int,input().split())
    print((k-1)**(n-1)*k)
if __name__=='__main__':
    solve()

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

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

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

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

print(ans)

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

dp = [1]*k

for _ in range(n-1):
    s = sum(dp)
    for i in range(k):
        dp[i] = s - dp[i]
print(sum(dp))

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 = min(K * (K - 1) ** (N - 1), 2 ** 31 - 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,color = map(int,input().split())

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

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

Solution (Python):

def myAnswer(N:int, K:int) -> int:
   return (K - 1)**(N - 1) * K

def modelAnswer():
   tmp=1
def main():
   N, K = map(int,input().split())
   print(myAnswer(N, K))
if __name__ == '__main__':
   main()

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

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())
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):
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math
import datetime
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()

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


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

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

Solution (Python):
n,k = map(int,input().split())
ans = k
for i in range(0,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().rstrip().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())

def comnb(a,b):
    return b*((b-1)**(a-1))
print(comnb(N,K))

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

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

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

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