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>
using namespace std;
const int K = 1000000 + 7;
const long long MOD = 1000000007;
long long n, k;
long long y[K];
long long pre[K], suf[K];
long long ifac[K];
long long f;
long long pow(long long a, long long k);
int main() {
  scanf("%lld%lld", &n, &k);
  pre[0] = ifac[0] = 1;
  for (long long i = 1; i <= k + 2; ++i) {
    y[i] = (y[i - 1] + pow(i, k)) % MOD;
    pre[i] = pre[i - 1] * (n - i + MOD) % MOD;
    ifac[i] = ifac[i - 1] * pow(i, MOD - 2) % MOD;
  }
  suf[k + 3] = 1;
  for (long long i = k + 2; i; --i) suf[i] = suf[i + 1] * (n - i + MOD) % MOD;
  for (long long i = 1, t; i <= k + 2; ++i) {
    t = y[i];
    if ((k + 2 - i) & 1) t = MOD - t;
    (t *= pre[i - 1] * suf[i + 1] % MOD) %= MOD;
    (t *= ifac[i - 1] * ifac[k + 2 - i] % MOD) %= MOD;
    (f += t) %= MOD;
  }
  printf("%lld", f);
  return 0;
}
long long pow(long long a, long long k) {
  long long t = 1;
  for (; k; a = a * a % MOD, k >>= 1)
    if (k & 1) t = t * a % MOD;
  return t;
}