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 p = 1e9 + 7, N = 1000100;
template <class I>
inline void read(I &z) {
  z = 0;
  char c = getchar();
  int base = 1;
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), base = -1;
  while (isdigit(c)) z = z * 10 + c - '0', c = getchar();
  z *= base;
}
long long power(long long x, int k) {
  long long z = 1;
  for (; k; k >>= 1, x = x * x % p)
    if (k & 1) z = z * x % p;
  return (z % p + p) % p;
}
long long n, k, f[N], l[N];
long long fac[N], invfac[N], s, ans = 0;
int main(int argc, char const *argv[]) {
  read(n), read(k);
  if (n <= k + 2) {
    f[1] = 1;
    for (int i = 2; i <= n; ++i) f[i] = (f[i - 1] + power(i, k)) % p;
    return printf("%lld", f[n]), 0;
  }
  f[1] = 1;
  for (int i = 2; i <= k + 2; ++i) f[i] = (f[i - 1] + power(i, k)) % p;
  fac[0] = 1;
  for (int i = 1; i <= k + 2; ++i) fac[i] = fac[i - 1] * i % p;
  invfac[k + 2] = power(fac[k + 2], p - 2);
  for (int i = k + 1; i >= 0; --i) invfac[i] = invfac[i + 1] * (i + 1) % p;
  s = 1;
  for (int i = 1; i <= k + 2; ++i) s = s * (n - i) % p;
  for (int i = 1; i <= k + 2; ++i) {
    l[i] = s * power(n - i, p - 2) % p;
    l[i] = (l[i] * invfac[i - 1] % p * invfac[k + 2 - i] % p *
                (((k + 2 - i) & 1) ? -1 : 1) % p +
            p) %
           p;
  }
  ans = 0;
  for (int i = 1; i <= k + 2; ++i) ans = (ans + l[i] * f[i] % p) % p;
  printf("%lld", (ans % p + p) % p);
  return 0;
}