#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1000000007;
unsigned long long po(unsigned long long a, unsigned long long b) {
  unsigned long long ans = 1ll;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    b = b >> 1;
    a = (a * a) % mod;
  }
  return (ans % mod);
}
int main() {
  ios_base::sync_with_stdio(false);
  unsigned long long n, k;
  cin >> n >> k;
  unsigned long long ans = (po(k, k - 1) * po(n - k, n - k)) % mod;
  cout << ans << endl;
  return 0;
}
