#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long long ans1 = 1, ans2 = 1;
  for (int i = 1; i <= k - 1; i++) ans1 = ans1 * k % 1000000007;
  for (int i = 1; i <= n - k; i++) ans2 = ans2 * (n - k) % 1000000007;
  printf("%I64d\n", ans1 * ans2 % 1000000007);
  return 0;
}
