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 int MAXK = 100;
const int MODU = 1e9 + 7;
struct Mat {
  long long a[MAXK][MAXK];
  int nrow, ncol;
  Mat(int nr = 0, int nc = 0) {
    nrow = nr;
    ncol = nc;
    memset(a, 0, sizeof(a));
  }
} E, T, O;
long long N, K;
long long C[MAXK][MAXK];
void Init() {
  for (int i = 0; i < E.nrow; i++) {
    E.a[i][i] = 1;
  }
  C[0][0] = 1;
  for (int i = 1; i <= K; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MODU;
    }
  }
}
Mat MatMul(const Mat &A, const Mat &B) {
  Mat ret(A.nrow, B.ncol);
  for (int i = 0; i < A.nrow; i++) {
    for (int j = 0; j < B.ncol; j++) {
      for (int k = 0; k < A.ncol; k++) {
        ret.a[i][j] += A.a[i][k] * B.a[k][j];
        ret.a[i][j] %= MODU;
      }
    }
  }
  return ret;
}
Mat MatExp(const Mat &A, int b) {
  Mat ret = E;
  Mat tmp = A;
  while (b) {
    if (1 & b) {
      ret = MatMul(ret, tmp);
    }
    tmp = MatMul(tmp, tmp);
    b >>= 1;
  }
  return ret;
}
int main() {
  cin >> N >> K;
  E = Mat(2 * K + 3, 2 * K + 3);
  O = Mat(2 * K + 3, 2 * K + 3);
  T = Mat(2 * K + 3, 2 * K + 3);
  Init();
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= i; j++) {
      T.a[K + 1 + j][i] = T.a[K + 1 + j][i + K + 1] = T.a[j][i + K + 1] =
          C[i][j];
    }
  }
  T.a[2 * K + 2][2 * K + 2] = T.a[2 * K + 1][2 * K + 2] = 1;
  Mat tmp(1, 2 * K + 3);
  for (int i = 0; i < 2 * K + 2; i++) {
    tmp.a[0][i] = 1;
  }
  long long tmpN = N;
  while (tmpN) {
    if (1 & tmpN) tmp = MatMul(tmp, T);
    T = MatMul(T, T);
    tmpN >>= 1;
  }
  cout << tmp.a[0][2 * K + 2] << endl;
  return 0;
}