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 maxn = 105;
const int maxm = 105;
const int MOD = 1000000007;
struct Matrix {
  int n, m;
  long long a[maxn][maxm];
  Matrix(int n = 0, int m = 0) {
    this->n = n;
    this->m = m;
  }
  void clear() {
    n = m = 0;
    memset(a, 0, sizeof(a));
  }
  Matrix operator*(const Matrix& b) const {
    Matrix tmp;
    tmp.clear();
    tmp.n = n, tmp.m = b.m;
    for (int i = 0; i < n; i++)
      for (int k = 0; k < m; k++)
        for (int j = 0; j < b.m; j++)
          tmp.a[i][j] = (tmp.a[i][j] + (long long)a[i][k] * b.a[k][j]) % MOD;
    return tmp;
  }
};
long long C[maxn][maxn];
void GetCnm() {
  memset(C, 0, sizeof(C));
  C[0][0] = 1;
  for (int i = 0; i <= maxn - 5; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
  }
}
long long pow2[maxn];
int k;
long long solve(long long b[], int n, long long t) {
  Matrix M, F, E;
  M.clear();
  F.clear();
  E.clear();
  M.n = M.m = n;
  E.n = E.m = n;
  F.n = n, F.m = 1;
  M.a[0][0] = M.a[0][1] = 1;
  for (int i = k, g = 1; i >= 0; i--, g++)
    for (int j = i, p = g, q = k + g + 1; j >= 0; j--, p++, q++) {
      M.a[g][p] = C[i][j];
      M.a[g][q] = C[i][j] * pow2[i - j] % MOD;
    }
  for (int i = k + 2; i < n; i++) M.a[i][i - k - 1] = 1;
  for (int i = 0; i < n; i++) {
    F.a[i][0] = b[i];
    E.a[i][i] = 1;
  }
  for (; t; t /= 2) {
    if (t & 1) E = M * E;
    M = M * M;
  }
  F = E * F;
  return F.a[0][0];
}
int main() {
  pow2[0] = 1;
  for (int i = 1; i < maxn; i++) pow2[i] = pow2[i - 1] * 2ll % MOD;
  long long n;
  GetCnm();
  while (scanf("%I64d%d", &n, &k) == 2) {
    long long b[maxn] = {0};
    b[0] = 1;
    for (int i = k, p = 1, q = k + 2; i >= 0; i--, p++, q++) {
      b[p] = pow2[i + 1];
      b[q] = 1;
    }
    printf("%I64d\n", solve(b, 2 * k + 3, n - 1) % MOD);
  }
  return 0;
}