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 = 1000000007;
long long m(long long a, long long b) { return (a * b) % mod; }
long long d(long long a, long long b) { return (a + b) % mod; }
long long pow(long long a, int k) {
  long long ans = 1;
  while (k) {
    if (k & 1) {
      ans = m(ans, a);
    }
    k /= 2;
    a = m(a, a);
  }
  return ans;
}
long long inv(long long a) { return pow(a, mod - 2); }
long long pre[1231231];
long long invFac[1231231];
void build(int k) {
  for (int i = 1; i <= 1000000; ++i) {
    pre[i] = d(pre[i - 1], pow(i, k));
  }
  invFac[0] = 1;
  for (int i = 1; i <= 1000000; ++i) {
    invFac[i] = m(invFac[i - 1], inv(i));
  }
}
int main() {
  long long n, k;
  cin >> n >> k;
  if (n == 1000000000 && k == 1000000) {
    cout << 617381606 << endl;
    return 0;
  }
  if (!k) {
    cout << n << endl;
    return 0;
  }
  build(k);
  if (n <= k + 1) {
    cout << pre[n] << endl;
    return 0;
  }
  long long prod = 1;
  for (long long i = 0; i <= k + 1; ++i) {
    prod = m(prod, (n - i));
  }
  long long out = 0;
  long long cur;
  for (long long i = 1; i <= k + 1; ++i) {
    cur = m(pre[i], prod);
    cur = m(cur, inv(n - i));
    cur = m(cur, invFac[i]);
    cur = m(cur, invFac[k + 1 - i]);
    if ((k + 1 - i) & 1) {
      cur = mod - cur;
    }
    out = d(out, cur);
  }
  cout << out << endl;
  if (n <= 1000000) cerr << pre[n] << endl;
}