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 = 1000000007;
using namespace std;
int k;
int n;
long long fac[1000006];
long long y[1000006];
long long pi = 1;
long long q_mod(long long a, long long b, long long mod) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  cin >> n >> k;
  y[0] = 0;
  for (int i = 1; i <= k + 2; i++) {
    y[i] = (y[i - 1] + q_mod(i, k, mod)) % mod;
  }
  if (n <= k + 2) {
    cout << y[n] << endl;
    return 0;
  }
  fac[0] = 1;
  for (int i = 1; i <= 1000006; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
  }
  for (int i = 1; i <= k + 2; i++) {
    pi = (pi * (n - i)) % mod;
  }
  long long ans = 0;
  for (int i = 1; i <= k + 2; i++) {
    long long f = ((k + 2 - i) % 2) ? -1 : 1;
    long long inv =
        q_mod(fac[k + 2 - i] % mod * fac[i - 1] % mod, mod - 2, mod);
    long long inv2 = q_mod(n - i, mod - 2, mod);
    ans = (ans + f * y[i] * pi % mod * inv % mod * inv2 % mod) % mod;
  }
  cout << (ans + mod) % mod << endl;
  return 0;
}