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, MAXK = 1e6 + 10;
int n, k, pre[MAXK], suc[MAXK], fac[MAXK], qwq[MAXK];
int ksm(int _, int __) {
  int ans = 1;
  while (__) {
    if (__ & 1) ans = 1LL * ans * _ % MOD;
    _ = 1LL * _ * _ % MOD;
    __ >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  pre[0] = n, suc[k + 2] = 1, fac[1] = 1;
  for (int i = 1; i <= k + 1; i++) pre[i] = 1LL * pre[i - 1] * (n - i) % MOD;
  for (int i = k + 1; i >= 0; i--) suc[i] = 1LL * suc[i + 1] * (n - i) % MOD;
  for (int i = 2; i <= k + 1; i++)
    fac[i] = 1LL * (MOD - MOD / i) * fac[MOD % i] % MOD;
  for (int i = 2; i <= k + 1; i++) fac[i] = 1LL * fac[i] * fac[i - 1] % MOD;
  int now = 0, ans = 0;
  fac[0] = 1;
  for (int i = 0; i <= k + 1; i++) {
    now = (now + (i ? ksm(i, k) : 0)) % MOD;
    ans =
        (ans + 1LL * ksm(-1, k + 1 - i) * now * (i > 0 ? pre[i - 1] : 1) % MOD *
                   (i <= k ? suc[i + 1] : 1) % MOD * (i > 0 ? fac[i] : 1) %
                   MOD * (k + 1 - i > 0 ? fac[k + 1 - i] : 1) % MOD) %
        MOD;
  }
  printf("%d\n", (ans + MOD) % MOD);
  return 0;
}