#include <bits/stdc++.h>
long long fastpow(int b, int e) {
  if (e == 0) return 1;
  long long dev = fastpow(b, e / 2);
  dev = (dev * dev) % 1000000007;
  if (e & 1) dev = (dev * b) % 1000000007;
  return dev;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  printf("%I64d\n", (fastpow(k, k - 1) * fastpow(n - k, n - k)) % 1000000007);
}
