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 = 1000005, P = 1000000007;
int n, m, ans, yi[N], fac[N], ifac[N];
void Inc(int &x, int y) {
  x += y;
  if (x >= P) x -= P;
}
int Add(int x, int y) { return x + y < P ? x + y : x + y - P; }
int qsm(int x, int y) {
  int w = x, s = 1;
  while (y) {
    if (y & 1) s = (long long)s * w % P;
    w = (long long)w * w % P;
    y >>= 1;
  }
  return s;
}
int main() {
  scanf("%d%d", &n, &m);
  if (!m) return printf("%d\n", n), 0;
  for (int i = (1); i <= (m + 2); i++) yi[i] = Add(yi[i - 1], qsm(i, m));
  if (n <= m + 2) return printf("%d\n", yi[n]), 0;
  int fz = 1;
  for (int i = (1); i <= (m + 2); i++) fz = (long long)fz * (n - i) % P;
  fac[0] = 1;
  for (int i = (1); i <= (m + 2); i++) fac[i] = (long long)fac[i - 1] * i % P;
  ifac[0] = 1;
  for (int i = (1); i <= (m + 2); i++)
    ifac[i] = (long long)ifac[i - 1] * (P - i) % P;
  for (int i = (1); i <= (m + 2); i++) {
    int FZ = (long long)fz * qsm(n - i, P - 2) % P;
    int FM = (long long)fac[i - 1] * ifac[m + 2 - i] % P;
    Inc(ans, (long long)yi[i] * FZ % P * qsm(FM, P - 2) % P);
  }
  printf("%d\n", ans);
  return 0;
}