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>
const long long mod = 1e9 + 7;
const long long K = 1e6 + 10;
using namespace std;
long long T, k, n;
long long y[K];
inline long long quick_pow(long long xa, long long xb) {
  xa %= mod;
  long long res = 1;
  for (; xb; xb >>= 1) {
    if (xb & 1) res = (res * xa) % mod;
    xa = (xa * xa) % mod;
  }
  return res;
}
long long suf[K], pre[K], fac[K];
inline void lagrange(long long t, long long xys) {
  pre[0] = 1;
  for (long long i = 1; i <= xys; ++i)
    pre[i] = (pre[i - 1] * (t - i) % mod) % mod;
  suf[0] = 1;
  for (long long i = 1; i <= xys; ++i)
    suf[i] = (suf[i - 1] * (t - xys + i - 1) % mod) % mod;
  fac[0] = 1;
  for (long long i = 1; i <= xys; ++i) fac[i] = (fac[i - 1] * i) % mod;
  long long ans = 0;
  for (long long i = 1; i <= xys; ++i) {
    long long s1 = (pre[i - 1] % mod * suf[(xys - i)] % mod) % mod,
              s2 = quick_pow((((fac[i - 1] * fac[abs(i - xys)]) % mod) *
                              quick_pow(-1, abs(i - xys))) %
                                 mod,
                             mod - 2);
    ans = (ans + ((y[i] % mod) * ((s1 * s2) % mod)) % mod) % mod;
  }
  cout << (ans + mod) % mod << endl;
}
signed main() {
  cin >> n >> k;
  for (long long i = 1; i <= k + 2; ++i)
    y[i] = (y[i - 1] + quick_pow(i, k)) % mod;
  lagrange(n, k + 2);
  return 0;
}