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;
long long n, t2[1][85], t1[85][85], c[85][85], tmp[85];
int K, tot, P = 1000000007;
struct ma1 {
  long long a[85][85];
  void Mul(long long b[85][85]) {
    for (int i = 0; i < tot; i++)
      for (int j = 0; j < tot; j++) t1[i][j] = 0;
    for (int i = 0; i < tot; i++)
      for (int j = 0; j < tot; j++)
        for (int k = 0; k < tot; k++)
          t1[i][k] = (t1[i][k] + a[i][j] * b[j][k] % P) % P;
    for (int i = 0; i < tot; i++)
      for (int j = 0; j < tot; j++) a[i][j] = t1[i][j];
  }
} T;
struct ma2 {
  long long a[1][85];
  void Mul(long long b[85][85]) {
    for (int i = 0; i < 1; i++)
      for (int j = 0; j < tot; j++) t2[i][j] = 0;
    for (int i = 0; i < 1; i++)
      for (int j = 0; j < tot; j++)
        for (int k = 0; k < tot; k++)
          t2[i][k] = (t2[i][k] + a[i][j] * b[j][k] % P) % P;
    for (int i = 0; i < 1; i++)
      for (int j = 0; j < tot; j++) a[i][j] = t2[i][j];
  }
} Ans;
long long Mul(int x, long long y) {
  long long ans = 1, tmp = x;
  while (y) {
    if (y & 1) ans = ans * tmp % P;
    tmp = tmp * tmp % P;
    y >>= 1;
  }
  return ans;
}
int main() {
  c[0][0] = 1;
  for (int i = 1; i <= 40; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % P;
  }
  scanf("%I64d%d", &n, &K);
  tot = (K + 1) * 2 + 1;
  long long s = 1;
  for (int i = 0; i <= K; i++) Ans.a[0][i] = 1;
  for (int i = K + 1; i <= K * 2 + 1; i++)
    Ans.a[0][i] = s * 2 % P, s = s * 2 % P;
  Ans.a[0][K * 2 + 2] = 1;
  for (int i = 0; i <= K; i++) T.a[i + K + 1][i] = 1;
  for (int j = K + 1; j <= K * 2 + 1; j++) {
    for (int i = K + 1; i <= j; i++) T.a[i][j] = c[j - K - 1][i - K - 1];
    for (int i = 0; i <= K; i++) tmp[i] = 0;
    for (int i = j - K - 1; i >= 0; i--) {
      long long dlt = c[j - K - 1][i] - tmp[i];
      T.a[i][j] = dlt % P;
      int mk = 1;
      for (int k = i; k >= 0; k--)
        (tmp[k] += dlt * mk % P * c[i][k] % P) % P, mk *= -1;
    }
  }
  T.a[K * 2 + 1][K * 2 + 2] = T.a[K * 2 + 2][K * 2 + 2] = 1;
  n--;
  while (n) {
    if (n & 1) Ans.Mul(T.a);
    T.Mul(T.a);
    n >>= 1;
  }
  printf("%I64d\n", Ans.a[0][K * 2 + 2]);
  return 0;
}