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;
long long qpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * a % ((long long)1e9 + 7);
    a = a * a % ((long long)1e9 + 7);
    n >>= 1;
  }
  return res;
}
long long n, m, k;
long long y[1000005], fac[1000005], inv[1000005];
void init() {
  fac[0] = 1;
  for (int i = 1; i < 1000005; i++)
    fac[i] = fac[i - 1] * i % ((long long)1e9 + 7);
  inv[1000005 - 1] = qpow(fac[1000005 - 1], ((long long)1e9 + 7) - 2);
  for (int i = 1000005 - 2; i >= 0; i--)
    inv[i] = inv[i + 1] * (i + 1) % ((long long)1e9 + 7);
}
int main() {
  init();
  cin >> k >> m;
  n = m + 2;
  long long g = 1;
  for (int i = 1; i <= n; i++) {
    y[i] = (y[i - 1] + qpow(i, m)) % ((long long)1e9 + 7);
    g = g * (k - i) % ((long long)1e9 + 7);
  }
  if (k <= n) {
    cout << y[k] << endl;
    return 0;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long t = inv[i - 1] * inv[n - i] % ((long long)1e9 + 7);
    if ((n - i) & 1) t = -t;
    ans = (ans + y[i] * t % ((long long)1e9 + 7) *
                     qpow(k - i, ((long long)1e9 + 7) - 2) %
                     ((long long)1e9 + 7)) %
          ((long long)1e9 + 7);
  }
  ans = (ans * g % ((long long)1e9 + 7) + ((long long)1e9 + 7)) %
        ((long long)1e9 + 7);
  cout << ans << endl;
  return 0;
}