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>
const int mod = 1e9 + 7;
inline int pw(int base, int p) {
  static int res;
  for (res = 1; p; p >>= 1, base = static_cast<long long>(base) * base % mod)
    if (p & 1) res = static_cast<long long>(res) * base % mod;
  return res;
}
inline int inv(int x) { return pw(x, mod - 2); }
inline void reduce(int &x) { x += x >> 31 & mod; }
int n, k, ans;
int fac[1000010], s[1000010], prod = 1;
int main() {
  scanf("%d%d", &n, &k);
  if (k == 0) {
    std::printf("%d\n", n);
    return 0;
  }
  for (int i = 0; i <= k + 1; i++) {
    prod = static_cast<long long>(n - i) * prod % mod;
    s[i] = pw(i, k);
  }
  fac[0] = 1;
  for (int i = 1; i <= k + 1; i++) {
    fac[i] = static_cast<long long>(fac[i - 1]) * i % mod;
    reduce(s[i] += s[i - 1] - mod);
    if (n == i) {
      std::printf("%d\n", s[i]);
      return 0;
    }
  }
  for (int i = 1; i <= k + 1; i++) {
    reduce(ans += s[i] * static_cast<long long>(prod) % mod * inv(n - i) % mod *
                      inv(fac[i]) % mod * inv(fac[k - i + 1]) *
                      (k - i + 1 & 1 ? -1 : 1) % mod -
                  mod);
    reduce(ans);
  }
  printf("%d\n", ans);
  return 0;
}