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;
inline long long read() {
  long long ret = 0, flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') ret = ret * 10 + (c ^ '0'), c = getchar();
  return flag * ret;
}
const long long N = 1e6 + 5, mod = 1e9 + 7;
long long n, k;
long long y[N], fac[N], pre[N], suf[N];
long long qpow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod, b >>= 1;
  }
  return ret;
}
void prework() {
  fac[0] = 1;
  for (long long i = 1; i <= k + 2; i++) fac[i] = fac[i - 1] * i % mod;
  for (long long i = 1; i <= k + 2; i++) fac[i] = qpow(fac[i], mod - 2);
  pre[0] = suf[k + 3] = 1;
  for (long long i = 1; i <= k + 2; i++)
    pre[i] = pre[i - 1] * (n - i + mod) % mod;
  for (long long i = k + 2; i >= 1; i--)
    suf[i] = suf[i + 1] * (n - i + mod) % mod;
}
long long lagrange(long long *s, long long k, long long n) {
  prework();
  long long ans = 0;
  for (long long i = 1; i <= k + 1; i++) {
    long long t1 = pre[i - 1] * suf[i + 1] % mod;
    long long t2 = fac[i - 1] * fac[k + 1 - i] % mod;
    if ((k + 1 - i) & 1) t2 = mod - t2;
    ans = (ans + y[i] * t1 % mod * t2 % mod) % mod;
  }
  return ans;
}
int main() {
  n = read(), k = read();
  for (long long i = 1; i <= k + 2; i++) y[i] = (y[i - 1] + qpow(i, k)) % mod;
  printf("%lld", lagrange(y, k + 1, n));
  return 0;
}