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;
struct Mat {
  long long at[85][85];
  int row, col;
};
const long long MOD = 1000000007;
Mat operator*(const Mat &a, const Mat &b) {
  int i, j, k, m, n, p;
  Mat res;
  m = a.row;
  n = b.col;
  p = a.col;
  res.row = m;
  res.col = n;
  memset(res.at, 0, sizeof(res.at));
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < p; k++) {
        res.at[i][j] += (a.at[i][k] * b.at[k][j]) % MOD;
        res.at[i][j] %= MOD;
      }
    }
  }
  return res;
}
Mat operator^(Mat a, long long k) {
  Mat res;
  int n, i;
  n = a.row;
  res.row = res.col = n;
  memset(res.at, 0, sizeof(res.at));
  for (i = 0; i < n; i++) res.at[i][i] = 1;
  if (k == 0) return res;
  while (k > 0) {
    if (k % 2 != 0) res = res * a;
    k /= 2;
    a = a * a;
  }
  return res;
}
long long power[41], C[41][41];
int init(int n);
int main() {
  long long n, k;
  int i, j;
  Mat a, origin, res;
  init(40);
  while (scanf("%lld%lld", &n, &k) > 0) {
    if (n == 1) {
      printf("1\n");
      continue;
    }
    origin.row = 1 + 2 * (k + 1);
    origin.col = 1;
    origin.at[0][0] = (1 + 2 * power[k]) % MOD;
    for (i = 0; i <= k; i++) origin.at[i + 1][0] = (2 * power[i]) % MOD;
    for (i = 0; i <= k; i++) origin.at[2 + k + i][0] = power[i] % MOD;
    a.row = a.col = (1 + 2 * (k + 1));
    memset(a.at, 0, sizeof(a.at));
    a.at[0][0] = 1;
    for (i = 0; i <= k; i++) a.at[0][i + 1] = a.at[0][2 + k + i] = C[k][i];
    for (i = 0; i <= k; i++) {
      for (j = 0; j <= i; j++)
        a.at[i + 1][j + 1] = a.at[i + 1][2 + k + j] = a.at[2 + k + i][j + 1] =
            C[i][j];
    }
    res = (a ^ (n - 2)) * origin;
    printf("%lld\n", res.at[0][0]);
  }
  return 0;
}
int init(int n) {
  long long tmp = 1;
  for (int i = 0; i <= n; i++) {
    power[i] = tmp;
    tmp *= 2;
  }
  for (int i = 0; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    ;
    for (int j = 1; j < i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
  }
  return 1;
}