#include <bits/stdc++.h>
int main() {
  int n, k;
  const int MOD = 1e9 + 7;
  long long res = 1;
  scanf("%d%d", &n, &k);
  for (int i = 2; i <= n; ++i) res = res * (i <= k ? k : n - k) % MOD;
  printf("%I64d\n", res);
  return 0;
}
