#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 10;
int Pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (long long)ans * a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    int ans = (long long)Pow(k, k - 1) * Pow(n - k, n - k) % 1000000007;
    printf("%d\n", ans);
  }
  return 0;
}
