#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, k, ans = 1;
int main() {
  cin >> n >> k;
  for (long long i = 1; i < k; i++) ans = (ans * k) % mod;
  for (long long i = 1; i <= n - k; i++) ans = (ans * (n - k)) % mod;
  cout << ans << endl;
  return 0;
}
