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 = (int)1e9 + 7;
struct mint {
  int n;
  mint(int n_ = 0) : n(n_ % MOD) {
    if (n < 0) n += MOD;
  }
};
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }
istream &operator>>(istream &is, mint &a) { return is >> a.n; }
mint inv(mint x) {
  long long a = x.n, b = MOD, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    swap((a -= t * b), b);
    swap((u -= t * v), v);
  }
  return mint(u);
}
mint operator^(mint a, long long n) {
  mint r = 1;
  while (n) {
    if (n & 1) r *= a;
    a *= a;
    n >>= 1;
  }
  return r;
}
bool operator<(const mint &a, const mint &b) { return a.n < b.n; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (auto &vi : vec) os << vi << " ";
  return os;
}
template <class T>
struct Matrix {
  vector<vector<T>> val;
  Matrix(int n = 1, int m = 1, T x = 0) : val(n, vector<T>(m, x)) {}
  size_t size() const { return val.size(); }
  vector<T> &operator[](int i) { return val[i]; }
  const vector<T> &operator[](int i) const { return val[i]; }
  friend ostream &operator<<(ostream &os, const Matrix<T> M) {
    for (int i = 0; i < (int)M.size(); ++i)
      os << M[i] << " \n"[i != (int)M.size() - 1];
    return os;
  }
};
template <class T>
Matrix<T> operator^(Matrix<T> A, long long n) {
  Matrix<T> R(A.size(), A.size());
  for (int i = 0; i < (int)A.size(); ++i) R[i][i] = 1;
  while (n > 0) {
    if (n & 1) R = R * A;
    A = A * A;
    n >>= 1;
  }
  return R;
}
template <class T>
Matrix<T> operator*(const Matrix<T> &A, const Matrix<T> &B) {
  Matrix<T> R(A.size(), B[0].size());
  for (int i = 0; i < (int)A.size(); ++i)
    for (int j = 0; j < (int)B[0].size(); ++j)
      for (int k = 0; k < (int)B.size(); ++k) R[i][j] += A[i][k] * B[k][j];
  return R;
}
template <class T>
vector<T> operator*(const Matrix<T> &A, vector<T> &B) {
  vector<T> v(A.size());
  for (int i = 0; i < (int)A.size(); ++i)
    for (int k = 0; k < (int)B.size(); ++k) v[i] += A[i][k] * B[k];
  return v;
}
int main() {
  long long N;
  cin >> N;
  int K;
  cin >> K;
  int sz = K + 1;
  Matrix<mint> mat(sz * 2 + 1, sz * 2 + 1);
  for (int i = 0; i < sz; i++) {
    mat[i][0] = mat[i][sz + i] = 1;
    for (int j = i; j >= 0; j--) {
      if (j) mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
      mat[i][sz + j] = (mint(2) ^ (i - j)) * mat[i][j];
    }
    mat[sz + i][i] = 1;
  }
  mat[sz * 2][sz - 1] = mat[sz * 2][sz * 2] = 1;
  vector<mint> state(sz * 2 + 1);
  for (int i = 0; i < sz; i++) {
    state[i] = mint(1) ^ i;
    state[i + sz] = mint(0) ^ i;
  }
  cout << ((mat ^ N) * state).back() << endl;
  return 0;
}