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;
const long long Mod = 1e9 + 7;
const int N = 100;
int msize;
struct Mat {
  long long mat[N][N];
};
Mat operator*(Mat a, Mat b) {
  Mat c;
  memset(c.mat, 0, sizeof(c.mat));
  for (int k = 0; k < msize; ++k)
    for (int i = 0; i < msize; ++i)
      if (a.mat[i][k])
        for (int j = 0; j < msize; ++j)
          if (b.mat[k][j])
            c.mat[i][j] = (c.mat[i][j] + a.mat[i][k] * b.mat[k][j]) % Mod;
  return c;
}
Mat operator^(Mat a, long long k) {
  Mat c;
  memset(c.mat, 0, sizeof(c.mat));
  for (int i = 0; i < msize; ++i) c.mat[i][i] = 1;
  for (; k; k >>= 1) {
    if (k & 1) c = c * a;
    a = a * a;
  }
  return c;
}
long long C[N][N];
long long pow2[N];
void calcu() {
  C[0][0] = 1;
  for (int i = 1; i <= 50; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
  }
  pow2[0] = 1;
  for (int i = 1; i <= 50; i++) pow2[i] = pow2[i - 1] * 2 % Mod;
}
int main() {
  calcu();
  long long n;
  int k;
  while (~scanf("%I64d%d", &n, &k)) {
    msize = 2 * k + 3;
    Mat A;
    memset(A.mat, 0, sizeof(A.mat));
    A.mat[0][0] = A.mat[0][1] = 1;
    for (int i = 1; i <= k + 1; i++) {
      for (int j = i, t = 0; j <= k + 1; j++, t++)
        A.mat[i][j] = C[k - i + 1][t];
      for (int j = i + k + 1, t = 0; j < msize; j++, t++)
        A.mat[i][j] = C[k - i + 1][t] * pow2[t] % Mod;
    }
    for (int i = k + 2; i < msize; i++) A.mat[i][i - k - 1] = 1;
    A = A ^ (n - 1);
    long long ans = A.mat[0][0];
    for (int i = 1; i <= k + 1; i++)
      ans = (ans + A.mat[0][i] * pow2[k + 2 - i]) % Mod;
    for (int i = k + 2; i < msize; i++) ans = (ans + A.mat[0][i]) % Mod;
    printf("%I64d\n", ans);
  }
  return 0;
}