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;
long long n, k;
struct mat {
  long long x[90][90];
  mat() { memset(x, 0, sizeof(x)); }
  mat(int k) {
    memset(x, 0, sizeof(x));
    for (int i = 0; i < 90; i++) x[i][i] = 1;
  }
};
mat operator*(mat &a, mat &b) {
  mat res;
  for (int i = 0; i < 90; i++) {
    for (int j = 0; j < 90; j++) {
      long long aux = 0;
      for (int k = 0; k < 90; k++)
        aux = (aux + (a.x[i][k] * b.x[k][j]) % 1000000007) % 1000000007;
      res.x[i][j] = aux % 1000000007;
    }
  }
  return res;
}
mat pot(mat a, long long k) {
  mat res(1);
  while (k > 0) {
    if (k & 1) res = res * a;
    a = a * a;
    k >>= 1;
  }
  return res;
}
void imp(mat a) {
  for (int i = 0; i <= 2 * k + 2; i++) {
    for (int j = 0; j <= 2 * k + 2; j++) cout << a.x[i][j] << " ";
    cout << endl;
  }
}
long long tc[50][50];
long long comb(int a, int b) {
  long long &ret = tc[a][b];
  if (ret != -1) return ret;
  if (a == b) return ret = 1;
  if (b == 0) return ret = 1;
  return ret = (comb(a - 1, b) + comb(a - 1, b - 1)) % 1000000007;
}
long long fs() {
  if (n == 1) return 1;
  mat res;
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= i; j++) {
      res.x[i][j + k + 1] = comb(i, j);
      res.x[i + k + 1][j] = comb(i, j);
      res.x[i + k + 1][j + k + 1] = comb(i, j);
    }
  for (int i = 0; i <= k; i++) res.x[2 * k + 2][i + k + 1] = comb(k, i);
  res.x[2 * k + 2][2 * k + 2] = 1;
  res = pot(res, n - 1);
  long long resp = 0;
  for (int i = 0; i <= k; i++) resp = (resp + res.x[2 * k + 2][i]) % 1000000007;
  for (int i = 0; i <= k; i++)
    resp = (resp + 2LL * res.x[2 * k + 2][i + k + 1]) % 1000000007;
  resp = (resp + 1) % 1000000007;
  return resp;
}
int main() {
  memset(tc, -1, sizeof(tc));
  cin >> n >> k;
  cout << fs() << endl;
}