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 mod = 1e9 + 7;
const int maxk = 1e6;
int inv[maxk + 2];
int facinv[maxk + 2];
int f[maxk + 2];
int pre[maxk + 2];
int suf[maxk + 2];
int pow_mod(int a, int k) {
  int s = 1;
  while (k) {
    if (k & 1) s = 1ll * s * a % mod;
    a = 1ll * a * a % mod;
    k >>= 1;
  }
  return s;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= k + 1; ++i) {
    f[i] = f[i - 1] + pow_mod(i, k);
    if (f[i] >= mod) f[i] -= mod;
  }
  inv[1] = facinv[0] = facinv[1] = 1;
  for (int i = 2; i <= k + 1; ++i) {
    inv[i] = 1ll * inv[mod % i] * (mod - mod / i) % mod;
    facinv[i] = 1ll * facinv[i - 1] * inv[i] % mod;
  }
  pre[0] = 1;
  for (int i = 1; i <= k + 1; ++i)
    pre[i] = 1ll * pre[i - 1] * (n - i + 1) % mod;
  suf[k + 1] = 1;
  for (int i = k; i >= 0; --i) suf[i] = 1ll * suf[i + 1] * (n - i - 1) % mod;
  int ans = 0;
  for (int i = 0; i <= k + 1; ++i) {
    if ((k + i) & 1)
      ans = ans + 1ll * pre[i] * suf[i] % mod * facinv[i] % mod *
                      facinv[k + 1 - i] % mod * f[i] % mod;
    else
      ans = ans + mod -
            1ll * pre[i] * suf[i] % mod * facinv[i] % mod * facinv[k + 1 - i] %
                mod * f[i] % mod;
    if (ans >= mod) ans -= mod;
  }
  printf("%d\n", ans);
  return 0;
}