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 = 1e9 + 7;
long long Pow(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * a % inf;
    a = a * a % inf;
    n >>= 1;
  }
  return ans;
}
long long interapolate(long long x, long long k, bool bf = false) {
  if (k == 0) return x;
  if (x <= k + 1 || bf) {
    long long s = 0;
    for (int i = 0; i <= x; i++) {
      s = s + Pow(i, k) % inf;
    }
    return s;
  }
  vector<long long> pre(k + 2), suf(k + 2), inv(k + 2);
  inv[0] = 1;
  pre[0] = x;
  suf[k + 1] = x - (k + 1);
  for (int i = 1; i <= k; i++) pre[i] = pre[i - 1] * (x - i) % inf;
  for (int i = k; i >= 1; i--) suf[i] = suf[i + 1] * (x - i) % inf;
  for (int i = 1; i <= k + 1; i++) inv[i] = inv[i - 1] * Pow(i, inf - 2) % inf;
  long long yi = 0, ans = 0, num, denom;
  for (int i = 0; i <= k + 1; i++) {
    yi = (yi + Pow(i, k)) % inf;
    if (i == 0)
      num = suf[1];
    else if (i == k + 1)
      num = pre[k];
    else
      num = pre[i - 1] * suf[i + 1] % inf;
    denom = inv[i] * inv[k + 1 - i] % inf;
    ans += ((k + i) & 1 ? 1 : -1) * (yi * num % inf * denom % inf);
    ans = (ans % inf + inf) % inf;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long x, k;
  cin >> x >> k;
  cout << interapolate(x, k) % inf;
}