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 LL = long long;
LL powMod(LL x, LL n, LL p) {
  LL r = 1;
  while (n) {
    if (n & 1) r = r * x % p;
    n >>= 1;
    x = x * x % p;
  }
  return r;
}
std::vector<int> spf(int N) {
  std::vector<int> sp(N), p{2};
  for (int i = 2; i < N; i += 2) sp[i] = 2;
  for (int i = 1; i < N; i += 2) sp[i] = i;
  for (int i = 3; i < N; i += 2) {
    if (sp[i] == i) p.emplace_back(i);
    for (int j = 1; j < p.size() && p[j] <= sp[i] && i * p[j] < N; ++j) {
      sp[i * p[j]] = p[j];
    }
  }
  return sp;
}
LL Lagrange(std::vector<LL> f, int m, LL M) {
  int n = f.size();
  if (m < n) return f[m];
  LL nfac = 1;
  for (int i = 2; i < n; ++i) nfac = nfac * i % M;
  std::vector<LL> ifac(n), AP(n), BP(n);
  ifac[n - 1] = powMod(nfac, M - 2, M);
  for (int i = n - 1; i > 0; --i) ifac[i - 1] = ifac[i] * i % M;
  AP[0] = BP[n - 1] = 1;
  for (int i = 1; i < n; ++i) AP[i] = AP[i - 1] * (m + 1 - i) % M;
  for (int i = n - 2; ~i; --i) BP[i] = BP[i + 1] * (m - 1 - i) % M;
  LL ans = 0;
  for (int i = 0; i < n; ++i) {
    LL x = f[i] * AP[i] % M * BP[i] % M * ifac[i] % M * ifac[n - 1 - i] % M;
    ans += (n - 1 - i) & 1 ? M - x : x;
  }
  return ans % M;
}
LL powSum(LL n, int k, LL M, std::vector<int> &sp) {
  if (k == 0) return n % M;
  std::vector<LL> f(k + 2);
  f[1] = 1;
  for (int i = 2; i < f.size(); ++i) {
    if (sp[i] == i)
      f[i] = powMod(i, k, M);
    else
      f[i] = f[sp[i]] * f[i / sp[i]] % M;
  }
  for (int i = 1; i < f.size(); ++i) {
    f[i] += f[i - 1];
    if (f[i] >= M) f[i] -= M;
  }
  return Lagrange(f, n, M);
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  const LL M = 1e9 + 7;
  int n, k;
  std::cin >> n >> k;
  auto sp = spf(k + 2);
  std::cout << powSum(n, k, M, sp) << "\n";
  return 0;
}