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 mod = 1e9 + 7;
const int maxn = 1e6 + 7;
long long quickpow(long long m, long long n, long long k) {
  long long b = 1;
  while (n > 0) {
    if (n & 1) b = (b * m) % k;
    n = n >> 1;
    m = (m * m) % k;
  }
  return b;
}
long long p[maxn];
long long fac[maxn];
int n, k;
int main() {
  fac[0] = 1;
  for (int i = 1; i < maxn; i++) fac[i] = (fac[i - 1] * i) % mod;
  scanf("%d%d", &n, &k);
  p[0] = 0;
  for (int i = 1; i <= k + 2; i++)
    p[i] = (p[i - 1] + quickpow(i, k, mod)) % mod;
  if (n <= k + 2) {
    printf("%d\n", p[n]);
    return 0;
  }
  long long cur = 1;
  for (int i = 1; i <= k + 2; i++) cur = (cur * (n - i)) % mod;
  long long ans = 0;
  for (int i = 1; i <= k + 2; i++) {
    long long tmp =
        quickpow(fac[k + 2 - i] % mod * fac[i - 1] % mod, mod - 2, mod);
    long long tmp2 = quickpow(n - i, mod - 2, mod);
    if ((k + 2 - i) % 2) tmp = -tmp;
    ans = (ans + p[i] * cur % mod * tmp % mod * tmp2) % mod;
  }
  cout << ans << endl;
}