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;
int f[1000020], g[1000020];
int Power(int x, int y) {
  int o;
  for (o = 1; y; y >>= 1) {
    if (y & 1) o = (long long)o * x % 1000000007;
    x = (long long)x * x % 1000000007;
  }
  return o;
}
int main(void) {
  int n, m;
  int i, o, s, p;
  for (i = f[0] = 1; i < 1000020; i++)
    f[i] = (long long)f[i - 1] * i % 1000000007;
  g[1000020 - 1] = Power(f[1000020 - 1], 1000000007 - 2);
  for (i = 1000020 - 2; i > -1; i--)
    g[i] = (long long)g[i + 1] * (i + 1) % 1000000007;
  for (i = 0; i < 1000020; i++)
    f[i] = i & 1 ? (1000000007 - g[i]) % 1000000007 : g[i];
  cin >> n >> m;
  if (n <= m + 1)
    for (i = 1, o = 0; i <= n; i++) o = (o + Power(i, m)) % 1000000007;
  else {
    for (i = 0, s = 1; i <= m + 1; i++) s = (long long)s * (n - i) % 1000000007;
    for (i = 1, o = p = 0; i <= m + 1; i++)
      o = (o + (long long)(p = (p + Power(i, m)) % 1000000007) * g[i] %
                   1000000007 * f[m + 1 - i] % 1000000007 * s % 1000000007 *
                   Power(n - i, 1000000007 - 2) % 1000000007) %
          1000000007;
  }
  cout << o << endl;
  return 0;
}