Problem: Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recurrence relation: 

F1 = 1, F2 = 2, Fi = Fi - 1 + Fi - 2 (i > 2).

We'll define a new number sequence Ai(k) by the formula: 

Ai(k) = Fi × ik (i ≥ 1).

In this problem, your task is to calculate the following sum: A1(k) + A2(k) + ... + An(k). The answer can be very large, so print it modulo 1000000007 (109 + 7).

Input

The first line contains two space-separated integers n, k (1 ≤ n ≤ 1017; 1 ≤ k ≤ 40).

Output

Print a single integer — the sum of the first n elements of the sequence Ai(k) modulo 1000000007 (109 + 7).

Examples

Input

1 1


Output

1


Input

4 1


Output

34


Input

5 2


Output

316


Input

7 4


Output

73825

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long n;
int k;
const int mod = 1000000007;
long long c[41][41];
void makec() {
  for (int i = 0; i < 41; i++)
    for (int j = 0; j < 41; j++)
      if (j == 0)
        c[i][j] = 1;
      else
        c[i][j] = 0;
  for (int i = 1; i < 41; i++)
    for (int j = 1; j < 41; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
}
vector<vector<long long> > mul(vector<vector<long long> > a,
                               vector<vector<long long> > b) {
  vector<vector<long long> > c(a.size(), vector<long long>(b[0].size()));
  for (int i = 0; i < a.size(); i++)
    for (int k = 0; k < b.size(); k++)
      for (int j = 0; j < b[0].size(); j++)
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % mod;
  return c;
}
vector<vector<long long> > powmat(vector<vector<long long> > a, long long k) {
  vector<vector<long long> > c(a.size(), vector<long long>(a.size()));
  for (int i = 0; i < a.size(); i++) c[i][i] = 1;
  while (k > 0) {
    if (k & 1) c = mul(c, a);
    a = mul(a, a);
    k >>= 1;
  }
  return c;
}
int main() {
  makec();
  while (~scanf("%I64d%d", &n, &k)) {
    vector<vector<long long> > nx(2 * k + 3, vector<long long>(2 * k + 3));
    nx[0][0] = 1;
    for (int i = 1; i < k + 2; i++) nx[0][i] = c[k][i - 1];
    for (int i = k + 2; i < 2 * k + 3; i++) nx[0][i] = c[k][i - k - 2];
    for (int i = 1; i < k + 2; i++)
      for (int j = 1; j < i + 1; j++) nx[i][j] = c[i - 1][j - 1];
    for (int i = 1; i < k + 2; i++)
      for (int j = k + 2; j < i + k + 2; j++) nx[i][j] = c[i - 1][j - k - 2];
    for (int i = k + 2; i < 2 * k + 3; i++)
      for (int j = 1; j < i - k; j++) nx[i][j] = c[i - k - 2][j - 1];
    vector<vector<long long> > a(2 * k + 3, vector<long long>(1));
    for (int i = 0; i < a.size(); i++) a[i][0] = 1;
    nx = powmat(nx, n - 1);
    a = mul(nx, a);
    printf("%lld\n", a[0][0] % mod);
  }
}