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 const xn = 1e6 + 5, mod = 1e9 + 7;
int n, k, f[xn];
long long fac[xn];
int pw(long long a, int b) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % mod)
    if (b & 1) ret = (ret * a) % mod;
  return ret;
}
int upt(int x) {
  while (x >= mod) x -= mod;
  while (x < 0) x += mod;
  return x;
}
long long get(int i) {
  if (i == k + 2) return fac[i - 1];
  return fac[i - 1] * fac[k + 2 - i] % mod;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k + 2; i++) f[i] = upt(f[i - 1] + pw(i, k));
  if (n <= k + 2) {
    printf("%d\n", f[n]);
    return 0;
  }
  int sum = 0;
  long long s1 = 1;
  fac[0] = 1;
  for (int i = 1; i <= k + 2; i++) fac[i] = fac[i - 1] * i % mod;
  for (int i = 1; i <= k + 2; i++) s1 = s1 * (n - i) % mod;
  for (int i = 1; i <= k + 2; i++) {
    long long t1 = s1 * pw(n - i, mod - 2) % mod;
    long long s2 = pw(get(i), mod - 2);
    if ((k + 2 - i) % 2) s2 = -s2;
    sum = (sum + t1 * s2 % mod * f[i]) % mod;
  }
  printf("%d\n", upt(sum));
  return 0;
}