#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long pw(long long a, int n) {
  int res = 1;
  while (n) {
    if (n & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  int n, k;
  cin >> n >> k;
  cout << (pw(n - k, n - k) * pw(k, k - 1)) % mod;
  return 0;
}
