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 mod = 1000000007;
long long mnogo = 7.9e18;
vector<vector<long long> > umnm(const vector<vector<long long> >& a,
                                const vector<vector<long long> >& b) {
  vector<vector<long long> > res(a.size(), vector<long long>(b[0].size()));
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < b[0].size(); j++)
      for (int g = 0; g < a.size(); g++) {
        res[i][j] += (a[i][g] * b[g][j]);
        if (res[i][j] >= mnogo) res[i][j] %= mod;
      }
  for (int i = 0; i < res.size(); ++i)
    for (int j = 0; j < res[0].size(); ++j)
      if (res[i][j] >= mod) res[i][j] %= mod;
  return res;
}
vector<vector<long long> > pw(vector<vector<long long> > a,
                              vector<vector<long long> >& res, long long n) {
  while (n) {
    if (n & 1ll) res = umnm(a, res);
    a = umnm(a, a);
    n >>= 1;
  }
  return res;
}
long long pw(long long x, int st) {
  if (st < 0) return 0;
  long long res = 1;
  while (st--) {
    res = (res * x) % mod;
  }
  return res;
}
int main() {
  long long C[100][100];
  C[0][0] = 1;
  for (int j = 1; j < 100; j++) C[0][j] = 0;
  for (int i = 1; i < 100; i++) {
    C[i][0] = 1;
    for (int j = 1; j < 100; j++)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
  }
  long long n;
  int k;
  cin >> n >> k;
  vector<vector<long long> > base(2 * k + 3, vector<long long>(2 * k + 3));
  for (int i = 0; i <= k; i++) base[i][i + k + 1] = 1;
  for (int i = k + 1; i <= 2 * k + 1; i++) {
    for (int j = 0; j <= k; j++)
      base[i][j] = (C[i - k - 1][j] * pw(2, i - k - 1 - j)) % mod;
    for (int j = k + 1; j <= 2 * k + 1; j++)
      base[i][j] = C[i - k - 1][j - k - 1];
  }
  base[2 * k + 2][2 * k + 1] = 1;
  base[2 * k + 2][2 * k + 2] = 1;
  vector<vector<long long> > A(2 * k + 3, vector<long long>(1));
  for (int i = 0; i <= k; i++) A[i][0] = 1;
  for (int i = k + 1; i <= 2 * k + 1; i++) A[i][0] = pw(2, i - k);
  A[2 * k + 2][0] = 1;
  base = pw(base, A, n - 1);
  cout << A[2 * k + 2][0];
}