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 int mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  if (b < 0) return 0;
  long long ans = 1;
  a %= mod;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    b >>= 1, a = (a * a) % mod;
  }
  return ans % mod;
}
long long Lagrange_Polynomial(vector<long long> a, long long t) {
  int n = a.size();
  if (t == 0) return 0;
  if (t <= n) return a[t - 1];
  vector<long long> pre(n + 10, 1);
  vector<long long> suf(n + 10, 1);
  vector<long long> fac(n + 10, 1);
  vector<long long> inv(n + 10, 1);
  for (int i = 1; i <= n; i++)
    pre[i] = pre[i - 1] * ((t - i) % mod), pre[i] %= mod;
  for (int i = n; i >= 1; i--)
    suf[i] = suf[i + 1] * ((t - i) % mod), suf[i] %= mod;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  inv[n] = qpow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    long long x = a[i - 1] * pre[i - 1] % mod * suf[i + 1] % mod;
    if (i - 1 > 0) x *= inv[i - 1], x %= mod;
    x *= inv[n - i], x %= mod;
    if ((n - i) & 1)
      res = (res - x + mod) % mod;
    else
      res = (res + x + mod) % mod;
  }
  return (res % mod + mod) % mod;
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<long long> a;
  long long x = 0;
  for (int i = 1; i <= k + 2; i++) x += qpow(i, k), x %= mod, a.push_back(x);
  cout << Lagrange_Polynomial(a, n) << '\n';
  return 0;
}