#include <bits/stdc++.h>
using namespace std;
const long long N = 200 * 1000 + 9;
const long long inf = 1e18;
const long long mod = 1000000007;
vector<bool> primes(1000001, false);
long long power(long long p, long long q) {
  long long res = 1;
  while (q) {
    if (q & 1) res = (res * p) % mod;
    p = (p * p) % mod;
    q = q / 2;
  }
  return res;
}
void HakunaMatata() {
  long long n, k;
  cin >> n >> k;
  long long ans = 1;
  ans = (ans * (power(n - k, n - k))) % mod;
  ans = (ans * (power(k, k - 1))) % mod;
  cout << ans << '\n';
  return;
}
signed main() {
  HakunaMatata();
  return 0;
}
