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;
int K;
vector<vector<long long> > mul(vector<vector<long long> > &A,
                               vector<vector<long long> > &B) {
  vector<vector<long long> > C(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)++)
        C[i][j] = (C[i][j] + A[i][k] * B[k][j] % 1000000007) % 1000000007;
  return C;
}
vector<vector<long long> > pow(long long c, vector<vector<long long> > A) {
  int n = A.size();
  vector<vector<long long> > B(n, vector<long long>(n));
  for (int(i) = 0; (i) < (n); (i)++) B[i][i] = 1;
  while (c) {
    if (c & 1) B = mul(B, A);
    A = mul(A, A);
    c /= 2;
  }
  return B;
}
int C[50][50];
int main() {
  C[0][0] = 1;
  for (int(i) = (1); (i) < (50); (i)++)
    for (int(j) = 0; (j) < (i + 1); (j)++) {
      C[i][j] = C[i - 1][j];
      if (j) C[i][j] = (C[i][j] + C[i - 1][j - 1]) % 1000000007;
    }
  cin >> N >> K;
  vector<vector<long long> > A(K * 2 + 3, vector<long long>(K * 2 + 3));
  for (int(i) = 0; (i) < (K + 1); (i)++) {
    for (int(j) = 0; (j) < (i + 1); (j)++) {
      A[i][j] = C[i][j];
      A[i][j + K + 1] = C[i][j];
    }
  }
  for (int(i) = 0; (i) < (K + 1); (i)++)
    for (int(j) = 0; (j) < (i + 1); (j)++) A[i + K + 1][j] = C[i][j];
  A[K + K + 2][K] = 1;
  A[K + K + 2][K + K + 2] = 1;
  A = pow(N + 1, A);
  vector<vector<long long> > B(K + K + 3, vector<long long>(1));
  B[0][0] = 1;
  A = mul(A, B);
  cout << A[K + K + 2][0] << endl;
}