#include <bits/stdc++.h>
using namespace std;
template <class T>
T bigmod(T base, T power) {
  T tem, t;
  T mod = 1000000007;
  if (power == 1) {
    return base;
  }
  if (power == 0) {
    return 1;
  }
  t = bigmod(base, power / 2);
  tem = t * t;
  tem %= mod;
  if (power & 1) {
    tem *= base;
    tem %= mod;
  }
  return tem;
};
long long n, k;
long long fact[10005];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  cout << (1LL * bigmod(k, k - 1) * bigmod(n - k, n - k)) % 1000000007;
}
