#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int MaxN = 100005;
const int Mod = 1000000007;
long long mypow(long long x, int n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = ans * x % Mod;
    x = x * x % Mod;
    n >>= 1;
  }
  return ans;
}
int main() {
  int n, k;
  while (2 == scanf("%d%d", &n, &k)) {
    long long ans = mypow(n - k, n - k);
    ans = ans * mypow(k, k - 1) % Mod;
    cout << ans << endl;
  }
  return 0;
}
