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;
long long MOD = 1000000007;
long long fac[1100000], inv[1100000], p[1100000];
long long pow_mod(long long a, long long b, long long m) {
  long long ans = 1LL;
  a %= m;
  while (b) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
int main() {
  fac[0] = 1LL;
  inv[0] = pow_mod(fac[0], MOD - 2, MOD);
  for (long long i = 1; i <= 1010000; ++i) {
    fac[i] = i * fac[i - 1] % MOD;
    inv[i] = pow_mod(fac[i], MOD - 2, MOD);
  }
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= k + 2; ++i) {
    p[i] = p[i - 1] + pow_mod(i, k, MOD);
    p[i] %= MOD;
  }
  if (n <= k + 2) {
    cout << p[n] << endl;
    return 0;
  }
  long long x = 1LL;
  for (int i = 1; i <= k + 2; ++i) {
    x *= (n - i);
    x %= MOD;
  }
  long long ans = 0LL, flag;
  for (int i = 1; i <= k + 2; ++i) {
    if ((k + 2 - i) & 1)
      flag = -1;
    else
      flag = 1;
    ans += x * flag * pow_mod(n - i, MOD - 2, MOD) % MOD * inv[i - 1] % MOD *
           inv[k + 2 - i] % MOD * p[i];
    (ans += MOD) %= MOD;
  }
  cout << ans << endl;
  return 0;
}