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 inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int maxk = 40 + 5;
const int maxs = 100;
const long long mod = 1000000007;
struct Matrix {
  int r, c;
  long long val[maxs][maxs];
  Matrix(int r, int c) : r(r), c(c) { memset(val, 0, sizeof(val)); }
  Matrix(long long a[][maxk * 2], int r, int c) : r(r), c(c) {
    for (int i = 0; i < (r); ++i)
      for (int j = 0; j < (c); ++j) val[i][j] = a[i][j];
  }
  Matrix &operator=(const Matrix &m) {
    r = m.r;
    c = m.c;
    for (int i = 0; i < (r); ++i)
      for (int j = 0; j < (c); ++j) val[i][j] = m.val[i][j];
    return *this;
  }
  Matrix operator*(const Matrix &m) {
    Matrix tmp(r, m.c);
    for (int i = 0; i < (r); ++i)
      for (int j = 0; j < (m.c); ++j)
        for (int k = 0; k < (c); ++k) {
          tmp.val[i][j] += val[i][k] * m.val[k][j];
          tmp.val[i][j] %= mod;
        }
    return tmp;
  }
  Matrix pow(long long b) {
    Matrix a = *this, res(r, c);
    for (int i = 0; i < (r); ++i) res.val[i][i] = 1;
    while (b) {
      if (b & 1) res = res * a;
      a = a * a;
      b >>= 1;
    }
    return res;
  }
};
long long n;
int k;
long long pow2[maxk], C[maxk][maxk];
long long a[1][maxk * 2], b[maxk * 2][maxk * 2];
void init() {
  pow2[0] = 1;
  for (long long i = (1); i <= (k); ++i) pow2[i] = pow2[i - 1] * 2 % mod;
  for (long long i = (0); i <= (k); ++i) {
    C[i][0] = C[i][i] = 1;
    for (long long j = (1); j <= (i - 1); ++j)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  init();
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  a[0][0] = 1;
  for (long long i = (0); i <= (k); ++i) a[0][(k + 1) + i] = 1;
  for (long long i = (0); i <= (k); ++i) b[(k + 1) + i][i] = 1;
  for (long long i = (0); i <= (k); ++i) {
    for (long long j = (0); j <= (i); ++j)
      b[j][(k + 1) + i] = C[i][j] * pow2[i - j] % mod;
    for (long long j = (0); j <= (i); ++j)
      b[(k + 1) + j][(k + 1) + i] = C[i][j];
  }
  b[(k + 1) + k][(k + 1) * 2] = b[(k + 1) * 2][(k + 1) * 2] = 1;
  Matrix A(a, 1, (k + 1) * 2 + 1);
  Matrix B(b, (k + 1) * 2 + 1, (k + 1) * 2 + 1);
  A = A * B.pow(n);
  cout << A.val[0][(k + 1) * 2] << endl;
  return 0;
}