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 = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = (40 + 1 << 1) + 1 + 1;
const int mod = 1e9 + 7;
long long n, k, comb[N][N], c[N][N], power[N];
void mul(vector<vector<int> > &a, vector<vector<int> > &b) {
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= N - 1; i++)
    for (int j = 1; j <= N - 1; j++)
      for (int k = 1; k <= N - 1; k++)
        c[i][j] = (c[i][j] + (long long)a[i][k] * b[k][j]) % mod;
  for (int i = 1; i <= N - 1; i++)
    for (int j = 1; j <= N - 1; j++) a[i][j] = c[i][j];
}
int main() {
  ios ::sync_with_stdio(0);
  comb[0][0] = 1;
  for (int i = 1; i <= N - 1; i++) {
    comb[i][0] = 1;
    for (int j = 1; j <= i; j++)
      comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
  }
  cin >> n >> k;
  if (n == 1) return cout << 1 << '\n', 0;
  vector<vector<int> > t;
  t.resize(N);
  for (int i = 1; i <= N - 1; i++) t[i].resize(N);
  for (int i = 1; i <= k + 1; i++) {
    for (int j = i; j <= k + 1; j++) t[i][j] = comb[k - i + 1][j - i];
    for (int j = k + 1 + i; j <= 2 * k + 2; j++)
      t[i][j] = comb[k - i + 1][j - (k + 1 + i)];
  }
  for (int i = k + 2; i <= 2 * k + 2; i++)
    for (int j = i - (k + 2) + 1; j <= k + 1; j++)
      t[i][j] = comb[k - (i - (k + 2))][j - (i - (k + 2) + 1)];
  for (int i = 1; i <= k + 1; i++) t[2 * k + 3][i] = comb[k][i - 1];
  for (int i = k + 2; i <= 2 * k + 2; i++)
    t[2 * k + 3][i] = comb[k][i - (k + 2)];
  t[2 * k + 3][2 * k + 3] = 1;
  vector<vector<int> > res;
  res.resize(N);
  for (int i = 1; i <= N - 1; i++) res[i].resize(N);
  for (int i = 1; i <= N - 1; i++) res[i][i] = 1;
  n -= 2;
  for (int i = 0; i <= 60; i++) {
    if (n & 1LL << i) mul(res, t);
    mul(t, t);
  }
  power[0] = 1;
  for (int i = 1; i <= N - 1; i++) power[i] = power[i - 1] * 2 % mod;
  long long ans = 0;
  for (int i = 1; i <= k + 1; i++)
    ans = (ans + res[2 * k + 3][i] * power[k - i + 1] * 2) % mod;
  for (int i = k + 2; i <= 2 * k + 2; i++)
    ans = (ans + res[2 * k + 3][i] * power[k - (i - (k + 2))]) % mod;
  ans = (ans + res[2 * k + 3][2 * k + 3] * (1 + 2 * power[k])) % mod;
  cout << ans << '\n';
  return 0;
}