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 long long mod = 1000 * 1000 * 1000 + 7;
long long n, k;
vector<long long> ans;
long long positive(long long n) {
  n %= mod;
  (n < 0) && (n += mod);
  return n;
}
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long g = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return g;
}
long long binpow(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;
}
void calc() {
  long long x = 0;
  ans.push_back(0);
  for (int i = 0; i < k + 1; ++i) {
    x = (x + binpow(i + 1, k)) % mod;
    ans.push_back(x);
  }
}
long long solve(vector<long long> ans, long long y) {
  long long x = 0;
  long long cur = 1;
  for (int j = 1; j < (long long)ans.size(); ++j) {
    cur = (cur * positive(y - j)) % mod;
    cur = (cur * binpow(positive(0 - j), mod - 2)) % mod;
  }
  for (int i = 0; i < (long long)ans.size(); ++i) {
    x = (x + (ans[i] * cur) % mod) % mod;
    if (i + 1 >= (long long)ans.size()) break;
    long long t =
        (positive(y - i) * binpow(positive(y - (i + 1)), mod - 2)) % mod;
    cur = (cur * t) % mod;
    long long v = (positive(i - ((long long)ans.size() - 1)) *
                   binpow(positive(i + 1), mod - 2)) %
                  mod;
    cur = (cur * v) % mod;
  }
  return x;
}
int main() {
  cin >> n >> k;
  calc();
  if (n < ans.size()) {
    cout << ans[n];
  } else {
    cout << solve(ans, n);
  }
}