#include <bits/stdc++.h>
using namespace std;
typedef int32_t itn;
const struct in_ {
} in;
template <typename T>
struct Proxy {
  Proxy(const T& t) : t_(t) {}
  const T& t_;
};
template <typename T>
Proxy<T> operator<<(const T& lhs, const in_& rhs) {
  return Proxy<T>(lhs);
}
template <typename T>
bool operator>>(const Proxy<T>& lhs, const vector<T>& rhs) {
  for (auto& a : rhs)
    if (lhs.t_ == a) return true;
  return false;
}
char _;
const int MOD = 1e9 + 7;
long long n, k;
long long ppow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % MOD;
    y /= 2, x = (x * x) % MOD;
  }
  return res % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  cout << (ppow(k, k - 1) * ppow(n - k, n - k)) % MOD << '\n';
  return 0;
}
