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;
int summ[1000005], fact[1000005], inv[1000005], ans;
int lp[1000005], rp[1000005];
int po(int a, int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  int cur = po(a, b >> 1);
  cur = 1LL * cur * cur % 1000000007;
  return 1LL * cur * po(a, b & 1) % 1000000007;
}
int main() {
  scanf("%d %d", &n, &k);
  summ[0] = 0;
  for (int i = (1); i <= (k + 1); i++)
    summ[i] = (summ[i - 1] + po(i, k)) % 1000000007;
  fact[0] = 1;
  for (int i = (1); i <= (k + 1); i++)
    fact[i] = 1LL * fact[i - 1] * i % 1000000007;
  for (int i = (0); i <= (k + 1); i++) inv[i] = po(fact[i], 1000000007 - 2);
  if (n <= k + 1)
    printf("%d\n", summ[n]);
  else {
    lp[0] = 1;
    for (int i = (0); i <= (k + 1); i++)
      lp[i + 1] = 1LL * lp[i] * (n - i) % 1000000007;
    rp[k + 2] = 1;
    for (int i = (k + 1); i >= (0); i--)
      rp[i] = 1LL * rp[i + 1] * (n - i) % 1000000007;
    for (int i = (0); i <= (k + 1); i++) {
      int cur = 1LL * lp[i] * rp[i + 1] % 1000000007;
      if ((k + 1 - i) & 1) cur *= -1;
      cur = 1LL * cur * inv[i] % 1000000007;
      cur = 1LL * cur * inv[k + 1 - i] % 1000000007;
      ans = (ans + 1LL * summ[i] * cur) % 1000000007;
    }
    printf("%d\n", (ans + 1000000007) % 1000000007);
  }
  return 0;
}