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