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 mod = 1e9 + 7;
const int maxn = 1e6 + 5;
long long f[maxn], fac[maxn];
long long pow(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;
}
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 1; i <= k + 2; i++) {
    f[i] = (f[i - 1] + pow(i * 1LL, k)) % mod;
  }
  if (n <= k + 2) {
    cout << f[n] << endl;
    return 0;
  }
  fac[0] = 1;
  for (int i = 1; i <= k + 2; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
  }
  long long cur = 1, ans = 0;
  for (int i = 1; i <= k + 2; i++) {
    cur = (cur * (n - i)) % mod;
  }
  for (int i = 1; i <= k + 2; i++) {
    long long inv1 = pow(n - i, mod - 2) % mod;
    long long inv2 =
        pow(fac[i - 1] % mod * fac[k + 2 - i] % mod, mod - 2) % mod;
    int sign = (k + 2 - i) % 2 ? -1 : 1;
    ans = (ans + sign * inv1 * inv2 % mod * f[i] % mod * cur % mod) % mod;
  }
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}