#include <bits/stdc++.h>
using namespace std;
const int N = 1000003;
int n, k;
const int MOD = 1000000007;
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
int main() {
  while (scanf("%d%d", &n, &k) == 2) {
    long long ans = power(k, k - 1) * power(n - k, n - k) % MOD;
    cout << ans << endl;
  }
}
