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 C[50][50];
const long long MOD = 1000000007;
void init() {
  memset(C, 0, sizeof(C));
  for (int i = 0; i < 50; i++)
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
}
struct matrix {
  vector<vector<long long>> val;
  int N;
  matrix operator*(const matrix& rhs) const {
    matrix out;
    out.N = N;
    out.val = vector<vector<long long>>(N, vector<long long>(N));
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++) {
        out.val[i][j] = 0;
        for (int k = 0; k < N; k++)
          out.val[i][j] = (out.val[i][j] + val[i][k] * rhs.val[k][j]) % MOD;
      }
    return out;
  }
  matrix power(long long b) const {
    if (b == 0) {
      matrix out;
      out.N = N;
      out.val = vector<vector<long long>>(N, vector<long long>(N));
      for (int i = 0; i < N; i++) out.val[i][i] = 1;
      return out;
    }
    if (b % 2 == 0) return ((*this) * (*this)).power(b / 2);
    return (*this) * ((*this) * (*this)).power(b / 2);
  }
};
int main() {
  init();
  long long n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  matrix A;
  A.N = 2 * (k + 1) + 1;
  A.val = vector<vector<long long>>(A.N, vector<long long>(A.N));
  A.val[0][0] = 1;
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= k - i; j++) A.val[1 + i][k + 1 - j] = C[k - i][j];
  for (int m = k; m >= 0; m--)
    for (int l = 0; l <= m; l++)
      for (int r = 0; r <= l; r++) {
        long long mult = (C[m][l] * C[l][r]) % MOD;
        A.val[k + 1 - m][2 * k + 2 - r] =
            (A.val[k + 1 - m][2 * k + 2 - r] + mult) % MOD;
      }
  for (int i = 0; i <= k; i++) A.val[k + 2 + i][i + 1] = 1;
  for (int i = 1; i < 2 * (k + 1) + 1; i++) A.val[0][i] = A.val[1][i];
  auto B = A.power(n - 2);
  long long ans = 0;
  for (int i = 0; i <= k; i++) ans = (ans + B.val[0][k + 2 + i]) % MOD;
  long long mult = 1ll;
  for (int i = 0; i <= k; i++) {
    mult <<= 1;
    mult %= MOD;
    ans = (ans + mult * B.val[0][k + 1 - i]) % MOD;
  }
  mult = (mult + 1) % MOD;
  ans = (ans + mult * B.val[0][0]) % MOD;
  cout << ans << endl;
  return 0;
}