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;
struct Mat {
  long long mat[88][88];
  int row, col;
};
Mat mod_mul(Mat a, Mat b, long long p) {
  Mat ans;
  ans.row = a.row;
  ans.col = b.col;
  memset(ans.mat, 0, sizeof(ans.mat));
  for (int i = 0; i < ans.row; i++)
    for (int k = 0; k < a.col; k++)
      if (a.mat[i][k])
        for (int j = 0; j < ans.col; j++) {
          ans.mat[i][j] += a.mat[i][k] * b.mat[k][j];
          ans.mat[i][j] %= p;
        }
  return ans;
}
Mat mod_pow(Mat a, long long k, long long p) {
  Mat ans;
  ans.row = a.row;
  ans.col = a.col;
  for (int i = 0; i < a.row; i++)
    for (int j = 0; j < a.col; j++) ans.mat[i][j] = (i == j);
  while (k) {
    if (k & 1) ans = mod_mul(ans, a, p);
    a = mod_mul(a, a, p);
    k >>= 1;
  }
  return ans;
}
int k;
long long n, C[88][88];
void init() {
  memset(C, 0, sizeof(C));
  C[0][0] = 1;
  for (int i = 1; i <= 40; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;
  }
}
Mat A, B;
int main() {
  init();
  while (~scanf("%I64d%d", &n, &k)) {
    if (n == 1)
      printf("1\n");
    else {
      A.row = A.col = 2 * k + 3;
      memset(A.mat, 0, sizeof(A.mat));
      A.mat[0][0] = A.mat[0][k + 1] = 1;
      for (int i = 0; i <= k; i++)
        for (int j = 0; j <= i; j++) {
          A.mat[i + 1][j + 1] = C[i][j];
          A.mat[i + 1][j + k + 2] =
              (1ll << (i - j)) % 1000000007 * C[i][j] % 1000000007;
        }
      for (int i = k + 2; i <= 2 * k + 2; i++) A.mat[i][i - (k + 1)] = 1;
      B.row = 2 * k + 3, B.col = 1;
      B.mat[0][0] = 1;
      for (int i = 1; i <= k + 1; i++) B.mat[i][0] = (1ll << i) % 1000000007;
      for (int i = k + 2; i <= 2 * k + 2; i++) B.mat[i][0] = 1;
      A = mod_pow(A, n - 2, 1000000007);
      A = mod_mul(A, B, 1000000007);
      printf("%I64d\n", (A.mat[0][0] + A.mat[k + 1][0]) % 1000000007);
    }
  }
  return 0;
}