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 N = 2000010;
const long long mod = 1e9 + 7;
int n, k;
long long a[N], b[N], c[N], S[N], pre[N], bck[N];
long long jc[N], ans;
long long fpow(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = 1LL * ans * x % mod;
    x = 1LL * x * x % mod;
    y >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  k += 2;
  for (int i = 1; i <= k; i++) S[i] = (S[i - 1] + fpow(i, k - 2)) % mod;
  if (n <= k) {
    printf("%lld", S[n]);
    return 0;
  }
  jc[0] = 1;
  for (int i = 1; i <= k; i++) jc[i] = jc[i - 1] * i % mod;
  pre[0] = 1;
  bck[k + 1] = 1;
  for (int i = 1; i <= k; i++) pre[i] = ((n - i) * pre[i - 1]) % mod;
  for (int i = k; i >= 1; i--) bck[i] = ((n - i) * bck[i + 1]) % mod;
  for (int i = 1; i <= k; i++) a[i] = pre[i - 1] * bck[i + 1] % mod;
  for (int i = 1; i <= k; i++) b[i] = (((jc[i - 1] % mod) * jc[k - i]) % mod);
  for (int i = 1; i <= k; i++)
    ans = (ans +
           fpow(-1, k - i) * ((S[i] * a[i] % mod) * fpow(b[i], mod - 2) % mod) +
           mod) %
          mod;
  printf("%lld", ans);
  return 0;
}