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;
int MOD = 1e9 + 7;
long long modinv(int a, int b, int x, int y) {
  if (b == 0) return x;
  return modinv(b, a % b, y, x - a / b * y);
}
long long Div(int a, int b) { return 1ll * a * modinv(b, MOD, 1, 0) % MOD; }
long long myPow(int a, int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long aa = myPow(a, b / 2);
  aa = aa * aa % MOD;
  aa = aa * myPow(a, b % 2) % MOD;
  return aa;
}
int main() {
  int n, k;
  cin >> n >> k;
  long long int frac[k + 2];
  frac[0] = 1;
  for (int i = (1) - ((1) > (k + 2)); i != (k + 2) - ((1) > (k + 2));
       i += 2 * ((1) < (k + 2)) - 1)
    frac[i] = (frac[i - 1] * i) % MOD;
  long long int firstK[k + 2];
  firstK[0] = 0;
  for (int i = (1) - ((1) > (k + 2)); i != (k + 2) - ((1) > (k + 2));
       i += 2 * ((1) < (k + 2)) - 1) {
    firstK[i] = (firstK[i - 1] + myPow(i, k)) % MOD;
  }
  if (n <= k + 1) {
    cout << firstK[n] << endl;
    return 0;
  }
  long long int summ = 1;
  for (int i = (0) - ((0) > (k + 2)); i != (k + 2) - ((0) > (k + 2));
       i += 2 * ((0) < (k + 2)) - 1) {
    summ *= (n - i);
    summ %= MOD;
  }
  long long int ans = 0;
  for (int i = (0) - ((0) > (k + 2)); i != (k + 2) - ((0) > (k + 2));
       i += 2 * ((0) < (k + 2)) - 1) {
    long long int aa =
        firstK[i] * Div(Div(Div(summ, n - i), frac[k + 1 - i]), frac[i]) % MOD;
    if (!((i + k) % 2)) aa *= -1;
    ans += aa;
    ans %= MOD;
  }
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}