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;
long long nn, k, hu[1000010];
const long long mod = 1e9 + 7;
namespace polysum {
const int D = 1e6 + 10;
long long a[D], f[D], g[D], p[D], p1[D], p2[D], b[D], h[D][2], C[D];
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long calcn(int d, long long *a, long long n) {
  if (n <= d) return a[n];
  p1[0] = p2[0] = 1;
  for (int i = 0; i < d + 1; i++) {
    long long t = (n - i + mod) % mod;
    p1[i + 1] = p1[i] * t % mod;
  }
  for (int i = 0; i < d + 1; i++) {
    long long t = (n - d + i + mod) % mod;
    p2[i + 1] = p2[i] * t % mod;
  }
  long long ans = 0;
  for (int i = 0; i < d + 1; i++) {
    long long t =
        g[i] * g[d - i] % mod * p1[i] % mod * p2[d - i] % mod * a[i] % mod;
    if ((d - i) & 1)
      ans = (ans - t + mod) % mod;
    else
      ans = (ans + t) % mod;
  }
  return ans;
}
void init(int M) {
  f[0] = f[1] = g[0] = g[1] = 1;
  for (int i = 2; i < M + 5; i++) f[i] = f[i - 1] * i % mod;
  g[M + 4] = powmod(f[M + 4], mod - 2);
  for (int i = M + 4 - 1; i >= 1; i--) g[i] = g[i + 1] * (i + 1) % mod;
}
long long polysum(long long m, long long *a, long long n) {
  for (int i = 0; i <= m; i++) b[i] = a[i];
  b[m + 1] = calcn(m, b, m + 1);
  for (int i = 1; i < m + 2; i++) b[i] = (b[i - 1] + b[i]) % mod;
  return calcn(m + 1, b, n);
}
}  // namespace polysum
long long qpow(long long val, long long m) {
  long long now = val, temp = 1;
  while (m) {
    if (m & 1) temp = temp * now % mod;
    now = now * now % mod;
    m = (m >> 1);
  }
  return temp;
}
int main() {
  cin >> nn >> k;
  if (k == 0) {
    printf("%I64d\n", nn);
    return 0;
  }
  polysum::init(k);
  hu[0] = 0;
  for (int i = 1; i < k + 1; i++) hu[i] = qpow(i, k);
  long long re = polysum::polysum(k, &hu[0], nn);
  printf("%I64d\n", re);
  return 0;
}