#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, p = 1LL;
  cin >> n >> k;
  for (int i = 1; i < k; i++) p = (p * k) % 1000000007;
  for (int i = 1; i <= n - k; i++) p = (p * (n - k)) % 1000000007;
  cout << p;
  return 0;
}
