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;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
long long C[50][50];
const int mod = 1e9 + 7;
vector<vector<long long> > multi(vector<vector<long long> > &A,
                                 vector<vector<long long> > &B) {
  vector<vector<long long> > D(A.size(), vector<long long>(B[0].size()));
  for (int i = 0; i < A.size(); ++i)
    for (int k = 0; k < B.size(); ++k)
      for (int j = 0; j < B[0].size(); ++j)
        D[i][j] = (D[i][j] + A[i][k] * B[k][j]) % mod;
  return D;
}
vector<vector<long long> > mod_pow(vector<vector<long long> > A, long long n) {
  vector<vector<long long> > ANS(A.size(), vector<long long>(A.size()));
  for (int i = 0; i < A.size(); ++i) ANS[i][i] = 1;
  while (n > 0) {
    if (n & 1) ANS = multi(ANS, A);
    A = multi(A, A);
    n >>= 1;
  }
  return ANS;
}
int main() {
  for (int i = 0; i < 50; ++i) {
    for (int j = 0; j < i + 1; ++j) {
      C[i][j] = (j == 0 || j == i) ? 1 : (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
  }
  long long n, p;
  cin >> n >> p;
  vector<vector<long long> > m(83, vector<long long>(83));
  for (int k = 0; k < 41; ++k) {
    for (int i = 0; i < k + 1; ++i) {
      m[k][i] += C[k][i];
      for (int j = 0; j < i + 1; ++j) {
        (m[k][j + 41] += C[k][i] * C[i][j] % mod) %= mod;
      }
    }
  }
  for (int i = 0; i < 41; ++i) m[i + 41][i] = 1;
  m[82][p] = 1;
  m[82][82] = 1;
  m = mod_pow(m, n - 1);
  vector<vector<long long> > a(83, vector<long long>(1));
  for (int i = 0; i < 41; ++i) {
    a[i][0] = (i == 0 ? 2 : (a[i - 1][0] * 2) % mod);
    a[i + 41][0] = 1;
  }
  a[82][0] = 1;
  a = multi(m, a);
  cout << a[82][0] << endl;
  return 0;
}