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 = 1000000 + 10, MOD = 1000000007;
int power(int base, int exp) {
  int res = 1;
  for (; exp; exp >>= 1) {
    if (exp & 1) res = (long long)res * base % MOD;
    base = (long long)base * base % MOD;
  }
  return res;
}
int n, k, m, f[N];
int fact[N];
int main() {
  fact[0] = 1;
  for (int i = 1; i < N; ++i) fact[i] = (long long)fact[i - 1] * i % MOD;
  scanf("%d%d", &n, &k);
  m = k + 2;
  for (int i = 1; i <= m; ++i) f[i] = (f[i - 1] + power(i, k)) % MOD;
  static int pre[N], suf[N];
  pre[0] = suf[m + 1] = 1;
  for (int i = 1; i <= m; ++i)
    pre[i] = (long long)pre[i - 1] * (n - i + MOD) % MOD;
  for (int i = m; i > 0; --i)
    suf[i] = (long long)suf[i + 1] * (n - i + MOD) % MOD;
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    int numer = (long long)pre[i - 1] * suf[i + 1] % MOD;
    int denom = (long long)fact[i - 1] * fact[m - i] % MOD;
    if ((m - i) & 1) denom = MOD - denom;
    ans = (ans + (long long)numer * power(denom, MOD - 2) % MOD * f[i]) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}