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 long long N = 1e6 + 5, mod = 1e9 + 7;
long long n, k, pre[N], suf[N], fac[N], qx[N], qy[N];
long long mul(long long x, long long n, long long mod) {
  long long ans = mod != 1;
  for (x %= mod; n; n >>= 1, x = x * x % mod)
    if (n & 1) ans = ans * x % mod;
  return ans;
}
long long calc(long long n, long long k, long long qx[N], long long qy[N]) {
  fac[0] = pre[0] = suf[n + 2] = 1;
  for (long long i = 1; i <= n + 1; i++)
    pre[i] = pre[i - 1] * (k - qx[i] + mod) % mod,
    fac[i] = fac[i - 1] * i % mod;
  for (long long i = n + 1; i >= 1; i--)
    suf[i] = suf[i + 1] * (k - qx[i] + mod) % mod;
  long long ans = 0;
  for (long long i = 1; i <= n + 1; i++) {
    long long s = fac[i - 1] * ((n + 1 - i) & 1 ? mod - 1 : 1) % mod *
                  fac[n + 1 - i] % mod;
    ans = (ans + qy[i] * (pre[i - 1] * suf[i + 1] % mod) % mod *
                     mul(s, mod - 2, mod) % mod) %
          mod;
  }
  return ans;
}
signed main() {
  scanf("%lld%lld", &n, &k);
  for (long long i = 1; i <= k + 2; i++)
    qx[i] = i, qy[i] = (qy[i - 1] + mul(i, k, mod)) % mod;
  printf("%lld\n", calc(k + 1, n, qx, qy));
  return 0;
}