#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000,mod = 1e9+7;
int n,K;
ll fac[10000010],ifac[10000010];
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
ll UP(int n,int m){
	if(n==0) return 0;
	return fac[n+m-1]*ifac[n-1]%mod;
}
ll C(int n,int m){
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main(){
	read(n);read(K);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	ifac[n]=fp(fac[n],mod-2);
	for(int i=n;i;i--) ifac[i-1]=ifac[i]*i%mod;
	ll ans=0;
	for(int i=1;i<=K;i++){
		for(int j=0;j<i;j++)
			ans=(ans+(j&1?-1:1)*C(i-1,j)*fac[i-1-j]%mod*UP(i-1-j,n-K)%mod*UP(i-j-K+n,K-i))%mod;
	}
	for(int i=0;i<=K;i++){
		ans=(ans+(i&1?-1:1)*C(K,i)*fac[K-i]%mod*UP(K-i,n-K))%mod;
	}
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}

