#include <bits/stdc++.h>
using namespace std;
const unsigned long long denom = 1000000007;
inline unsigned long long powa(unsigned long long n, unsigned p) {
  unsigned long long res = 1;
  while (p) {
    if (p & 1UL) {
      res *= (unsigned long long)n;
      res %= denom;
      p -= 1;
    }
    n *= n;
    n %= denom;
    p >>= 1;
  }
  return res;
}
int main(void) {
  unsigned n, k;
  cin >> n >> k;
  cout << (powa(k, k - 1) * powa(n - k, n - k)) % denom << endl;
  return 0;
}
