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>
const long long MOD = 1000000007LL;
struct matrix {
  int n;
  long long m[85][85];
  matrix(int _n = 0) : n(_n) { memset(m, 0, sizeof(m)); }
  inline void unit() {
    for (int i = 1; i <= n; ++i) m[i][i] = 1LL;
  }
} M;
long long cmb[44][44] = {1LL}, n;
int k;
inline void init() {
  memset(M.m, 0, sizeof(M.m));
  int i, j;
  for (i = k + 3, j = 2; i <= (k << 1) + 3; ++i, ++j) M.m[i][j] = 1LL;
  for (i = 0; i <= k; ++i) {
    for (j = 0; j <= i; ++j) M.m[k + 2 - i][k + 2 - j] = cmb[i][j];
  }
  for (i = 0; i <= k; ++i) {
    long long pow2 = 1LL;
    for (j = i; j >= 0; --j) {
      M.m[k + 2 - i][(k << 1) + 3 - j] = cmb[i][j] * pow2 % MOD;
      pow2 <<= 1;
      if (pow2 >= MOD) pow2 -= MOD;
    }
  }
  memcpy(M.m[1], M.m[2], sizeof(M.m[1]));
  M.m[1][1] = 1LL;
}
matrix mul_mod(matrix a, matrix b) {
  int n = a.n;
  long long INF = (long long)(7.5e18);
  matrix ans(n);
  int i, j, k;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) {
      for (k = 1; k <= n; ++k) {
        ans.m[i][j] += a.m[i][k] * b.m[k][j];
        if (ans.m[i][j] >= INF || k == n) ans.m[i][j] %= MOD;
      }
    }
  return ans;
}
matrix pow_mod(matrix a, long long b) {
  int n = a.n;
  matrix ans(n);
  ans.unit();
  while (b) {
    if (b & 1) ans = mul_mod(ans, a);
    b >>= 1;
    a = mul_mod(a, a);
  }
  return ans;
}
int main() {
  int i, j;
  scanf("%I64d%d", &n, &k);
  for (i = 1; i <= k; ++i) cmb[i][0] = 1LL;
  for (i = 1; i <= k; ++i)
    for (j = 1; j <= i; ++j) {
      cmb[i][j] = cmb[i - 1][j - 1] + cmb[i - 1][j];
      if (cmb[i][j] >= MOD) cmb[i][j] -= MOD;
    }
  M.n = (k << 1) + 3;
  if (n == 1LL) {
    puts("1");
    return 0;
  }
  init();
  M = pow_mod(M, n - 1);
  long long ans = M.m[1][(k << 1) + 3] % MOD;
  for (i = 1; i <= k + 2; ++i) ans += M.m[1][i];
  printf("%I64d\n", ans % MOD);
  return 0;
}