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 Matrix {
  long long matrix[100][100];
};
int n;
const int mod = 1e9 + 7;
long long c[45][45];
void init(Matrix &res) {
  memset(res.matrix, 0, sizeof(res.matrix));
  for (int i = 0; i <= 40; i++) res.matrix[i][i] = 1;
}
Matrix multiplicative(Matrix a, Matrix b) {
  Matrix res;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      res.matrix[i][j] = 0;
      for (int k = 0; k < n; k++) {
        res.matrix[i][j] =
            (res.matrix[i][j] % mod + a.matrix[i][k] * b.matrix[k][j] % mod) %
            mod;
      }
    }
  }
  return res;
}
Matrix pow(Matrix mx, long long m) {
  Matrix res, base = mx;
  init(res);
  while (m) {
    if (m & 1) res = multiplicative(res, base);
    base = multiplicative(base, base);
    m >>= 1;
  }
  return res;
}
void init_matrix(Matrix &mx, const int &k) {
  mx.matrix[0][0] = 1;
  for (int i = 0; i <= k; i++) {
    mx.matrix[0][i + 1] = c[k][i];
    mx.matrix[0][k + 2 + i] = c[k][i];
  }
  mx.matrix[1][1] = mx.matrix[1][k + 2] = 1;
  for (int i = 1; i <= k; i++)
    for (int j = 0; j <= i; j++) {
      mx.matrix[i + 1][j + 1] = c[i][j];
      mx.matrix[i + 1][j + k + 2] = c[i][j];
      mx.matrix[i + k + 2][j + 1] = c[i][j];
    }
  mx.matrix[k + 2][1] = 1;
  return;
}
void init_c() {
  memset(c, 0, sizeof(c));
  c[0][0] = c[1][0] = c[1][1] = 1;
  for (int i = 2; i < 45; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
  }
}
int main() {
  Matrix mx, nx;
  long long m;
  int k;
  init_c();
  scanf("%I64d%d", &m, &k);
  n = 2 * k + 3;
  init_matrix(mx, k);
  nx = pow(mx, m - 1);
  long long ans = 0;
  for (int i = 0; i < n; i++) ans = (ans + nx.matrix[0][i] % mod) % mod;
  printf("%I64d\n", ans);
  return 0;
}