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>
const int N = 1e6 + 5, Mod = 1e9 + 7;
using namespace std;
int n, k;
long long ans, y;
long long s1[N], s2[N], fac[N];
inline long long power(long long a, long long b) {
  long long tmp = a, res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * tmp % Mod;
    tmp = tmp * tmp % Mod;
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  s1[0] = s2[k + 3] = fac[0] = 1;
  for (int i = 1; i <= k + 2; i++) s1[i] = s1[i - 1] * (n - i) % Mod;
  for (int i = k + 2; i >= 1; i--) s2[i] = s2[i + 1] * (n - i) % Mod;
  for (int i = 1; i <= k + 2; i++) fac[i] = fac[i - 1] * i % Mod;
  for (int i = 1; i <= k + 2; i++) {
    y = (y + power(i, k)) % Mod;
    long long a = s1[i - 1] * s2[i + 1] % Mod, b = fac[i - 1] *
                                                   ((k - i) & 1 ? -1ll : 1ll) *
                                                   fac[k + 2 - i] % Mod;
    ans = (ans + y * a % Mod * power(b, Mod - 2) % Mod) % Mod;
  }
  printf("%lld\n", (ans + Mod) % Mod);
  return 0;
}