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 + 5, mod = 1e9 + 7;
int n, k, pre[N], suf[N], fact[N];
inline int quick_pow(int x, int p = mod - 2, int mul = 1) {
  for (; p; p >>= 1, x = 1LL * x * x % mod)
    if (p & 1) mul = 1LL * mul * x % mod;
  return mul;
}
inline int Lagrange(const int& n, const int& k) {
  register int i;
  for (pre[0] = i = 1; i <= n; ++i) pre[i] = 1LL * pre[i - 1] * (k - i) % mod;
  for (suf[n + 1] = 1, i = n; i; --i) suf[i] = 1LL * suf[i + 1] * (k - i) % mod;
  for (fact[0] = i = 1; i <= n; ++i) fact[i] = 1LL * fact[i - 1] * i % mod;
  int ret = 0, y = 0;
  for (i = 1; i <= n; ++i) {
    (y += quick_pow(i, n - 2)) %= mod;
    int val = 1LL * pre[i - 1] * suf[i + 1] % mod *
              quick_pow(1LL * fact[i - 1] * fact[n - i] % mod) % mod;
    if ((n - i) & 1)
      (ret -= 1LL * y * val % mod) %= mod;
    else
      (ret += 1LL * y * val % mod) %= mod;
  }
  return (ret + mod) % mod;
}
int main() {
  return scanf("%d%d", &n, &k), printf("%d", Lagrange(k + 2, n)), 0;
}