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 mod = 1e9 + 7, MAXK = 88;
long long N;
int K, comb[MAXK][MAXK], power[MAXK], ar[MAXK][MAXK], ans[MAXK][MAXK],
    tmp[MAXK][MAXK];
inline void multiply(int A[MAXK][MAXK], int B[MAXK][MAXK]) {
  for (int i = 0; i <= K; i++)
    for (int j = 0; j <= K; j++) {
      tmp[i][j] = 0;
      for (int k = 0; k <= K; k++) {
        tmp[i][j] = tmp[i][j] + ((long long)A[i][k] * B[k][j]) % mod;
        if (tmp[i][j] >= mod) tmp[i][j] -= mod;
      }
    }
  for (int i = 0; i <= K; i++)
    for (int j = 0; j <= K; j++) A[i][j] = tmp[i][j];
}
int main() {
  scanf("%I64d%d", &N, &K);
  if (N == 1) {
    printf("1\n");
    return 0;
  }
  K = (K + 1) << 1;
  comb[0][0] = 1;
  for (int i = 1; i <= K; i++) {
    comb[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
      if (comb[i][j] >= mod) comb[i][j] -= mod;
    }
  }
  power[0] = 1;
  for (int i = 1; i <= K; i++) {
    power[i] = power[i - 1] << 1;
    if (power[i] >= mod) power[i] -= mod;
  }
  ar[K][K] = ar[K - 1][K] = 1;
  for (int i = 1; i <= K; i += 2) {
    for (int j = 0; j <= i; j++) {
      ar[j][i] = comb[i >> 1][j >> 1];
      if (!(j & 1))
        ar[j][i] = ((long long)ar[j][i] * power[(i - j) >> 1]) % mod;
    }
    ar[i][i - 1] = 1;
  }
  for (int i = 0; i <= K; i++) {
    ans[0][i] = (i & 1) ? power[(i >> 1) + 1] : 1;
  }
  N -= 2;
  while (N) {
    if (N & 1) multiply(ans, ar);
    N >>= 1;
    multiply(ar, ar);
  }
  printf("%d\n", (ans[0][K] + ans[0][K - 1]) % mod);
  return 0;
}