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;
inline int read() {
  int s = 0, t = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') t = -1;
    c = getchar();
  }
  while (isdigit(c)) s = s * 10 + c - 48, c = getchar();
  return s * t;
}
const int maxn = 1e6 + 5, p = 1e9 + 7;
long long rev[maxn] = {1, 1}, L[maxn], R[maxn], f[maxn];
inline int Pow(long long x, int t) {
  int ret = 1;
  while (t) {
    if (t & 1) ret = ret * x % p;
    x = x * x % p, t >>= 1;
  }
  return ret;
}
int main() {
  int n = read(), k = read();
  if (!k) return printf("%d\n", n), 0;
  for (register int i = 1; i <= k + 2; i++) f[i] = (Pow(i, k) + f[i - 1]) % p;
  L[0] = R[k + 3] = 1;
  for (register int i = 1; i <= k + 2; i++) L[i] = L[i - 1] * (n - i) % p;
  for (register int i = k + 2; i >= 1; i--) R[i] = R[i + 1] * (n - i) % p;
  for (register int i = 2; i <= k + 2; i++)
    rev[i] = (p - p / i) * rev[p % i] % p;
  for (register int i = 2; i <= k + 2; i++) rev[i] = rev[i - 1] * rev[i] % p;
  long long ans = 0, tmp;
  for (register int i = 1; i <= k + 2; i++) {
    tmp = L[i - 1] * R[i + 1] % p;
    tmp = f[i] * tmp % p * rev[i - 1] % p * rev[k + 2 - i] % p;
    if ((k + 2 - i) & 1) tmp = -tmp;
    ans = ((ans + tmp) % p + p) % p;
  }
  cout << ans << endl;
  return 0;
}