#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000000 + 7;
int power(long long a, int b) {
  long long ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) {
      ret = ret * a % MOD;
    }
    a = a * a % MOD;
  }
  return ret;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  printf("%I64d\n", (long long)power(k, k - 1) * power(n - k, n - k) % MOD);
  return 0;
}
