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

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

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

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

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

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

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

print(count)

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

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

Solution (Python):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


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

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

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

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

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):
bols,cols = (int(i) for i in input().split())

n = cols * pow((cols - 1), (bols - 1))
print(n)

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

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

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

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

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

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

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

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

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

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

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

print(ans)

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

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

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

print(P)

Solution (Python):

n, k = [int(el) for el in input().split(' ')]
print(k*(k-1)**(n-1))

Solution (Python):

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



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

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

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

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


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

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

ans = 1

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

Solution (Python):

import sys, math, fractions, itertools


def solve(N: int, K: int):
    print(K * (K-1)**(N-1))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    solve(N, K)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)

from math import factorial
import bisect
import math



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





if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    n, k = read()
    result = think(n, k)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, k):
    return k * (k - 1) ** (n - 1)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int):
    ret = K * (K - 1) ** (N - 1)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    solve(N, K)

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

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

Solution (Python):
n,k = map(int, input().split())
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())
ans = k * pow(k-1, n-1)
print("{}".format(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 = list(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):

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


import sys

sys.setrecursionlimit(10**7)


input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


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


if __name__ == '__main__':
    main()

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

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

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

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

print(res)

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

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

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

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

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

ans *= K

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

print(ans)

Solution (Python):


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

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

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

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

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

dp = [[0] * k for _ in range(n)]
for i in range(k):
  dp[0][i] = 1

for i in range(1, n):
  toAdd = sum(dp[i - 1])
  for j in range(k):
    dp[i][j] += toAdd - dp[i - 1][j]
    
print(sum(dp[-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):
row = list(map(int, input().split()))

ans = row[1] * (row[1]-1)**(row[0]-1)
print(ans)

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

Solution (Python):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().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=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())

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

print(ans)

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

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

for i in range(a[0]):
  if i==0:
    b*=a[1]
  else:
    b*=a[1]-1
else:
  print(b)

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
N,K=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):
ball,color = map(int,input().split())
sum = color * pow(color - 1,ball - 1)
print(sum)

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

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

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

if __name__ == "__main__":

    main()

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, K = list(map(int, sys.stdin.readline().split()))


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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, K = nl()

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

print(total)

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

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

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

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


abc()

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

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

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 = [ int(v) for v in input().split() ]
print(k*((k-1)**(n-1)))

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

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


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,m=map(int,input().split())
print(m*((m-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 = 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):
  if i == 0:
  	ans *= k
  else:
    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())
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 = [int(s) for s in input().split()]

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

Solution (Python):

def main(N, K):
    print(K * (K-1)**(N-1))

if __name__ == "__main__":
    N, K = [int(x) for x in input().split()]

    main(N, K)

def test1(capsys):
    inputs = [2, 2]
    out = 2
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test3(capsys):
    inputs = [1, 10]
    out = 10
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test4(capsys):
    inputs = [10, 8]
    out = 322828856
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test5(capsys):
    inputs = [1, 2]
    out = 2
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

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

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

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

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

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

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

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

Solution (Python):
if __name__ == '__main__':
    N, K = map(int, input().split(' '))
    total = K * (K - 1) ** (N - 1)
    print(total)

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

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

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

print(f)

Solution (Python):
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = list(map(lambda x: int(x), inputs[0].split()))
    pattern = K * ((K - 1) ** (N - 1))
    return pattern


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Solution (Python):
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = list(map(lambda x: int(x), inputs[0].split()))
    pattern = K
    for i in range(1, N):
        pattern *= K - 1
    return pattern


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

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

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

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

Solution (Python):


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

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

print(ans)

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

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

print(sum)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k = f()

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


solve()

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

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

print(num)

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

Solution (Python):

N ,M  =list(map(int,input().split(" ")))


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

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

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

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

print(ans)

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

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

print(ans)

Solution (Python):


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

if n == 1:
    ans = k
else:
    ans = k * pow(k-1, n-1)

print(ans)

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

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

print(Answer)

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

"""
B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
https://abc046.contest.atcoder.jp/tasks/abc046_b

"""
import sys


def solve(N, K):
    ans = K
    for _ in range(1, N):
        ans *= (K-1)
    return ans


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

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

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

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

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

p = 0

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

Solution (Python):

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

Solution (Python):
a, b = (int(_) for _ in input().split())  
print(int(b*((b-1)**(a-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):
import sys
from collections import Counter

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

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

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

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

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

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

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

print(ans)

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

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

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


def submit():
    n, k = read_input()

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


if __name__ == '__main__':
    submit()

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 solve(N, K):
    print(K*(K-1)**(N-1))
                
if __name__ == '__main__':
    N, K = map(int, input().split())

    solve(N, K)

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

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

for i in range(len(input)):
  input[i]=int(input[i])
  
output=1
output=input[1]*(input[1]-1)**(input[0]-1)

print(output)

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

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

ans=k

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

print(ans)

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