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;
long long int ans[1000005], prod[1000005];
long long int bpow(long long int x, long long int n) {
  long long int ans = 1;
  while (n > 0) {
    if (n & 1) ans *= x;
    x *= x;
    ans %= 1000000007;
    x %= 1000000007;
    n /= 2;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  long long int i, j, n, k, now, store, res = 0, num;
  cin >> n >> k;
  num = 1;
  for (i = 1; i <= k + 2; i++) {
    num = (1LL * num * (n - i)) % 1000000007;
    ans[i] = ans[i - 1] + bpow(i, k);
    if (ans[i] >= 1000000007) ans[i] -= 1000000007;
  }
  if (n <= k + 2) {
    cout << ans[n];
    return 0;
  }
  prod[0] = 1;
  prod[1] = 1;
  for (i = 2; i < 1000005; i++) prod[i] = (1LL * i * prod[i - 1]) % 1000000007;
  store = k + 2;
  for (i = 1; i <= k + 2; i++) {
    store--;
    now = (1LL * num * bpow(n - i, 1000000007 - 2)) % 1000000007;
    now = (1LL * now * bpow(prod[store], 1000000007 - 2)) % 1000000007;
    now = (1LL * now * bpow(prod[i - 1], 1000000007 - 2)) % 1000000007;
    if (store % 2) now = (-now + 1000000007) % 1000000007;
    res = res + (1LL * ans[i] * now) % 1000000007;
    if (res >= 1000000007) res -= 1000000007;
  }
  cout << res;
  return 0;
}