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