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