#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 2e9;
const long long INF64 = 7e18;
const long double EPS = 1e-9;
const long double PI = 3.14159265358979310000;
const long long MD = 535355424;
const int T = 1e5 * 3;
const int N = 400101;
const int M = 501;
int main() {
  long long n, k;
  cin >> n >> k;
  long long sum = 1;
  for (long long i = 1; i <= n - k; i++) sum = (sum * (n - k)) % MOD;
  for (long long i = 1; i < k; i++) sum = (sum * k) % MOD;
  cout << sum;
  return 0;
}
