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>
namespace chiaro {
const long long ha = 1e9 + 7;
long long n, k;
long long f[1000010];
long long pre[1000010], suf[1000010];
long long inv[1000010];
inline long long ksm(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % ha;
    a = a * a % ha;
    b >>= 1;
  }
  return ans;
}
inline long long sign(long long x) { return ((x & 1) ? -1 : 1); }
inline void setting() { return; }
inline long long main() {
  setting();
  std::cin >> n >> k;
  if (k == 0) printf("%lld\n", n), exit(0);
  f[1] = 1;
  for (long long i = 2; i <= k + 2; i++) f[i] = (f[i - 1] + ksm(i, k)) % ha;
  long long mul = 1;
  inv[0] = 1;
  for (long long i = 1; i <= k + 2; i++) mul = 1ll * mul * i % ha;
  inv[k + 2] = ksm(mul, ha - 2);
  for (long long i = k + 1; i; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % ha;
  pre[0] = 1;
  for (long long i = 1; i <= k + 2; i++)
    pre[i] = 1ll * pre[i - 1] * (n - i) % ha;
  suf[k + 3] = 1;
  for (long long i = k + 2; i; i--) suf[i] = 1ll * suf[i + 1] * (n - i) % ha;
  long long res = 0;
  for (long long i = 1; i <= k + 2; i++) {
    long long tmp = 0;
    tmp = 1ll * f[i] * inv[i - 1] % ha * inv[k + 2 - i] % ha * pre[i - 1] % ha *
          suf[i + 1] % ha;
    res = (res + tmp * sign(k + 2 - i)) % ha;
  }
  printf("%lld\n", (res + ha) % ha);
  return 0;
}
}  // namespace chiaro
signed main() { return chiaro::main(); }