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 N = 1e6 + 5;
const int Mod = 1e9 + 7;
int n, k, x[N], y[N];
int fac[N], inv[N];
inline int Pow(int a, int x) {
  int res = 1;
  while (x) {
    if (x & 1) res = (long long)res * a % Mod;
    a = (long long)a * a % Mod;
    x >>= 1;
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  long long s = 0;
  long long Fac = 1;
  fac[0] = 1;
  for (int i = 1; i <= k + 2; i++) {
    fac[i] = (long long)fac[i - 1] * i % Mod;
    Fac *= n - i;
    Fac %= Mod;
    s += Pow(i, k);
    s %= Mod;
    x[i] = i;
    y[i] = s;
  }
  if (n <= k + 2) {
    cout << y[n];
    return 0;
  }
  inv[k + 2] = Pow(fac[k + 2], Mod - 2);
  for (int i = k + 1; i >= 0; i--)
    inv[i] = (long long)inv[i + 1] * (i + 1) % Mod;
  long long ans = 0;
  for (int i = 1; i <= k + 2; i++) {
    long long tmp = y[i];
    tmp *= inv[i - 1];
    tmp %= Mod;
    tmp *= inv[k + 2 - i];
    tmp %= Mod;
    if ((k + 2 - i) & 1) tmp *= -1;
    tmp *= Fac;
    tmp %= Mod;
    tmp *= Pow(n - i, Mod - 2);
    tmp %= Mod;
    ans += tmp;
    ans %= Mod;
  }
  cout << (ans + Mod) % Mod;
}