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 mod = 1e9 + 7;
long long f[1000010], fac[1000010];
long long Pow(long long x, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ans;
}
long long n_k(int n, int k) {
  f[0] = 0;
  for (int i = 1; i <= k + 2; ++i) f[i] = (f[i - 1] + Pow(i, k)) % mod;
  if (n <= k + 2) return f[n];
  fac[0] = 1;
  for (int i = 1; i <= k + 2; ++i) fac[i] = fac[i - 1] * i % mod;
  long long cur = 1, ans = 0;
  for (int i = 1; i <= k + 2; ++i) cur = cur * (n - i) % mod;
  for (int i = 1; i <= k + 2; ++i) {
    long long inv1 = Pow(n - i, mod - 2) % mod;
    long long inv2 =
        Pow(fac[i - 1] % mod * fac[k + 2 - i] % mod, mod - 2) % mod;
    int sign = (k + 2 - i) % 2 ? -1 : 1;
    ans = (ans + sign * inv1 * inv2 % mod * f[i] % mod * cur % mod) % mod;
  }
  ans = (ans + mod) % mod;
  return ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  cout << n_k(n, k) << endl;
  return 0;
}