MOD = 10 ** 9 + 7
CEIL = 10 ** 6

FACT = Array.new(CEIL, 1)
INV  = Array.new(CEIL, 1)
FINV = Array.new(CEIL, 1)

(2 ... CEIL).each do |i|
  FACT[i] = (FACT[i - 1] * i) % MOD
  INV[i] = MOD - (INV[MOD % i] * (MOD / i)) % MOD
  FINV[i] = (FINV[i - 1] * INV[i]) % MOD
end

def combination_mod(n,k)
    return 0 if n < k
    return 0 if (n < 0 || k < 0)
    
    FACT[n] * (FINV[k] * FINV[n - k] % MOD) % MOD;
end

def split_mod(n,k)
  combination_mod(n-1, k-1)
end

N, K = gets.split.map(&:to_i)
K_ = N - K

ans = (1 .. K).map do |i|
  t = split_mod(K, i)
  a = split_mod(K_, i - 1) # B,R, ..., R,B
  b = split_mod(K_, i) # B,R, ... ,B,R or R,B, ... ,R,B
  c = split_mod(K_, i + 1) # R,B, ... ,B,R
  
  ((t * a % MOD) + (2 * t * b % MOD) + (t * c % MOD)) % MOD
end

puts ans
