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 M = 1000010;
const long long inf = 0x7f7f7f7f;
const double eps = 1e-6;
const long long mod = 1e9 + 7;
inline long long read(void) {
  long long x = 0, f = 1;
  char s = getchar();
  while (!isdigit(s)) {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (isdigit(s)) {
    x = (x << 1) + (x << 3) + (s ^ 48);
    s = getchar();
  }
  return x * f;
}
long long n, k, ans, pre[M], suf[M], fac[M], inv[M], y;
inline long long qpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod, b >>= 1;
  }
  return ans;
}
signed main(void) {
  n = read(), k = read();
  pre[0] = suf[k + 3] = fac[0] = 1, inv[1] = 1;
  for (long long i = 1; i <= k + 2; i++) fac[i] = fac[i - 1] * i % mod;
  for (long long i = 2; i <= k + 2; i++)
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  for (long long i = 2; i <= k + 2; i++) inv[i] = inv[i] * inv[i - 1] % mod;
  for (long long i = 1; i <= k + 2; i++) pre[i] = pre[i - 1] * (n - i) % mod;
  for (long long i = k + 2; i >= 1; i--) suf[i] = suf[i + 1] * (n - i) % mod;
  for (long long i = 1; i <= k + 2; i++) {
    y = (y + qpow(i, k)) % mod;
    long long a = pre[i - 1] * suf[i + 1] % mod;
    long long b =
        (fac[i - 1] * fac[k + 2 - i] % mod * ((k + 2 - i) & 1 ? -1 : 1) + mod) %
        mod;
    ans = (ans + y * a % mod * qpow(b, mod - 2) % mod + mod) % mod;
  }
  printf("%lld", ans);
  return 0;
}