#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair<int, int> fib(int n) {
  if (n == 0) return {0, 1};
  auto p = fib(n >> 1);
  int c = p.first * (2 * p.second - p.first);
  int d = p.first * p.first + p.second * p.second;
  if (n & 1)
    return {d, c + d};
  else
    return {c, d};
}
int fact(int n) {
  int res = 1;
  for (int i = n; i >= 1; i--) (res *= i) %= mod;
  return (res % mod);
}
int pow(int a, int b, int m) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  for (long long i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
vector<long long> segmentedSieve(long long L, long long R) {
  long long lim = sqrt(R);
  vector<bool> mark(lim + 1, false);
  vector<long long> primes;
  for (long long i = 2; i <= lim; ++i) {
    if (!mark[i]) {
      primes.emplace_back(i);
      for (long long j = i * i; j <= lim; j += i) mark[j] = true;
    }
  }
  vector<bool> isPrime(R - L + 1, true);
  for (long long i : primes)
    for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
      isPrime[j - L] = false;
  if (L == 1) isPrime[0] = false;
  vector<long long> realprime;
  for (int i = 0; i <= R - L; i++) {
    if (isPrime[i]) {
      realprime.emplace_back(i + L);
    }
  }
  return realprime;
}
bool isPalindrome(string s) {
  int l = 0;
  int h = s.size() - 1;
  while (h > l) {
    if (s[l++] != s[h--]) {
      return false;
    }
  }
  return true;
}
int ternarySearch(int l, int r, int key, int ar[]) {
  while (r >= l) {
    int mid1 = l + (r - l) / 3;
    int mid2 = r - (r - l) / 3;
    if (ar[mid1] == key) {
      return mid1;
    }
    if (ar[mid2] == key) {
      return mid2;
    }
    if (key < ar[mid1]) {
      r = mid1 - 1;
    } else if (key > ar[mid2]) {
      l = mid2 + 1;
    } else {
      l = mid1 + 1;
      r = mid2 - 1;
    }
  }
  return -1;
}
int binarySearch(int arr[], int l, int r, int x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (arr[m] == x) return m;
    if (arr[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return -1;
}
long long maxsubarraysum(long long *array, long long n) {
  long long best = 0, sum = 0;
  for (long long k = 0; k < n; k++) {
    sum = max(array[k], sum + array[k]);
    best = max(best, sum);
  }
  return best;
}
string findSum(string str1, string str2) {
  if (str1.length() > str2.length()) swap(str1, str2);
  string str = "";
  int n1 = str1.length(), n2 = str2.length();
  reverse(str1.begin(), str1.end());
  reverse(str2.begin(), str2.end());
  int carry = 0;
  for (int i = 0; i < n1; i++) {
    int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (int i = n1; i < n2; i++) {
    int sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
string smin(string a, string b) {
  if (a.size() < b.size()) return a;
  if (a.size() > b.size()) return b;
  if (a <= b)
    return a;
  else
    return b;
}
bool so(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int getsum(const vector<int> &s, int l, int r) {
  return (l == 0) ? s[r] : (s[r] - s[l - 1]);
}
long long maxPrimeFactors(long long n) {
  long long maxPrime = -1;
  while (n % 2 == 0) {
    maxPrime = 2;
    n >>= 1;
  }
  for (int i = 3; i <= sqrt(n); i += 2) {
    while (n % i == 0) {
      maxPrime = i;
      n = n / i;
    }
  }
  if (n > 2) maxPrime = n;
  return maxPrime;
}
long long int primeFactors(int n) {
  long long int k = 0;
  while (n % 2 == 0) {
    k++;
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      k++;
      n = n / i;
    }
  }
  if (n > 2) k++;
  return k;
}
long long findgcd(long long a, long long b) {
  if (a == 0)
    return b;
  else
    return findgcd(b % a, a);
}
vector<pair<int, int>> shift;
int dist(int a, int b, double x) {
  double mindis = 1e9;
  for (int i = 0; i < shift.size(); i++) {
    long long int t1 = shift[i].first - a, t2 = shift[i].second - b;
    double distance = sqrt(t1 * t1 + t2 * t2);
    mindis = min(mindis, distance);
  }
  if (mindis <= x) return 1;
  return -1;
}
int match(string s) {
  int g1 = 0, g2 = 0, pos1 = 5, pos2 = 5, ans = 0;
  int i = 0;
  while (g1 <= (pos2 + g2) && g2 <= (pos1 + g1) && i < 10) {
    if (i % 2 == 0) {
      if (s[i] == '1') {
        g1++;
        pos1--;
      } else
        pos1--;
    }
    if (i % 2 == 1) {
      if (s[i] == '1') {
        g2++;
        pos2--;
      } else
        pos2--;
    }
    i++;
  }
  return i;
}
int main() {
  (ios_base::sync_with_stdio(false), cin.tie(NULL));
  int t;
  t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long p1 = pow(k, k - 1, mod);
    long long int ans = 1;
    for (int i = 0; i < n - k; i++) ans = (ans * (n - k)) % mod;
    ans = (ans * p1) % mod;
    cout << ans << "\n";
  }
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).

Little penguin Polo loves walking around this village. The walk looks like that. First he stands by a house number x. Then he goes to the house whose number is written on the plaque of house x (that is, to house px), then he goes to the house whose number is written on the plaque of house px (that is, to house ppx), and so on.

We know that:

  1. When the penguin starts walking from any house indexed from 1 to k, inclusive, he can walk to house number 1. 
  2. When the penguin starts walking from any house indexed from k + 1 to n, inclusive, he definitely cannot walk to house number 1. 
  3. When the penguin starts walking from house number 1, he can get back to house number 1 after some non-zero number of walks from a house to a house. 



You need to find the number of ways you may write the numbers on the houses' plaques so as to fulfill the three above described conditions. Print the remainder after dividing this number by 1000000007 (109 + 7).

Input

The single line contains two space-separated integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ min(8, n)) — the number of the houses and the number k from the statement.

Output

In a single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

5 2


Output

54


Input

7 4


Output

1728

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair<int, int> fib(int n) {
  if (n == 0) return {0, 1};
  auto p = fib(n >> 1);
  int c = p.first * (2 * p.second - p.first);
  int d = p.first * p.first + p.second * p.second;
  if (n & 1)
    return {d, c + d};
  else
    return {c, d};
}
int fact(int n) {
  int res = 1;
  for (int i = n; i >= 1; i--) (res *= i) %= mod;
  return (res % mod);
}
int pow(int a, int b, int m) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  for (long long i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
vector<long long> segmentedSieve(long long L, long long R) {
  long long lim = sqrt(R);
  vector<bool> mark(lim + 1, false);
  vector<long long> primes;
  for (long long i = 2; i <= lim; ++i) {
    if (!mark[i]) {
      primes.emplace_back(i);
      for (long long j = i * i; j <= lim; j += i) mark[j] = true;
    }
  }
  vector<bool> isPrime(R - L + 1, true);
  for (long long i : primes)
    for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
      isPrime[j - L] = false;
  if (L == 1) isPrime[0] = false;
  vector<long long> realprime;
  for (int i = 0; i <= R - L; i++) {
    if (isPrime[i]) {
      realprime.emplace_back(i + L);
    }
  }
  return realprime;
}
bool isPalindrome(string s) {
  int l = 0;
  int h = s.size() - 1;
  while (h > l) {
    if (s[l++] != s[h--]) {
      return false;
    }
  }
  return true;
}
int ternarySearch(int l, int r, int key, int ar[]) {
  while (r >= l) {
    int mid1 = l + (r - l) / 3;
    int mid2 = r - (r - l) / 3;
    if (ar[mid1] == key) {
      return mid1;
    }
    if (ar[mid2] == key) {
      return mid2;
    }
    if (key < ar[mid1]) {
      r = mid1 - 1;
    } else if (key > ar[mid2]) {
      l = mid2 + 1;
    } else {
      l = mid1 + 1;
      r = mid2 - 1;
    }
  }
  return -1;
}
int binarySearch(int arr[], int l, int r, int x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (arr[m] == x) return m;
    if (arr[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return -1;
}
long long maxsubarraysum(long long *array, long long n) {
  long long best = 0, sum = 0;
  for (long long k = 0; k < n; k++) {
    sum = max(array[k], sum + array[k]);
    best = max(best, sum);
  }
  return best;
}
string findSum(string str1, string str2) {
  if (str1.length() > str2.length()) swap(str1, str2);
  string str = "";
  int n1 = str1.length(), n2 = str2.length();
  reverse(str1.begin(), str1.end());
  reverse(str2.begin(), str2.end());
  int carry = 0;
  for (int i = 0; i < n1; i++) {
    int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (int i = n1; i < n2; i++) {
    int sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
string smin(string a, string b) {
  if (a.size() < b.size()) return a;
  if (a.size() > b.size()) return b;
  if (a <= b)
    return a;
  else
    return b;
}
bool so(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int getsum(const vector<int> &s, int l, int r) {
  return (l == 0) ? s[r] : (s[r] - s[l - 1]);
}
long long maxPrimeFactors(long long n) {
  long long maxPrime = -1;
  while (n % 2 == 0) {
    maxPrime = 2;
    n >>= 1;
  }
  for (int i = 3; i <= sqrt(n); i += 2) {
    while (n % i == 0) {
      maxPrime = i;
      n = n / i;
    }
  }
  if (n > 2) maxPrime = n;
  return maxPrime;
}
long long int primeFactors(int n) {
  long long int k = 0;
  while (n % 2 == 0) {
    k++;
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      k++;
      n = n / i;
    }
  }
  if (n > 2) k++;
  return k;
}
long long findgcd(long long a, long long b) {
  if (a == 0)
    return b;
  else
    return findgcd(b % a, a);
}
vector<pair<int, int>> shift;
int dist(int a, int b, double x) {
  double mindis = 1e9;
  for (int i = 0; i < shift.size(); i++) {
    long long int t1 = shift[i].first - a, t2 = shift[i].second - b;
    double distance = sqrt(t1 * t1 + t2 * t2);
    mindis = min(mindis, distance);
  }
  if (mindis <= x) return 1;
  return -1;
}
int match(string s) {
  int g1 = 0, g2 = 0, pos1 = 5, pos2 = 5, ans = 0;
  int i = 0;
  while (g1 <= (pos2 + g2) && g2 <= (pos1 + g1) && i < 10) {
    if (i % 2 == 0) {
      if (s[i] == '1') {
        g1++;
        pos1--;
      } else
        pos1--;
    }
    if (i % 2 == 1) {
      if (s[i] == '1') {
        g2++;
        pos2--;
      } else
        pos2--;
    }
    i++;
  }
  return i;
}
int main() {
  (ios_base::sync_with_stdio(false), cin.tie(NULL));
  int t;
  t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long p1 = pow(k, k - 1, mod);
    long long int ans = 1;
    for (int i = 0; i < n - k; i++) ans = (ans * (n - k)) % mod;
    ans = (ans * p1) % mod;
    cout << ans << "\n";
  }
}

```