#include <bits/stdc++.h>
long long R[] = {0, 1, 2, 9, 64, 625, 7776, 117649, 2097152};
int main() {
  int n, k;
  long long s;
  scanf("%d%d", &n, &k);
  n -= k;
  s = R[k];
  k = n;
  while (n--) s = (s * k) % 1000000007;
  printf("%d\n", s);
  return (0);
}
