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 MOD = 1e9 + 7;
long long power(long long x, long long k) {
  long long res = 1;
  while (k > 0) {
    if (k & 1) res = res * x % MOD;
    x = x * x % MOD;
    k >>= 1;
  }
  return res;
}
long long inverse(long long x) { return power(x, MOD - 2); }
const long long MN = 1000111;
long long y[MN], gt[MN], inv_gt[MN], f[MN], l[MN], r[MN];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  gt[0] = 1;
  for (long long i = (1), _b = (MN - 1); i <= _b; ++i)
    gt[i] = gt[i - 1] * i % MOD;
  for (long long i = (0), _b = (MN); i <= _b; ++i) inv_gt[i] = inverse(gt[i]);
  long long x, k;
  while (cin >> x >> k) {
    long long n = k + 2;
    for (long long i = (1), _b = (n); i <= _b; ++i) y[i] = power(i, k);
    for (long long i = (1), _b = (n); i <= _b; ++i)
      y[i] = (y[i - 1] + y[i]) % MOD;
    long long res = 0;
    for (long long i = (1), _b = (n); i <= _b; ++i) {
      f[i] = (x - i + MOD) % MOD;
    }
    l[0] = 1;
    for (long long i = (1), _b = (n); i <= _b; ++i)
      l[i] = l[i - 1] * f[i] % MOD;
    r[n + 1] = 1;
    for (long long i = (n), _b = (1); i >= _b; --i)
      r[i] = r[i + 1] * f[i] % MOD;
    for (long long i = (1), _b = (n); i <= _b; ++i) {
      long long cur = 1;
      cur = cur * l[i - 1] % MOD;
      cur = cur * inv_gt[i - 1] % MOD;
      cur = cur * r[i + 1] % MOD;
      cur = cur * inv_gt[n - i] % MOD;
      if ((n - i) % 2) cur = cur * (MOD - 1) % MOD;
      res = (res + cur * y[i]) % MOD;
    }
    cout << res << endl;
  }
}