#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool in(T &x) {
  return bool(cin >> x);
}
template <typename T, typename... Args>
bool in(T &x, Args &...args) {
  return bool(cin >> x) & in(args...);
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
template <typename... Args>
long long gcd(long long x, Args... args) {
  return gcd(x, gcd(args...));
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
template <typename... Args>
long long lcm(long long x, Args... args) {
  return lcm(x, lcm(args...));
}
const int N = 1e6 + 10, M = 1e3 + 10, mod = 1e9 + 7;
const double eps = 1e-6, Pi = acos(-1.0);
long long fac[N], y[N], pre[N], suf[N];
long long quick_pow(long long a, long long x) {
  long long ans = 1;
  a %= mod;
  while (x) {
    if (x & 1) ans = (ans * a) % mod;
    x >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
long long inv(long long x) { return quick_pow(x, mod - 2); }
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  in(n, k);
  fac[0] = 1;
  for (int i = 1; i <= k + 5; i++) fac[i] = fac[i - 1] * i % mod;
  k += 2;
  pre[0] = n;
  suf[k + 1] = 1;
  for (int i = 1; i <= k; i++) {
    y[i] = (y[i - 1] + quick_pow(i, k - 2)) % mod;
    pre[i] = pre[i - 1] * (n - i) % mod;
  }
  for (int i = k; i >= 0; i--) {
    suf[i] = suf[i + 1] * (n - i) % mod;
  }
  for (int i = 0; i <= k + 1; i++) {
  }
  long long ans = 0;
  for (int i = 1; i <= k; i++) {
    long long op = 1;
    if ((k - i) & 1) op = -1;
    ans += op * y[i] * inv(fac[i] * fac[k - i]) % mod * pre[i - 1] % mod *
           suf[i + 1] % mod;
    ans = (ans % mod + mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}

### Prompt

Please create a solution in CPP to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool in(T &x) {
  return bool(cin >> x);
}
template <typename T, typename... Args>
bool in(T &x, Args &...args) {
  return bool(cin >> x) & in(args...);
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
template <typename... Args>
long long gcd(long long x, Args... args) {
  return gcd(x, gcd(args...));
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
template <typename... Args>
long long lcm(long long x, Args... args) {
  return lcm(x, lcm(args...));
}
const int N = 1e6 + 10, M = 1e3 + 10, mod = 1e9 + 7;
const double eps = 1e-6, Pi = acos(-1.0);
long long fac[N], y[N], pre[N], suf[N];
long long quick_pow(long long a, long long x) {
  long long ans = 1;
  a %= mod;
  while (x) {
    if (x & 1) ans = (ans * a) % mod;
    x >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
long long inv(long long x) { return quick_pow(x, mod - 2); }
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  in(n, k);
  fac[0] = 1;
  for (int i = 1; i <= k + 5; i++) fac[i] = fac[i - 1] * i % mod;
  k += 2;
  pre[0] = n;
  suf[k + 1] = 1;
  for (int i = 1; i <= k; i++) {
    y[i] = (y[i - 1] + quick_pow(i, k - 2)) % mod;
    pre[i] = pre[i - 1] * (n - i) % mod;
  }
  for (int i = k; i >= 0; i--) {
    suf[i] = suf[i + 1] * (n - i) % mod;
  }
  for (int i = 0; i <= k + 1; i++) {
  }
  long long ans = 0;
  for (int i = 1; i <= k; i++) {
    long long op = 1;
    if ((k - i) & 1) op = -1;
    ans += op * y[i] * inv(fac[i] * fac[k - i]) % mod * pre[i - 1] % mod *
           suf[i + 1] % mod;
    ans = (ans % mod + mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}

```