MOD = 10**9+7 mod = MOD n,m = map(int,input().split()) N = n def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) fact = [1]*(N+1) rfact = [1]*(N+1) r = 1 for i in range(1, N+1): fact[i] = r = r * i % MOD rfact[N] = r = pow(fact[N], MOD-2, MOD) for i in range(N, 0, -1): rfact[i-1] = r = r * i % MOD # nPk (mod MOD) を求める def perm(n, k): return fact[n] * rfact[n-k] % MOD ans = perm(m,m) if n != m: ans *= cmb(n,n-m,mod) print(ans)