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

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

Solution (Python):


mojir=input()
hyo=mojir.split(' ')

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


ans=1
for idx in range(0,N,1):
    iro = K-1 if idx != 0 else K
    ans=ans*iro

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

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

print value

Solution (Python):
N,K = raw_input().split()
N=int(N)
K=int(K)
if N==1:
    print K
else:
    A = K*pow(K-1,N-1)
    print A

Solution (Python):
l = raw_input().split()
N = int(l[0])
K = int(l[1])

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

Solution (Python):
l = input().split()
N = int(l[0])
K = int(l[1])
print(str(K*((K-1)**(N-1))))

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

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

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

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

Solution (Python):
d=[int(i) for i in input().split()]

print(d[1]*((d[1]-1)**(d[0]-1)))

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

Solution (Python):
import sys

line = sys.stdin.readline()
line = line.rstrip().split(" ")
n,k = int(line[0]), int(line[1])

ret = 1
ret = ret*k
for l in range(n-1):
    ret = ret*(k-1)

print (ret)

Solution (Python):

N, K = [int(a) for a in raw_input().strip().split()]
print K*(K-1)**(N-1)

Solution (Python):
data = map(int, raw_input().split(" "))
ball_num = data[0]
color_num = data[1]

res = color_num

for _ in range(ball_num-1):
	res *= (color_num-1)

print res

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

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

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

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

Solution (Python):
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(2)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def solve():
    buf = IO_for_Contest.read_from_input()
    n = buf[0]
    k = buf[1]
    print(k * ((k - 1) ** (n - 1)))


if __name__ == '__main__':
    
    solve()

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

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

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

Solution (Python):
from random import random
import math
import re
import fractions


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

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

Solution (Python):

n, k = list(map(lambda x: int(x), input().split()))

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

print(ans)

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

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

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

Solution (Python):
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')


def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())


def join(s):
    return ''.join(s)


def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)


def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m


def index(a, x):
    
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1


def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])



n,k=ii()

def f(x):
    if x==0:
        return 1
    elif x==1:
        return k-1
    elif x%2==0:
        return f(x/2)**2
    else:
        return f(x/2)**2*(k-1)

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