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 MOD = 1e9 + 7;
struct Matrix {
  int n;
  long long a[200][200];
  void init(int _n) {
    memset(a, 0, sizeof(a));
    n = _n;
  }
  void idx(int _n) {
    init(_n);
    for (int i = 0; i < n; i++) a[i][i] = 1;
  }
  Matrix operator*(const Matrix &rhs) const {
    Matrix res;
    res.init(n);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          res.a[i][j] = (res.a[i][j] + a[i][k] * rhs.a[k][j]) % MOD;
        }
      }
    }
    return res;
  }
};
long long n, C[209][209], bin[209];
int m;
long long col[209];
Matrix mgml(Matrix a, long long b) {
  Matrix res;
  res.idx(a.n);
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < 209; 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;
  }
  bin[0] = 1;
  for (int i = 1; i < 209; i++) bin[i] = (bin[i - 1] + bin[i - 1]) % MOD;
  Matrix a;
  int sz = 2 * (m + 1) + 1;
  a.init(sz);
  for (int i = m + 1; i <= 2 * m + 1; i++) {
    a.a[i][i - m - 1] = 1;
  }
  a.a[sz - 1][sz - 1] = 1;
  for (int i = 0; i <= m; i++) {
    int k = m - i;
    for (int j = i; j <= m; j++) {
      int c = m - j;
      a.a[i][j] = (a.a[i][j] + C[k][c]) % MOD;
    }
    for (int j = i + m + 1; j <= 2 * m + 1; j++) {
      int c = 2 * m + 1 - j;
      a.a[i][j] = (a.a[i][j] + C[k][c] * bin[k - c]) % MOD;
    }
  }
  for (int i = 0; i < sz; i++)
    a.a[sz - 1][i] = (a.a[sz - 1][i] + a.a[0][i]) % MOD;
  for (int i = 0; i <= m; i++) {
    col[i] = bin[m - i + 1];
  }
  for (int i = m + 1; i <= 2 * m + 1; i++) {
    col[i] = 1;
  }
  col[sz - 1] = (2 * bin[m] + 1) % MOD;
  if (n >= 2) {
    a = mgml(a, n - 2);
    long long ans = 0;
    for (int i = 0; i < sz; i++) {
      ans = (ans + a.a[sz - 1][i] * col[i]) % MOD;
    }
    if (ans < 0) ans += MOD;
    cout << ans << endl;
  } else {
    puts("1");
  }
  return 0;
}