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 int MOD = 1e9 + 7;
long long mul(long long a, long long b) { return a * b % MOD; }
long long add(long long a, long long b) { return (a + b) % MOD; }
long long pow(long long a, long long x) {
  long long res = 1, tmp = a;
  while (x) {
    if (x & 1) res = mul(res, tmp);
    tmp = mul(tmp, tmp);
    x >>= 1;
  }
  return res;
}
long long inv(long long a) { return pow(a, (long long)MOD - 2); }
long long f[N];
long long frac[N];
long long inv_frac[N];
void init(long long n, long long k) {
  f[0] = 0;
  frac[0] = 1;
  inv_frac[0] = 1;
  for (int i = 1; i < N; i++) {
    f[i] = add(f[i - 1], pow((long long)i, k));
    frac[i] = mul((long long)i, frac[i - 1]);
    inv_frac[i] = inv(frac[i]);
  }
}
void solve(long long n, long long k) {
  if (k == 0) {
    cout << n << endl;
    return;
  }
  if (n < N) {
    cout << f[n] << endl;
  } else {
    long long res = 0;
    long long x = 1;
    for (int i = 0; i <= k + 1; i++) {
      x = mul(n - i, x);
    }
    for (int i = 0; i <= k + 1; i++) {
      long long tmp = mul(x, inv(n - i));
      tmp = mul(tmp, f[i]);
      tmp = mul(tmp, inv_frac[k + 1 - i]);
      tmp = mul(tmp, inv_frac[i]);
      if ((k + 1 - i) % 2 == 1) tmp = (MOD - tmp) % MOD;
      res = add(res, tmp);
    }
    cout << res << endl;
  }
}
int main() {
  long long n, k;
  cin >> n >> k;
  init(n, k);
  solve(n, k);
}