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 maxn = 1e6 + 100;
const int mod = 1e9 + 7;
long long prim[maxn];
bool vis[maxn];
int cnt = 0;
long long f[maxn];
long long mul[maxn];
long long inv[maxn];
long long qp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a % mod;
    }
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
int main() {
  long long n, k;
  cin >> n >> k;
  f[1] = 1;
  for (int i = 2; i <= k + 50; i++) {
    if (!vis[i]) {
      prim[++cnt] = i;
      f[i] = qp(i, k);
    }
    for (int j = 1; j <= cnt && i * prim[j] <= k + 50; j++) {
      vis[i * prim[j]] = 1;
      f[i * prim[j]] = f[i] * f[prim[j]] % mod;
      if (i % prim[j] == 0) {
        break;
      }
    }
  }
  f[0] = 0;
  for (int i = 1; i <= k + 50; i++) {
    f[i] = (f[i - 1] + f[i]) % mod;
  }
  if (n <= k + 2) {
    cout << f[n] << endl;
    return 0;
  }
  inv[1] = 1;
  for (int i = 2; i <= k + 2; i++) {
    inv[i] = ((-(mod / i) * inv[mod % i]) % mod + mod) % mod;
  }
  long long ans = 0;
  long long p = 1;
  mul[0] = 1;
  for (int i = 0; i < k + 2; i++) {
    p *= (n - i);
    p %= mod;
    p += mod;
    p %= mod;
    if (i) mul[i] = mul[i - 1] * inv[i] % mod;
  }
  for (int i = 0; i < k + 2; i++) {
    long long tem = p;
    tem *= qp(((n - i) % mod + mod) % mod, mod - 2);
    tem %= mod;
    tem *= mul[i - 0];
    tem %= mod;
    tem *= mul[k + 1 - i];
    tem %= mod;
    tem *= f[i];
    tem %= mod;
    if ((k + 1 - i) % 2 == 1) {
      tem *= -1;
      tem += mod;
      tem %= mod;
    }
    ans += tem;
    ans %= mod;
  }
  cout << ans << endl;
}