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 <int mod = (long long)(1e9 + 7)>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while (n) {
      if (n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};
long long extGCD(long long a, long long b, long long &s, long long &t) {
  s = 1, t = 0;
  long long u = 0, v = 1;
  while (b) {
    long long tmp = a / b;
    a -= b * tmp;
    s -= u * tmp;
    t -= v * tmp;
    swap(s, u);
    swap(t, v);
    swap(a, b);
  }
  return a;
}
long long calcinv(long long a, long long m) {
  long long s, t;
  extGCD(a, m, s, t);
  return (s + m) % m;
}
vector<long long> lagrange_interpolation(long long mod, vector<long long> &y,
                                         vector<long long> &x) {
  assert(y.size() == x.size());
  long long n = y.size();
  vector<long long> ans(n, 0), Q(n), c[2];
  for (int i = 0; i < 2; ++i) c[i] = vector<long long>(n, 0);
  c[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    long long inv = 1;
    for (int j = 0; j < n; ++j)
      if (j != i) {
        inv *= x[i] - x[j];
        if ((inv %= mod) < 0) inv += mod;
      }
    Q[i] = y[i] * calcinv(inv, mod) % mod;
    for (int j = 0; j < n; ++j) {
      c[(i + 1) % 2][j] = (c[i % 2][j] * (-x[i]) % mod + mod) % mod;
      if (j != 0) (c[(i + 1) % 2][j] += c[i % 2][j - 1]) %= mod;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j >= 0; --j) {
      if (j == n - 1)
        c[(n + 1) % 2][j] = 1;
      else
        c[(n + 1) % 2][j] =
            (c[n % 2][j + 1] + c[(n + 1) % 2][j + 1] * x[i] % mod) % mod;
      (ans[j] += (c[(n + 1) % 2][j] * Q[i]) % mod) %= mod;
    }
  }
  return ans;
}
template <typename T>
T lagrange_interpolation(const vector<T> &y, const T &t, const T &a = 0,
                         const T &d = 1) {
  long long n = y.size();
  T res = 0, p = 1;
  for (int i = 1; i < n; ++i) {
    p *= t - (a + d * i);
    p /= -d * i;
  }
  for (int i = 0; i < n; ++i) {
    res += y[i] * p;
    p *= t - (a + d * i);
    p /= t - d * (i + 1);
    p *= d * (i - (n - 1));
    p /= d * (i + 1);
  }
  return res;
}
long long n, t;
vector<ModInt<>> v;
ModInt<> solve(long long x);
int main() {
  cin >> n >> t;
  cout << solve(n) << endl;
  return 0;
}
ModInt<> solve(long long x) {
  vector<ModInt<>> v;
  v.push_back(0);
  ModInt<> sum = 0;
  for (int i = 0; i <= t; ++i) {
    sum += ModInt<>(i + 1).pow(t);
    v.push_back(sum);
  }
  if (x < v.size()) return v[x];
  return lagrange_interpolation<ModInt<>>(v, x);
}