#include <bits/stdc++.h>
using namespace std;
long long modPow(long long base, long long exp) {
  if (exp == 0) return 1;
  if (exp & 1)
    return (base * modPow(base, exp - 1)) % 1000000007;
  else
    return modPow((base * base) % 1000000007, exp / 2);
}
int main() {
  long long n, k;
  cin >> n >> k;
  cout << (modPow(n - k, n - k) * modPow(k, k - 1)) % 1000000007 << endl;
  return 0;
}
