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;
template <typename T>
struct Matrix {
  T mat[128][128];
  static int n, p;
  Matrix() {}
  Matrix(const T &x) {
    int i;
    memset(mat, 0, sizeof(mat));
    for (i = 0; i < n; ++i) mat[i][i] = x;
  }
  static void resize(int _n) { n = _n; }
  static void setMod(int _p) { p = _p; }
  T *operator[](int k) { return mat[k]; }
  Matrix<T> operator*(const Matrix<T> &o) const {
    Matrix ret(0);
    int i, j, k;
    for (i = 0; i < n; ++i) {
      for (k = 0; k < n; ++k) {
        if (!mat[i][k]) continue;
        for (j = 0; j < n; ++j) {
          ret.mat[i][j] += mat[i][k] * o.mat[k][j];
          if (~p) ret.mat[i][j] %= p;
        }
      }
    }
    return ret;
  }
  Matrix<T> pow(long long x) const {
    Matrix<T> ret(1), a = *this;
    for (; x; x >>= 1) {
      if (x & 1) ret = ret * a;
      a = a * a;
    }
    return ret;
  }
};
template <typename T>
int Matrix<T>::n = 0;
template <typename T>
int Matrix<T>::p = -1;
long long cb[128][128], vec[128];
long long calc(int n, int k) {
  if (!k || n == k) return 1;
  if (~cb[n][k]) return cb[n][k];
  return cb[n][k] = (calc(n - 1, k - 1) + calc(n - 1, k)) % 1000000007;
}
long long solve(long long n, int k) {
  Matrix<long long> a(0), b;
  int i, j, m = (2 * (k + 1) + 1);
  long long ret = 0;
  Matrix<long long>::resize(m);
  Matrix<long long>::setMod(1000000007);
  a[0][0] = a[0][1] = 1;
  for (i = 0; i <= k; ++i) {
    for (j = i; j <= k; ++j) {
      a[(((i) << 1) + 1)][(((j) << 1) + 1)] = calc(k - i, j - i);
      a[(((i) << 1) + 1)][(((j) << 1) + 2)] = calc(k - i, j - i);
      a[(((i) << 1) + 2)][(((j) << 1) + 1)] = calc(k - i, j - i);
      a[(((i) << 1) + 2)][(((j) << 1) + 2)] = 0;
    }
  }
  b = a.pow(n);
  vec[0] = 0;
  for (i = 1; i < m; ++i) vec[i] = 1;
  for (i = 0; i < m; ++i) {
    ret = (ret + b[0][i] * vec[i]) % 1000000007;
  }
  return ret;
}
int main() {
  long long n;
  int k;
  memset(cb, -1, sizeof(cb));
  while (cin >> n >> k) {
    cout << solve(n, k) << endl;
  }
  return 0;
}