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 N = 100;
const long long mod = 1e9 + 7;
long long n, C[45][45];
int k;
struct Matrix {
  int n, m;
  int v[N][N];
  Matrix(int n = 0, int m = 0) : n(n), m(m) { memset(v, 0, sizeof v); }
  void init() { memset(v, 0, sizeof v); }
  void show() {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) cout << v[i][j] << " ";
      cout << endl;
    }
  }
  Matrix operator*(const Matrix B) const {
    Matrix C(n, B.m);
    C.init();
    for (int i = 0; i < n; i++)
      for (int j = 0; j < B.m; j++)
        for (int k = 0; k < m; k++)
          C.v[i][j] =
              ((v[i][k] % mod) * (B.v[k][j] % mod) + C.v[i][j] % mod) % mod;
    return C;
  }
};
void init1() {
  for (int i = 0; i <= 40; i++) C[i][0] = C[i][i] = 1;
  for (int i = 1; i <= 40; i++) {
    for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
  }
}
Matrix a, b;
void make_a() {
  a.n = 1;
  a.m = 2 * k + 3;
  a.init();
  for (int i = 0; i <= k; i++) a.v[0][i] = 1;
  for (int i = k + 1; i <= 2 * k + 1; i++) a.v[0][i] = 2;
  a.v[0][2 * k + 2] = 1;
}
void make_b() {
  b.n = b.m = 2 * k + 3;
  b.init();
  for (int j = 0; j <= k; j++) {
    int cnt1 = j;
    for (int i = k + 1, cnt2 = 0; i <= 2 * k + 1 && cnt2 <= cnt1; i++, cnt2++)
      b.v[i][j] = C[cnt1][cnt2];
  }
  for (int j = k + 1; j <= 2 * k + 1; j++) {
    int cnt1 = j - k - 1;
    for (int i = 0, cnt2 = 0; i <= k && cnt2 <= cnt1; i++, cnt2++)
      b.v[i][j] = C[cnt1][cnt2];
    for (int i = k + 1, cnt2 = 0; i <= 2 * k + 1 && cnt2 <= cnt1; i++, cnt2++)
      b.v[i][j] = C[cnt1][cnt2];
  }
  int cnt1 = k;
  for (int i = k + 1, cnt2 = 0; i <= 2 * k + 1 && cnt2 <= cnt1; i++, cnt2++)
    b.v[i][2 * k + 2] = C[cnt1][cnt2];
  b.v[2 * k + 2][2 * k + 2] = 1;
}
Matrix ksm(Matrix unit, long long x, Matrix turn) {
  Matrix ret = unit;
  while (x) {
    if (x & 1) ret = ret * turn;
    turn = turn * turn;
    x >>= 1;
  }
  return ret;
}
int main() {
  init1();
  cin >> n >> k;
  make_a();
  make_b();
  Matrix res = ksm(a, n - 1, b);
  cout << res.v[0][2 * k + 2] << endl;
}