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;
inline int read() {
  int ret = 0, t = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') t = -1, c = getchar();
  while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
  return ret * t;
}
const int MAXN = 1001000, mod = 1e9 + 7;
int qpow(int x, int y) {
  if (y < 0) return qpow(qpow(x, -y), mod - 2);
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % mod;
    x = 1ll * x * x % mod;
    y >>= 1;
  }
  return ret;
}
int k, n;
int FAC[MAXN], pre[MAXN], suf[MAXN];
int fac(int x) { return (x < 0 && (x & 1)) ? -FAC[-x] : FAC[abs(x)]; }
int main() {
  k = read(), n = read();
  int i, j;
  FAC[0] = pre[0] = 1, suf[n + 3] = 1;
  for (i = 1; i <= n + 2; i++)
    FAC[i] = 1ll * FAC[i - 1] * i % mod,
    pre[i] = 1ll * pre[i - 1] * (k - i) % mod;
  for (i = n + 2; i >= 0; i--) suf[i] = 1ll * suf[i + 1] * (k - i) % mod;
  int Y = 0, ans = 0;
  for (i = 1; i <= n + 2; i++) {
    Y = (Y + qpow(i, n)) % mod;
    int tmp = 1ll * Y * pre[i - 1] % mod * suf[i + 1] % mod *
              qpow(fac(i - 1), -1) % mod * qpow(fac(i - n - 2), -1) % mod;
    ans = (ans + tmp) % mod;
  }
  printf("%d\n", (ans + mod) % mod);
  return 0;
}