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 MAXN = 1000005;
const long long MOD = 1000000007;
long long n, k;
long long pre[MAXN], suf[MAXN], fac[MAXN], ifac[MAXN];
inline long long quick_pow(long long x, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) (res *= x) %= MOD;
    (x *= x) %= MOD;
    k >>= 1;
  }
  return res;
}
inline void init() {
  pre[0] = suf[k + 3] = fac[0] = 1;
  for (int i = 1; i <= k + 2; i++) pre[i] = pre[i - 1] * (n - i) % MOD;
  for (int i = k + 2; i >= 1; i--) suf[i] = suf[i + 1] * (n - i) % MOD;
  for (int i = 1; i <= k + 2; i++) fac[i] = fac[i - 1] * i % MOD;
  ifac[k + 2] = quick_pow(fac[k + 2], MOD - 2);
  for (int i = k + 2 - 1; i >= 0; i--) ifac[i] = ifac[i + 1] * (i + 1) % MOD;
}
inline long long calc(int i, long long tmp) {
  return ((k - i) & 1 ? -1 : 1) * pre[i - 1] * suf[i + 1] % MOD * ifac[i - 1] %
         MOD * ifac[k + 2 - i] % MOD * tmp % MOD;
}
int main() {
  cin >> n >> k;
  init();
  long long ans = 0, tmp = 0;
  for (int i = 1; i <= k + 2; i++) {
    (tmp += quick_pow(i, k)) %= MOD;
    (ans += calc(i, tmp) % MOD) %= MOD;
  }
  cout << (ans + MOD) % MOD;
  return 0;
}