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