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 int Matsize = 85;
const int MOD = 1000000007;
long long n, k, C[Matsize][Matsize];
struct Mat {
  long long mat[Matsize][Matsize];
  void init() {
    for (int i = 0; i < Matsize; i++) {
      for (int j = 0; j < Matsize; j++) mat[i][j] = 0;
      mat[i][i] = 1;
    }
  }
  Mat operator*(const Mat &t) const {
    Mat ans;
    memset(ans.mat, 0, sizeof(ans.mat));
    for (int k = 0; k < Matsize; k++)
      for (int i = 0; i < Matsize; i++)
        for (int j = 0; j < Matsize; j++)
          ans.mat[i][j] = (ans.mat[i][j] + mat[i][k] * t.mat[k][j]) % MOD;
    return ans;
  }
  Mat operator+(const Mat &t) const {
    Mat ans;
    for (int i = 0; i < Matsize; i++)
      for (int j = 0; j < Matsize; j++)
        ans.mat[i][j] = (mat[i][j] + t.mat[i][j]) % MOD;
    return ans;
  }
};
Mat mt, a;
Mat pow_M(long long m) {
  Mat res;
  res.init();
  while (m) {
    if (m & 1) res = res * mt;
    mt = mt * mt;
    m /= 2;
  }
  return res;
}
long long Fp(long long x, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * x % MOD;
    x = x * x % MOD;
    n /= 2;
  }
  return ans;
}
int main() {
  C[0][0] = C[1][0] = C[1][1] = 1;
  for (int i = 2; i < Matsize; i++) {
    C[i][0] = 1;
    for (int j = 1; j < Matsize; j++) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
  }
  scanf("%I64d%I64d", &n, &k);
  if (n == 1) return 0 * puts("1");
  if (n == 2) return 0 * printf("%I64d\n", 1 + Fp(2, k) * 2);
  for (int j = 0; j <= k; j++) {
    for (int i = k + 1; i <= j + k + 1; i++) {
      mt.mat[i][j] = C[j][i - (k + 1)];
    }
  }
  for (int j = k + 1; j < 2 * (k + 1); j++) {
    for (int i = 0; i <= j - (k + 1); i++) {
      mt.mat[i][j] = C[j - (k + 1)][i];
    }
  }
  for (int j = k + 1; j < 2 * (k + 1); j++) {
    for (int i = k + 1; i <= j; i++) {
      mt.mat[i][j] = C[j - (k + 1)][i - (k + 1)];
    }
  }
  for (int i = 0; i < 2 * (k + 1); i++) {
    mt.mat[i][2 * (k + 1)] = mt.mat[i][2 * (k + 1) - 1];
  }
  mt.mat[2 * (k + 1)][2 * (k + 1)] = 1;
  for (int i = 0; i < k + 1; i++) {
    a.mat[0][i] = Fp(2, i);
  }
  for (int i = k + 1; i < 2 * (k + 1); i++) {
    a.mat[0][i] = 2 * Fp(2, i - (k + 1));
  }
  a.mat[0][2 * (k + 1)] = 1 + Fp(2, k) * 2;
  a = a * pow_M(n - 2);
  printf("%I64d\n", a.mat[0][2 * (k + 1)]);
}