#include <bits/stdc++.h>
using namespace std;
const int N = 10;
const int MOD = 1000000007;
long long qPow(int n, int m) {
  long long ret = 1;
  while (m) {
    if (m & 1) ret = ret * n % MOD;
    m >>= 1;
    n = (long long)n * n % MOD;
  }
  return ret;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long long ans = qPow(n - k, n - k) * qPow(k, k - 1) % MOD;
  printf("%I64d\n", ans);
  return 0;
}
