#include <bits/stdc++.h>
using namespace std;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
const double EPS = 1e-8;
const double PI = acos(-1.0);
int popcount(int n) { return __builtin_popcount(n); }
int popcount(long long n) { return __builtin_popcountll(n); }
template <class T>
int SIZE(T a) {
  return a.size();
}
template <class T>
string IntToString(T num) {
  string res;
  stringstream ss;
  ss << num;
  return ss.str();
}
template <class T>
T StringToInt(string str) {
  T res = 0;
  for (int i = 0; i < SIZE(str); i++) res = (res * 10 + str[i] - '0');
  return res;
}
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
void PrintSeq(T &a, int sz) {
  for (int i = 0; i < sz; i++) {
    cout << a[i];
    if (sz == i + 1)
      cout << endl;
    else
      cout << ' ';
  }
}
bool EQ(double a, double b) { return abs(a - b) < EPS; }
bool EQV(complex<double> a, complex<double> b) {
  return EQ(a.real(), b.real()) & EQ(a.imag(), b.imag());
}
void fastStream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
vector<string> split(string str, char del) {
  vector<string> res;
  for (int i = 0, s = 0; i < SIZE(str); i++) {
    if (str[i] == del) {
      if (i - s != 0) res.push_back(str.substr(s, i - s));
      s = i + 1;
    } else if (i == SIZE(str) - 1) {
      res.push_back(str.substr(s));
    }
  }
  return res;
}
const int mod = 1000000000 + 7;
int p[11];
int N, K;
int dp[10];
int g[11][11];
int sizes[11];
bool used[11];
void rec(int now) {
  used[now] = true;
  for (int i = 0; i < sizes[now]; i++) {
    int to = g[now][i];
    if (!used[to]) rec(to);
  }
}
long long cnt = 0;
void dfs(int depth) {
  if (depth == K) {
    for (int i = 0; i < K; i++) sizes[i] = 0;
    for (int i = 0; i < K; i++) g[p[i]][sizes[p[i]]++] = i;
    memset(used, 0, sizeof(used));
    rec(0);
    bool ok = true;
    for (int i = 0; i < K; i++)
      if (!used[i]) {
        ok = false;
        break;
      }
    if (ok) {
      cnt++;
    }
  } else {
    for (int i = 0; i < K; i++) {
      p[depth] = i;
      dfs(depth + 1);
    }
  }
}
int main() {
  cin >> N >> K;
  dfs(0);
  for (int i = 0; i < N - K; i++) {
    cnt = (cnt * (N - K)) % mod;
  }
  cout << cnt << endl;
  return 0;
}

### 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;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
const double EPS = 1e-8;
const double PI = acos(-1.0);
int popcount(int n) { return __builtin_popcount(n); }
int popcount(long long n) { return __builtin_popcountll(n); }
template <class T>
int SIZE(T a) {
  return a.size();
}
template <class T>
string IntToString(T num) {
  string res;
  stringstream ss;
  ss << num;
  return ss.str();
}
template <class T>
T StringToInt(string str) {
  T res = 0;
  for (int i = 0; i < SIZE(str); i++) res = (res * 10 + str[i] - '0');
  return res;
}
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
void PrintSeq(T &a, int sz) {
  for (int i = 0; i < sz; i++) {
    cout << a[i];
    if (sz == i + 1)
      cout << endl;
    else
      cout << ' ';
  }
}
bool EQ(double a, double b) { return abs(a - b) < EPS; }
bool EQV(complex<double> a, complex<double> b) {
  return EQ(a.real(), b.real()) & EQ(a.imag(), b.imag());
}
void fastStream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
vector<string> split(string str, char del) {
  vector<string> res;
  for (int i = 0, s = 0; i < SIZE(str); i++) {
    if (str[i] == del) {
      if (i - s != 0) res.push_back(str.substr(s, i - s));
      s = i + 1;
    } else if (i == SIZE(str) - 1) {
      res.push_back(str.substr(s));
    }
  }
  return res;
}
const int mod = 1000000000 + 7;
int p[11];
int N, K;
int dp[10];
int g[11][11];
int sizes[11];
bool used[11];
void rec(int now) {
  used[now] = true;
  for (int i = 0; i < sizes[now]; i++) {
    int to = g[now][i];
    if (!used[to]) rec(to);
  }
}
long long cnt = 0;
void dfs(int depth) {
  if (depth == K) {
    for (int i = 0; i < K; i++) sizes[i] = 0;
    for (int i = 0; i < K; i++) g[p[i]][sizes[p[i]]++] = i;
    memset(used, 0, sizeof(used));
    rec(0);
    bool ok = true;
    for (int i = 0; i < K; i++)
      if (!used[i]) {
        ok = false;
        break;
      }
    if (ok) {
      cnt++;
    }
  } else {
    for (int i = 0; i < K; i++) {
      p[depth] = i;
      dfs(depth + 1);
    }
  }
}
int main() {
  cin >> N >> K;
  dfs(0);
  for (int i = 0; i < N - K; i++) {
    cnt = (cnt * (N - K)) % mod;
  }
  cout << cnt << endl;
  return 0;
}

```