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 long long maxn = 1e6 + 5, mod = 1e9 + 7;
int n, k;
long long fac[maxn], pre[maxn], suf[maxn], y[maxn], inv[maxn];
long long pow_mod(long long a, long long b) {
  a %= mod, b %= mod - 1;
  if (!a) return 0;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return ans;
}
inline long long f(long long x) {
  long long ans = 0;
  pre[0] = suf[k + 2 + 1] = 1;
  for (int i = 1; i <= k + 2; i++) pre[i] = pre[i - 1] * (x - i) % mod;
  for (int i = k + 2; i >= 1; i--) suf[i] = suf[i + 1] * (x - i) % mod;
  for (int i = 1; i <= k + 2; i++) {
    int flag = 1;
    if ((k + 2 - i) & 1) flag = -1;
    ans = (ans + y[i] * pre[i - 1] % mod * suf[i + 1] % mod * inv[i - 1] % mod *
                     inv[k + 2 - i] % mod * flag) %
          mod;
  }
  return (ans + mod) % mod;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= k + 2; i++) y[i] = (y[i - 1] + pow_mod(i, k)) % mod;
  fac[0] = 1, inv[0] = 1;
  for (int i = 1; i <= k + 2; i++)
    fac[i] = fac[i - 1] * i % mod, inv[i] = pow_mod(fac[i], mod - 2);
  cout << f(n);
  return 0;
}