#include <bits/stdc++.h>
using namespace std;
const int N = 25;
const int mod = 1000000007;
int main(int argc, char *argv[]) {
  int n, k;
  cin >> n >> k;
  int x = n - k;
  long long ans = 1;
  for (int i = (0), _b = (x); i < (_b); ++i) {
    ans *= x;
    ans %= mod;
  }
  for (int i = (0), _b = (k - 1); i < (_b); ++i) {
    ans *= k;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
