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 maxn = 1e6 + 7;
const int mod = 1e9 + 7;
long long q_pow(long long a, int b) {
  long long ret = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
long long f[maxn], invF[maxn], inv[maxn];
int n, k;
long long M = 1;
void init() {
  M = n;
  for (int i = 1; i <= k + 1; i++) f[i] = (f[i - 1] + q_pow(i, k)) % mod;
  invF[0] = 1;
  for (int i = 1; i <= k + 1; i++)
    invF[i] = invF[i - 1] * i % mod, M = M * (n - i) % mod;
  invF[k + 1] = q_pow(invF[k + 1], mod - 2);
  for (int i = k; i > 0; i--) invF[i] = invF[i + 1] * (i + 1) % mod;
  for (int i = 1; i <= k + 1; i++) inv[i] = q_pow(n - i, mod - 2);
}
long long cal() {
  long long ret = 0, t, ty;
  for (int i = 1; i <= k + 1; i++) {
    t = M * inv[i] % mod;
    ty = invF[i] * invF[k + 1 - i] % mod;
    if (~(k - i) & 1) ty = (mod - ty) % mod;
    ret = (ret + t * ty % mod * f[i]) % mod;
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  if (!k) return 0 * printf("%d\n", n);
  init();
  if (n <= k + 1) return 0 * printf("%lld\n", f[n]);
  printf("%lld\n", cal());
  return 0;
}