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 MAXN2 = 64;
long long c[MAXN2 + 5][MAXN2 + 5];
void CNTable() {
  c[0][0] = 1;
  for (int i = 1; i <= MAXN2; ++i) {
    c[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
    }
  }
}
struct Matrix {
  long long Mat[100][100];
  int n, m;
} mc, bs;
Matrix Mul(Matrix a, Matrix b) {
  Matrix re;
  re.n = a.n;
  re.m = b.m;
  for (int i = 0; i < a.n; ++i)
    for (int j = 0; j < b.m; ++j) re.Mat[i][j] = 0;
  for (int i = 0; i < a.n; ++i) {
    for (int j = 0; j < b.m; ++j) {
      for (int k = 0; k < a.m; ++k) {
        re.Mat[i][j] = re.Mat[i][j] + (a.Mat[i][k] * b.Mat[k][j]) % 1000000007;
        re.Mat[i][j] %= 1000000007;
      }
    }
  }
  return re;
}
Matrix FPOMCounting(Matrix base, long long n) {
  Matrix re = base;
  for (int i = 0; i < re.n; ++i)
    for (int j = 0; j < re.m; ++j) {
      if (i == j)
        re.Mat[i][j] = 1;
      else
        re.Mat[i][j] = 0;
    }
  while (n) {
    if (n & 1) re = Mul(re, base);
    base = Mul(base, base);
    n >>= 1;
  }
  return re;
}
int main() {
  CNTable();
  long long n, k, len;
  while (scanf("%lld %lld", &n, &k) != EOF) {
    memset(mc.Mat, 0, sizeof(mc.Mat));
    len = 2 * k + 3;
    mc.n = mc.m = len;
    bs.n = len;
    bs.m = 1;
    for (int i = 0; i < len; ++i) bs.Mat[i][0] = 1;
    mc.Mat[0][0] = 1;
    for (int j = 0; j <= k; j++) {
      mc.Mat[0][j + 1] = c[k][j];
      mc.Mat[0][j + k + 2] = c[k][j];
    }
    mc.Mat[1][1] = mc.Mat[1][k + 2] = 1;
    for (int i = 1; i <= k; i++) {
      for (int j = 0; j <= i; j++) {
        mc.Mat[i + 1][j + 1] = c[i][j];
        mc.Mat[i + 1][j + k + 2] = c[i][j];
      }
    }
    mc.Mat[k + 2][1] = 1;
    for (int i = 1; i <= k; i++) {
      for (int j = 0; j <= i; j++) {
        mc.Mat[i + k + 2][j + 1] = c[i][j];
      }
    }
    Matrix re, tem;
    tem = FPOMCounting(mc, n - 1);
    re = Mul(tem, bs);
    printf("%lld\n", re.Mat[0][0]);
  }
  return 0;
}