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 n, k, ans, tmp;
long long pre[1000100], suf[1000100], fac[1000100];
long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 1) + (s << 3) + ch - '0', ch = getchar();
  return s * w;
}
long long quickpow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
    y >>= 1;
  }
  return res;
}
signed main() {
  n = read();
  k = read();
  pre[0] = fac[0] = suf[k + 3] = 1;
  for (long long i = k + 2; i >= 1; i--)
    suf[i] = suf[i + 1] * (n - i) % 1000000007;
  for (long long i = 1; i <= k + 2; i++)
    fac[i] = fac[i - 1] * i % 1000000007,
    pre[i] = pre[i - 1] * (n - i) % 1000000007;
  for (long long i = 1, fir, sec; i <= k + 2; i++) {
    tmp = (tmp + quickpow(i, k)) % 1000000007;
    fir = pre[i - 1] * suf[i + 1] % 1000000007;
    sec = fac[i - 1] * ((k - i) & 1 ? -1 : 1) * fac[k + 2 - i] % 1000000007;
    ans = ((ans + tmp * fir % 1000000007 * quickpow(sec, 1000000007 - 2) %
                      1000000007) %
               1000000007 +
           1000000007) %
          1000000007;
  }
  printf("%lld\n", ans);
  return 0;
}