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;
int f[1000005], pre[1000005], suf[1000005];
inline int dec(const int& a, const int& b) {
  return a < b ? a - b + MOD : a - b;
}
inline int qpow(int a, int p) {
  int ans = 1;
  while (p) {
    if (p & 1) ans = (long long)ans * a % MOD;
    a = (long long)a * a % MOD;
    p >>= 1;
  }
  return ans;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  f[0] = 1;
  for (int i = 1; i <= k + 1; i++) f[i] = (long long)f[i - 1] * i % MOD;
  f[k + 1] = qpow(f[k + 1], MOD - 2);
  for (int i = k; i >= 0; i--) f[i] = (long long)f[i + 1] * (i + 1) % MOD;
  pre[0] = 1;
  for (int i = 1; i <= k + 2; i++)
    pre[i] = (long long)pre[i - 1] * dec(n, i) % MOD;
  suf[k + 3] = 1;
  for (int i = k + 2; i >= 0; i--)
    suf[i] = (long long)suf[i + 1] * dec(n, i) % MOD;
  int ans = 0, sum = 0;
  for (int i = 1; i <= k + 2; i++) {
    sum += qpow(i, k);
    if (sum >= MOD) sum -= MOD;
    int mul = sum;
    mul = (long long)mul * pre[i - 1] % MOD * suf[i + 1] % MOD;
    mul = (long long)mul * f[i - 1] % MOD *
          (((k - i) & 1) ? MOD - f[k - i + 2] : f[k - i + 2]) % MOD;
    ans += mul;
    if (ans >= MOD) ans -= MOD;
  }
  printf("%d\n", ans);
  return 0;
}