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;
int x[85][85], k;
long long nn;
int n;
int c[85][85];
int d[85];
void mmul(int r[85][85], int a[85][85], int b[85][85]) {
  int t[85][85];
  memset(t, 0, sizeof(t));
  for (int i = 0, ThxDem = n; i < ThxDem; ++i)
    for (int j = 0, ThxDem = n; j < ThxDem; ++j)
      for (int k = 0, ThxDem = n; k < ThxDem; ++k)
        t[i][j] += 1LL * a[i][k] * b[k][j] % 1000000007, t[i][j] %= 1000000007;
  memcpy(r, t, sizeof(t));
}
void mexp(int r[85][85], int x[85][85], long long e) {
  int a[85][85], t[85][85];
  memcpy(a, x, sizeof(a));
  memset(t, 0, sizeof(t));
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) t[i][i] = 1;
  while (e) {
    if (e & 1) mmul(t, t, a);
    e >>= 1;
    mmul(a, a, a);
  }
  memcpy(r, t, sizeof(t));
}
int main() {
  for (int i = 0, ThxDem = 85; i < ThxDem; ++i) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1, ThxDem = i; j < ThxDem; ++j)
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007;
  }
  scanf("%lld%d", &nn, &k);
  n = 2 * k + 3;
  x[2 * k + 2][2 * k + 2] = x[2 * k + 2][k] = 1;
  for (int i = 0, ThxDem = k + 1; i < ThxDem; ++i) {
    x[i + k + 1][i] = 1;
    memset(d, 0, sizeof(d));
    d[i] = 1;
    for (int j = i; j >= 0; --j) {
      x[i][j] = d[j];
      int p = 1;
      for (int l = j - 1; l >= 0; --l) {
        p = (1LL * p * (1000000007 - 1)) % 1000000007;
        d[l] +=
            1000000007 - (1LL * p * c[j][l]) % 1000000007 * d[j] % 1000000007;
        d[l] %= 1000000007;
      }
    }
    memset(d, 0, sizeof(d));
    d[i] = 1;
    for (int j = i; j >= 0; --j) {
      x[i][j + k + 1] = d[j];
      int p = 1;
      for (int l = j - 1; l >= 0; --l) {
        p = (1LL * p * (1000000007 - 2)) % 1000000007;
        d[l] +=
            1000000007 - (1LL * p * c[j][l]) % 1000000007 * d[j] % 1000000007;
        d[l] %= 1000000007;
      }
    }
  }
  mexp(x, x, nn);
  int r = 0;
  for (int i = 0, ThxDem = k + 2; i < ThxDem; ++i)
    r += x[2 * k + 2][i], r %= 1000000007;
  printf("%d\n", r);
  return 0;
}