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 long long mod = 1e9 + 7;
const int N = 2e5 + 5;
void multiply(vector<vector<long long>> &a, vector<vector<long long>> &b) {
  int n = a.size();
  vector<vector<long long>> mul(n, vector<long long>(n, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        mul[i][j] = (mul[i][j] + a[i][k] * b[k][j]) % mod;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) a[i][j] = mul[i][j];
}
void add(vector<vector<long long>> &a, vector<vector<long long>> &b) {
  int n = a.size();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) a[i][j] = (a[i][j] + b[i][j]) % mod;
}
vector<vector<long long>> power(vector<vector<long long>> &M,
                                unsigned long long y) {
  int n = M.size();
  vector<vector<long long>> F(n, vector<long long>(n, 0));
  vector<vector<long long>> T(n, vector<long long>(n, 0));
  vector<vector<long long>> I(n, vector<long long>(n, 0));
  for (int i = 0; i < n; i++) T[i][i] = I[i][i] = 1;
  while (y) {
    if (y & 1) {
      multiply(F, M);
      add(F, T);
    }
    y >>= 1;
    vector<vector<long long>> temp = M;
    add(temp, I);
    multiply(T, temp);
    multiply(M, M);
  }
  return F;
}
long long C[50][50], pw[50];
void pre() {
  for (long long i = 0; i < 50; i++) {
    for (long long j = 0; j <= i; j++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    }
  }
  pw[0] = 1;
  for (long long i = 1; i < 50; i++) pw[i] = (pw[i - 1] * 2) % mod;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  pre();
  long long n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << "1";
    return 0;
  }
  long long m = 2 * (k + 1);
  vector<vector<long long>> M(m, vector<long long>(m, 0));
  long long i, j;
  long long curr = k, pos = 0;
  for (i = 0; i < m; i += 2) {
    long long cnt = 0;
    for (j = pos; j < m; j += 2) {
      M[i][j] = C[curr][cnt];
      M[i][j + 1] = (C[curr][cnt] * pw[cnt]) % mod;
      cnt++;
    }
    curr--;
    M[i + 1][pos] = 1;
    pos += 2;
  }
  long long arr[m];
  arr[m - 1] = 1;
  arr[m - 2] = 2;
  for (i = m - 3; i > 0; i -= 2) {
    arr[i] = arr[i + 2];
    arr[i - 1] = (arr[i + 1] * 2) % mod;
  }
  vector<vector<long long>> F = power(M, n - 1);
  long long ans = 1;
  for (i = 0; i < m; i++) ans = (ans + F[0][i] * arr[i]) % mod;
  cout << ans;
  return 0;
}