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 int N = 1e6 + 10;
const long long mod = 1e9 + 7;
long long p[N], jc[N];
long long upjc;
long long extgcd(long long a, long long b, long long& x, long long& y) {
  long long d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
long long mod_inverse(long long a) {
  long long x, y, m;
  m = mod;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}
long long mod_pow(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
void _init(long long n, long long k) {
  jc[0] = jc[1] = 1;
  for (long long i = 2; i <= k + 5; i++) jc[i] = jc[i - 1] * i % mod;
  upjc = n - 1;
  for (long long i = 2; i <= k + 2; i++) {
    upjc *= n - i;
    upjc %= mod;
  }
}
int main() {
  long long n, k, ans, _up, _down;
  int flag;
  cin >> n >> k;
  ans = 0;
  if (max(n, k) <= 2000000) {
    for (long long i = 1; i <= n; i++) {
      ans += mod_pow(i, k);
      ans %= mod;
    }
    cout << ans << '\n';
    return 0;
  }
  p[0] = 0;
  for (long long i = 1; i <= k + 5; i++) {
    p[i] = p[i - 1] + mod_pow(i, k);
    p[i] %= mod;
  }
  _init(n, k);
  for (long long i = 1; i <= k + 2; i++) {
    if ((k - 2 - i) & 1)
      flag = -1;
    else
      flag = 1;
    _up = upjc * mod_inverse(n - i) % mod * p[i] % mod;
    _down = jc[i - 1] * jc[k + 2 - i] % mod;
    ans += (_up * mod_inverse(_down) % mod * flag + mod) % mod;
    ans %= mod;
  }
  cout << ans << '\n';
  return 0;
}