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 = 1e9 + 7;
long long fastPow(long long a, long long pw, long long mod) {
  long long res = 1;
  a %= mod;
  while (pw > 0) {
    if (pw & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    pw >>= 1;
  }
  return res;
}
int faulhaber(long long n, int k) {
  vector<long long> sum(k + 5, 0);
  for (long long i = 1; i <= k + 2; i++)
    sum[i] = (sum[i - 1] + fastPow(i, k, mod)) % mod;
  if (n <= k + 2) return sum[n];
  long long t = 1;
  vector<long long> fac(k + 5, 1);
  for (long long i = 1; i <= k + 2; i++) {
    t = (n - i) * t % mod;
    fac[i] = fac[i - 1] * i % mod;
  }
  long long ans = 0;
  for (long long i = 1; i <= k + 2; i++) {
    long long t1 = fastPow(fac[i - 1] * fac[k - i + 2] % mod, mod - 2, mod);
    long long t2 = fastPow(n - i, mod - 2, mod);
    if ((k - i + 2) & 1) t1 = -t1;
    ans = (ans + sum[i] * t % mod * t1 % mod * t2 % mod) % mod;
  }
  return (ans + mod) % mod;
}
int main() {
  int n, k;
  cin >> n >> k;
  cout << faulhaber(n, k) << '\n';
  return 0;
}