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 pp = (1e9) + 7;
long long P[1000010];
long long ans, now;
int N, K;
long long quick(int x, int y) {
  long long s = 1, t = x;
  for (; y; y >>= 1) {
    if (y & 1) s = s * t % pp;
    t = t * t % pp;
  }
  return s;
}
long long get0() {
  long long t = 1;
  for (int i = N - K - 1; i < N; i++) t = t * i % pp;
  for (int i = 1; i <= K + 1; i++) t = t * quick(pp - i, pp - 2) % pp;
  return t;
}
int main() {
  scanf("%d%d", &N, &K);
  if (!K) {
    printf("%d\n", N);
    return 0;
  }
  for (int i = 1; i <= K + 2; i++) P[i] = (P[i - 1] + quick(i, K)) % pp;
  if (N <= K + 2) {
    printf("%I64d\n", P[N]);
    return 0;
  }
  ans = 0;
  now = get0();
  for (int i = 1; i <= K + 1; i++) {
    now = now * quick(i, pp - 2) % pp * (N - i + 1) % pp *
          quick(N - i, pp - 2) % pp * (pp - (K - i + 2)) % pp;
    ans = (ans + P[i] * now) % pp;
  }
  printf("%I64d", ans);
}