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 n, K, ans;
long long cur;
int cnt1[1000004], cnt2[1000004];
int inv[1000004];
long long mypow(long long x, long long t) {
  long long ans = 1, ret = x;
  while (t) {
    if (t & 1) ans = ans * ret % MOD;
    ret = ret * ret % MOD, t >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &K);
  cnt1[0] = 1, cnt2[K + 3] = 1, inv[1] = 1;
  for (int i = 1; i <= K + 2; i++) cnt1[i] = 1ll * cnt1[i - 1] * (n - i) % MOD;
  for (int i = K + 2; i; i--) cnt2[i] = 1ll * cnt2[i + 1] * (n - i) % MOD;
  for (int i = 2; i <= K + 2; i++)
    inv[i] = 1ll * (MOD - MOD / i) * inv[MOD % i] % MOD;
  inv[0] = 1;
  for (int i = 2; i <= K + 2; i++) inv[i] = 1ll * inv[i - 1] * inv[i] % MOD;
  for (int i = 1; i <= K + 2; i++) {
    cur = (cur + mypow(i, K)) % MOD;
    long long tmp1 = 1ll * cnt1[i - 1] * cnt2[i + 1] % MOD;
    long long tmp2 = 1ll * inv[i - 1] * inv[K + 2 - i] % MOD;
    long long tmp = cur * tmp1 % MOD * tmp2 % MOD;
    if ((K + 2 - i) % 2 == 1) tmp = MOD - tmp;
    ans = (ans + tmp) % MOD;
  }
  printf("%d", ans);
}