#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long exp(long long base, long long expz) {
  long long res = 1;
  while (expz > 0) {
    if (expz % 2 == 1) res = (res * base) % mod;
    base = (base * base) % mod;
    expz /= 2;
  }
  return res % mod;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, k;
  cin >> n >> k;
  cout << (exp(k, k - 1) * exp(n - k, n - k)) % mod;
  return 0;
}
