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 INF = 1000000000000000000LL;
long long qpowmod(long long a, long long b, long long mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
const int MAXN = 1000003;
const int MOD = 1000000007;
long long rev[MAXN];
long long Y[MAXN];
long long X[MAXN];
long long numProdPref[MAXN];
long long numProdSuff[MAXN];
long long revProd[MAXN];
long long getRev(long long x) {
  assert(llabs(x) < MAXN);
  if (x < 0)
    return (MOD - rev[-x]);
  else
    return rev[x];
}
int main() {
  int k, n;
  scanf("%d%d", &n, &k);
  rev[1] = 1;
  for (int i = 2; i < MAXN; i++)
    rev[i] = (MOD - (MOD / i) * rev[MOD % i] % MOD);
  revProd[0] = 1;
  for (int i = 1; i < MAXN; i++) revProd[i] = revProd[i - 1] * rev[i] % MOD;
  for (int i = 1; i <= k + 1; i++) Y[i] = (Y[i - 1] + qpowmod(i, k, MOD)) % MOD;
  for (int j = 0; j <= k + 1; j++) X[j] = n - j;
  numProdPref[0] = 1;
  numProdSuff[k + 2] = 1;
  for (int i = 0; i <= k + 1; i++)
    numProdPref[i + 1] = numProdPref[i] * X[i] % MOD;
  for (int i = k + 1; i >= 0; i--)
    numProdSuff[i] = numProdSuff[i + 1] * X[i] % MOD;
  long long res = 0;
  for (int i = 1; i <= k + 1; i++) {
    long long inc = Y[i] * numProdPref[i] % MOD * numProdSuff[i + 1] % MOD *
                    revProd[i] % MOD * revProd[k + 1 - i] % MOD;
    if ((k + 1 - i) % 2 == 1) inc = (MOD - inc) % MOD;
    res = (res + inc) % MOD;
  }
  printf("%lld\n", res);
  return 0;
}