#include <bits/stdc++.h>
using namespace std;
long long fp(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power & 1) result = (result * base) % 1000000007;
    base = (base * base) % 1000000007;
    power >>= 1;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  cout << (fp(k, k - 1) * fp(n - k, n - k)) % 1000000007 << endl;
}
