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>
template <class T>
T read() {
  T s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return w * s;
}
int dbg = 0;
using namespace std;
template <class T>
T cmin(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T cmax(T a, T b) {
  return a > b ? a : b;
}
template <class T>
void cswp(T &a, T &b) {
  T t = a;
  a = b, b = t;
}
struct OI {
  int rp, score;
} CSPS, CSPJ;
const int P = 1e9 + 7;
int n, k;
long long ls[1000010], rs[1000010], fa[1000010];
long long qp(long long a, long long k) {
  long long ret = 1;
  while (k) {
    if (k & 1) ret = ret * a % P;
    a = a * a % P;
    k >>= 1;
  }
  return ret;
}
signed main() {
  ++CSPJ.rp, ++CSPJ.score, ++CSPS.rp, ++CSPS.score, 1004535809;
  n = read<long long>(), k = read<long long>();
  ls[0] = rs[k + 3] = fa[0] = 1;
  for (register int i = 1; i <= k + 2; ++i) ls[i] = ls[i - 1] * (n - i) % P;
  for (register int i = k + 2; i >= 1; --i) rs[i] = rs[i + 1] * (n - i) % P;
  for (register int i = 1; i <= k + 2; ++i) fa[i] = fa[i - 1] * i % P;
  long long sum = 0, ans = 0;
  for (register int i = 1; i <= k + 2; ++i) {
    sum = (sum + qp(i, k)) % P;
    long long x = ls[i - 1] * rs[i + 1] % P;
    long long y = fa[i - 1] * fa[k + 2 - i] * (((k - i) & 1) ? -1 : 1) % P;
    ans = (ans + sum * x % P * qp(y, P - 2) % P) % P;
  }
  return !printf("%lld\n", (ans + P) % P);
}