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;
struct __s {
  __s() {
    if (1) {
      ios_base::Init i;
      cin.sync_with_stdio(0);
      cin.tie(0);
    }
  }
  ~__s() {
    if (!1)
      fprintf(stderr, "Execution time: %.3lf s.\n",
              (double)clock() / CLOCKS_PER_SEC);
    long long n;
    cin >> n;
  }
} __S;
int mod = 1e9 + 7;
int p[1111111];
int binpow(int x, int n) {
  if (n == 0) return 1;
  if (n == 1) return x;
  if (n & 1) {
    int y = binpow(x, n - 1);
    return (y * 1LL * x) % mod;
  } else {
    int y = binpow(x, n >> 1);
    return (y * 1LL * y) % mod;
  }
}
int inverse(int x) { return binpow(x, mod - 2); }
int main(void) {
  int n, k;
  cin >> n >> k;
  int m = k + 2;
  for (int i = 1; i <= m; i++) {
    p[i] = p[i - 1] + binpow(i, k);
    p[i] %= mod;
  }
  if (n <= m) {
    cout << p[n] << '\n';
    return 0;
  }
  long long a = 1;
  long long b = 1;
  for (int j = 2; j <= m; j++) {
    a *= (n - j);
    a %= mod;
    b *= (1 - j + mod);
    b %= mod;
  }
  long long c = a * inverse(b);
  c %= mod;
  int l = (1 - m + mod);
  int r = 1;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    long long res = p[i];
    res *= c;
    res %= mod;
    ans += res;
    ans %= mod;
    c *= (n - i);
    c %= mod;
    c *= l;
    c %= mod;
    c *= inverse(((n - i - 1) * 1LL * r) % mod);
    c %= mod;
    r++;
    l++;
  }
  cout << ans << '\n';
  return 0;
}