#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, -1, 1, 1, -1, 1, -1};
string ds = "DULR";
const int inf = 1e9;
const long long inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;
long long modular_Exponentiation(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return modular_Exponentiation((x * x) % mod, n / 2);
  else
    return (x * modular_Exponentiation((x * x) % mod, (n - 1) / 2)) % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, k;
  cin >> n >> k;
  long long ans = modular_Exponentiation(n - k, n - k);
  ans = ans * modular_Exponentiation(k, k - 1) % mod;
  cout << ans;
}
