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;
template <class T>
istream& operator>>(istream& in, vector<T>& a) {
  for (int i = 0; i < a.size(); ++i) in >> a[i];
  return in;
}
template <class T>
ostream& operator<<(ostream& o, vector<T>& a) {
  for (int i = 0; i < a.size(); ++i) o << a[i] << " ";
  return o;
}
const int INF9 = 2e9 + 5;
const int MOD = 1e9 + 7;
int mult(int x, int y) {
  long long t = x;
  t *= y;
  t %= MOD;
  return t;
}
int add(int x, int y) { return (x + y) % MOD; }
int mod(int x) {
  x %= MOD;
  return x < 0 ? x + MOD : x;
}
int binpow(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = mult(res, x);
    x = mult(x, x);
    y >>= 1;
  }
  return res;
}
int divx(int x, int y) { return mult(x, binpow(y, MOD - 2)); }
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<int> v(k + 2);
  v[0] = 0;
  for (int i = 0; i < k + 1; i++) {
    v[i + 1] = add(v[i], binpow(i + 1, k));
  }
  if (n < v.size()) {
    cout << v[n] << endl;
    return 0;
  }
  int ans = 0;
  int k2 = 1;
  for (int i = 1; i < k + 2; i++) {
    k2 = mult(k2, mod(n - i));
    k2 = divx(k2, mod(0 - i));
  }
  for (int i = 0; i < k + 2; i++) {
    ans = add(ans, mult(v[i], k2));
    k2 = mult(k2, divx(mod(n - i), mod(n - i - 1)));
    k2 = mult(k2, divx(mod(i - k - 1), mod(i + 1)));
  }
  cout << ans << endl;
  return 0;
}