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;
inline void setmin(int &x, int y) {
  if (y < x) x = y;
}
inline void setmax(int &x, int y) {
  if (y > x) x = y;
}
inline void setmin(long long &x, long long y) {
  if (y < x) x = y;
}
inline void setmax(long long &x, long long y) {
  if (y > x) x = y;
}
const int N = 100000;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
long long bin_pow(long long a, long long p) {
  if (a == 0) return 0;
  long long res = 1;
  while (p) {
    if (p & 1) res = res * a % MOD;
    a = a * a % MOD;
    p >>= 1;
  }
  return res;
}
long long rev(long long x) { return bin_pow(x, MOD - 2); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  long long x[k + 2], y[k + 2];
  for (int i = 0; i < k + 2; i++) {
    x[i] = i;
    y[i] = bin_pow(x[i], k);
    if (i > 0) y[i] = (y[i] + y[i - 1]) % MOD;
  }
  if (n <= k + 1) {
    cout << y[n] << "\n";
    return 0;
  }
  long long A = 1, B = 1;
  for (int i = 0; i < k + 2; i++) {
    A = A * (n - x[i]) % MOD;
    if (i > 0) B = B * (x[0] - x[i] + MOD) % MOD;
  }
  long long ans = 0;
  for (int i = 0; i < k + 2; i++) {
    ans = (ans + y[i] * (A * rev(n - x[i]) % MOD) % MOD * rev(B) % MOD) % MOD;
    if (i < k + 1) {
      B = B * (i + 1) % MOD;
      B = B * rev(-(k + 1 - i) + MOD) % MOD;
    }
  }
  cout << ans << "\n";
  return 0;
}