#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int n, k;
const int mod = 1e9 + 7;
ll qp(ll a, ll k) {
  ll ans = 1;
  while (k) {
    if (k & 1) ans = ans * a % mod;
    a = a * a % mod;
    k >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  return printf("%lld\n", qp(k, k - 1) * qp(n - k, n - k) % mod), 0;
}
