#include <bits/stdc++.h>
using namespace std;
long long int powM(long long int x, long long int n, long long int M) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return powM((x * x) % M, n / 2, M);
  else
    return (x * powM((x * x) % M, (n - 1) / 2, M)) % M;
}
int main() {
  int n, k;
  int mod = 1000000007;
  cin >> n >> k;
  long long int val = (long long int)powM(n - k, n - k, mod);
  long long int val2 = (long long int)powM(k, k - 1, mod);
  cout << (val * val2) % mod << endl;
}
