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.

Examples

Input

2 2


Output

2


Input

1 10


Output

10
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (x == 0) {
    return y;
  } else {
    return gcd(y % x, x);
  }
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
long long C(long long n, long long k) {
  if (n == k) {
    return 1;
  } else if (n < k) {
    return 0;
  } else if (k == 0) {
    return 1;
  } else if (k == 1) {
    return n;
  } else
    return C(n - 1, k - 1) + C(n - 1, k);
}
long long P(long long n, long long k) {
  if (k == 1) {
    return n;
  }
  return (n * (P(n - 1, k - 1) % 1000000007) % 1000000007);
}
int main() {
  long long n, k;
  cin >> n >> k;
  if (k >= n) {
    cout << P(k, n) << endl;
  } else {
    printf("%lld\n", k * (long long)pow(k - 1, n - 1));
  }
  return 0;
}
