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;
int n, k, y[1000005];
long long fpow(long long a, long long b) {
  long long r = 1;
  for (; b; b /= 2, a = (a * a) % 1000000007)
    if (b & 1) r = (r * a) % 1000000007;
  return r;
}
int main() {
  scanf("%d %d", &n, &k);
  int s = 0;
  for (int i = 0; i <= k + 1; i++) {
    y[i] = s;
    s = (s + fpow(i + 1, k)) % 1000000007;
  }
  if (n <= k + 1)
    printf("%d\n", y[n]);
  else {
    int ans = 0, top = 1;
    for (int j = 0; j <= k + 1; j++) top = (top * 1LL * (n - j)) % 1000000007;
    int pre = 1, suf = 1;
    for (int i = 1; i <= k + 1; i++) suf = (suf * 1LL * i) % 1000000007;
    for (int i = 0; i <= k + 1; i++) {
      int t = (top * fpow(n - i, 1000000007 - 2)) % 1000000007;
      int down = (pre * 1LL * suf) % 1000000007;
      int here = (t * fpow(down, 1000000007 - 2)) % 1000000007;
      ans = (ans + here * 1LL * y[i]) % 1000000007;
      pre = (pre * 1LL * (-(i + 1))) % 1000000007;
      suf = (suf * fpow(k + 1 - i, 1000000007 - 2)) % 1000000007;
    }
    printf("%d\n", abs(ans));
  }
  return 0;
}