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;
int read() {
  char ch = getchar();
  int w = 1, c = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') w = -1;
  for (; isdigit(ch); ch = getchar()) c = (c << 3) + (c << 1) + (ch ^ 48);
  return w * c;
}
const int mod = 1e9 + 7, M = 1e6 + 10;
long long fast(long long x, long long p) {
  long long ret = 1;
  for (; p; p >>= 1, x = x * x % mod)
    if (p & 1) ret = ret * x % mod;
  return ret;
}
int n, k;
long long f[M], pr[M], sf[M], Y[M], inv[M];
int main() {
  n = read();
  k = read();
  f[0] = 1;
  for (int i = 1; i <= k + 1; ++i)
    Y[i] = (Y[i - 1] + fast(i, k)) % mod, f[i] = f[i - 1] * i % mod;
  inv[k + 1] = fast(f[k + 1], mod - 2);
  for (int i = k + 1; i >= 1; --i) inv[i - 1] = inv[i] * i % mod;
  sf[k + 3] = pr[0] = 1;
  for (int i = 1; i <= k + 2; ++i) pr[i] = pr[i - 1] * (n - i + 1) % mod;
  for (int i = k + 2; i >= 1; --i) sf[i] = sf[i + 1] * (n - i + 1) % mod;
  long long ans = 0;
  for (int i = 0; i <= k + 1; ++i) {
    if (n <= k + 1) {
      if (i == n) ans = (ans + Y[i]) % mod;
    } else {
      long long o = Y[i] * pr[i] % mod * sf[i + 2] % mod * inv[i] % mod *
                    inv[k + 1 - i] % mod;
      if ((k + 1 - i) & 1)
        ans = (ans + mod - o) % mod;
      else
        ans = (ans + o) % mod;
    }
  }
  cout << ans << "\n";
  return 0;
}