#include <bits/stdc++.h>
using namespace std;
long long int M = 1e9 + 7;
signed main() {
  long long int n, k;
  cin >> n >> k;
  long long int ans = 1;
  for (long long int i = 1; i <= (n - k); i++) {
    ans = ((ans % M) * ((n - k) % M)) % M;
  }
  for (long long int i = 1; i <= k - 1; i++) {
    ans = ((ans % M) * (k % M)) % M;
  }
  cout << ans << endl;
  return 0;
}
