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 mod = 1e9 + 7;
const int maxn = 1e6 + 10;
int n, k, y[maxn], prod[maxn], f[maxn], g[maxn], h[maxn];
int pow(int x, int p) {
  if (!p) return 1;
  int t = x;
  p--;
  while (p) {
    if (p & 1) t = ((long long)t * x) % mod;
    x = ((long long)x * x) % mod;
    p >>= 1;
  }
  return t;
}
void solve() {
  scanf("%d%d", &n, &k);
  f[0] = g[0] = 1;
  int ret = 1, ans = 0;
  for (int i = 1; i <= k + 2; ++i) y[i] = (y[i - 1] + pow(i, k)) % mod;
  if (n <= k + 2) {
    printf("%d\n", y[n]);
    return;
  }
  for (int i = 1; i <= k + 2; ++i) f[i] = (long long)f[i - 1] * (mod - i) % mod;
  for (int i = 1; i <= k + 2; ++i) g[i] = (long long)g[i - 1] * i % mod;
  for (int i = 1; i <= k + 2; ++i)
    h[i] = (long long)f[k + 2 - i] * g[i - 1] % mod;
  for (int i = 1; i <= k + 2; ++i) ret = ((long long)ret * (n - i)) % mod;
  for (int i = 1; i <= k + 2; ++i)
    prod[i] =
        (long long)ret * pow(n - i, mod - 2) % mod * pow(h[i], mod - 2) % mod;
  for (int i = 1; i <= k + 2; ++i)
    ans = (ans + (long long)prod[i] * y[i]) % mod;
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}