Problem: There are well-known formulas: <image>, <image>, <image>. Also mathematicians found similar formulas for higher degrees.

Find the value of the sum <image> modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 109 + 7).

Input

The only line contains two integers n, k (1 ≤ n ≤ 109, 0 ≤ k ≤ 106).

Output

Print the only integer a — the remainder after dividing the value of the sum by the value 109 + 7.

Examples

Input

4 1


Output

10


Input

4 2


Output

30


Input

4 3


Output

100


Input

4 0


Output

4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
const long long K = 1e6 + 100;
const long long MOD = 1e9 + 7;
long long n, k;
long long pre[K];
long long suf[K];
long long fac[K];
long long inv[K];
long long pow(long long x, long long k) {
  if (x == 0) return 0;
  long long res = 1;
  while (k) {
    if (k & 1) res *= x, res %= MOD;
    x *= x, x %= MOD;
    k >>= 1;
  }
  return res;
}
signed main() {
  scanf("%lld%lld", &n, &k);
  pre[0] = n - k - 1, suf[k + 1] = n, inv[0] = inv[1] = 1, fac[0] = 1;
  for (long long i = 1; i <= k + 1; ++i)
    pre[i] = pre[i - 1] * (n - k - 1 + i), pre[i] %= MOD;
  for (long long i = k; i >= 0; --i)
    suf[i] = suf[i + 1] * (n - k - 1 + i), suf[i] %= MOD;
  for (long long i = 2; i <= k + 1; ++i)
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
  for (long long i = 1; i <= k + 1; ++i) fac[i] = inv[i] * fac[i - 1] % MOD;
  long long f = 0, ans = 0;
  for (long long i = 0; i <= k + 1; ++i) {
    f += pow(i, k), f %= MOD;
    long long add;
    if (i == 0)
      add = f * pre[k - 1] % MOD;
    else if (i == k + 1)
      add = f * suf[1] % MOD;
    else
      add = f * suf[k + 1 - i + 1] % MOD * pre[k + 1 - i - 1] % MOD;
    ans +=
        add * ((k + 1 - i) & 1 ? -1 : 1) * fac[i] % MOD * fac[k + 1 - i] % MOD,
        ans %= MOD;
  }
  printf("%lld", (ans % MOD + MOD) % MOD);
}