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;
using lli = long long;
using lld = long double;
using ulli = unsigned long long int;
using pll = pair<lli, lli>;
using ttt = pair<lli, pll>;
using vttt = vector<ttt>;
using vll = vector<pll>;
using vl = vector<lli>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using cd = complex<lld>;
const double PI = acos(-1);
inline lli mpow(lli a, lli b, lli m = 1000000007) {
  lli ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    a = (a * a) % m;
    b /= 2;
  }
  return ans;
}
lli fact[50], invf[50];
void __prec() {
  fact[0] = 1;
  for (int i = 1; i < 50; i++) fact[i] = (fact[i - 1] * i) % 1000000007;
  for (int i = 0; i < 50; i++) invf[i] = mpow(fact[i], 1000000007 - 2);
}
lli nck(lli n, lli k) {
  if (k < 0 || n < k) return 0;
  return (((fact[n] * invf[n - k]) % 1000000007) * invf[k]) % 1000000007;
}
vvi operator*(vvi &m1, vvi &m2) {
  int n = ((lli)(m1).size()), m = ((lli)(m2).size()), k = ((lli)(m2[0]).size()),
      temp;
  vvi res(n, vi(k, 0));
  if (((lli)(m1[0]).size()) != m) return res;
  for (int row = 0; row < n; row++) {
    for (int col = 0; col < k; col++) {
      for (int i = 0; i < m; i++) {
        temp = (1LL * m1[row][i] * m2[i][col]) % 1000000007;
        res[row][col] = (res[row][col] + temp) % 1000000007;
      }
    }
  }
  return res;
}
vvi matpow(vvi mat, lli b) {
  int n = ((lli)(mat).size());
  vvi res(n, vi(n, 0));
  for (int i = 0; i < n; i++) res[i][i] = 1;
  while (b) {
    if (b & 1) res = res * mat;
    mat = mat * mat;
    b /= 2;
  }
  return res;
}
int tejas_919(int kkkk) {
  lli n, m, k, q, u, v, temp = 0, ans = 0;
  cin >> n >> k;
  if (n == 1) return cout << 1 << '\n', 0;
  vvi state(2 * k + 3, vi(1, 0)), mat(2 * k + 3, vi(2 * k + 3, 0));
  for (int i = 1; i < k + 2; i++) state[i][0] = mpow(2, k + 2 - i);
  for (int i = k + 2; i < 2 * k + 3; i++) state[i][0] = 1;
  state[0][0] = (state[1][0] + 1) % 1000000007;
  for (int i = 1; i < k + 2; i++) {
    lli tk = k + 1 - i;
    for (int j = k + 1 + i; j < 2 * k + 3; j++)
      mat[i][j] =
          (nck(tk, j - 1 - k - i) * mpow(2, j - 1 - k - i)) % 1000000007;
    for (int j = i; j < k + 2; j++) mat[i][j] = nck(tk, j - i);
  }
  for (int i = k + 2; i < 2 * k + 3; i++) mat[i][i - k - 1] = 1;
  for (int i = 1; i < 2 * k + 3; i++) mat[0][i] = mat[1][i];
  mat[0][0] = 1;
  mat = matpow(mat, n - 2);
  {}
  state = mat * state;
  {}
  cout << state[0][0] << '\n';
  return 0;
}
signed main() {
  if (!0) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  }
  cout << fixed << setprecision(10);
  int t = 1;
  __prec();
  for (int i = 0; i < t; i++) {
    tejas_919(i + 1);
  }
  {};
  if (0) system("pause");
}