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;
namespace lgr {
short factor[1000010];
int P[1000010], S[1000010], ar[1000010], inv[1000010];
inline int Add(int a, int b) {
  return a + b >= 1000000007 ? a + b - 1000000007 : a + b;
}
inline int Sub(int a, int b) { return a - b < 0 ? a - b + 1000000007 : a - b; }
inline int bigMod(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int lagrange(long long int n, int k) {
  if (!k) return (n % 1000000007);
  if (!inv[0]) {
    int x = 1;
    for (int i = 2; i < 1000010; i++) x = (long long int)x * i % 1000000007;
    inv[1000010 - 1] = bigMod(x, 1000000007 - 2);
    for (int i = 1000010 - 2; i >= 0; i--)
      inv[i] = (long long int)inv[i + 1] * (i + 1) % 1000000007;
  }
  k++;
  for (int i = 0; i <= k; i++) ar[i] = bigMod(i, k - 1);
  for (int i = 1; i <= k; i++) ar[i] = Add(ar[i], ar[i - 1]);
  if (n <= k) return ar[n];
  P[0] = 1, S[k] = 1;
  for (int i = 1; i <= k; i++)
    P[i] = (n - i + 1) % 1000000007 * P[i - 1] % 1000000007;
  for (int i = k - 1; i >= 0; i--)
    S[i] = (n - i - 1) % 1000000007 * S[i + 1] % 1000000007;
  int res = 0;
  for (int i = 0; i <= k; i++) {
    int x = (long long int)ar[i] * P[i] % 1000000007 * S[i] % 1000000007 *
            inv[k - i] % 1000000007 * inv[i] % 1000000007;
    if ((k - i) & 1)
      res = Sub(res, x);
    else
      res = Add(res, x);
  }
  return (res % 1000000007);
}
}  // namespace lgr
int main() {
  long long int n;
  int k;
  scanf("%lld %d", &n, &k);
  printf("%d\n", lgr::lagrange(n, k));
}