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 int MAX = 1e6 + 1;
const int mod = 1e9 + 7;
long long y[MAX], fac[MAX], b[MAX];
long long quick(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;
}
int main() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  fac[0] = 1;
  for (long long i = 1; i <= k + 2; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
  }
  if (k == 0) {
    cout << n << endl;
    return 0;
  }
  y[0] = 0;
  for (long long i = 1; i <= k + 2; i++) {
    y[i] = (y[i - 1] + quick(i, k)) % mod;
  }
  if (n <= k + 2) {
    cout << y[n] << endl;
    return 0;
  }
  long long ans1 = 1;
  for (long long i = 1; i <= k + 2; i++) ans1 = (ans1 * (n - i)) % mod;
  long long ans = 0;
  for (long long i = 1; i <= k + 2; i++) {
    long long p1 = quick(n - i, mod - 2) % mod;
    long long p2 = quick(fac[i - 1] * fac[k + 2 - i] % mod, mod - 2) % mod;
    long long fu = ((k + 2 - i) % 2 == 1 ? -1 : 1);
    long long cur = y[i] * p1 % mod * p2 % mod * ans1 % mod;
    cur *= fu;
    if (cur < 0) cur = (cur + mod) % mod;
    ans = (ans + cur) % mod;
  }
  cout << ans << endl;
  return 0;
}