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