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 int mat[85][85];
long long int pas1[46][46];
long long int pas2[46][46];
long long int cur[85][85];
long long int c[85][85];
int sz;
long long int add(long long int a, long long int b) {
  return (a + b) % 1000000007;
}
void mult(long long int a[][85], long long int b[][85]) {
  int i, j, k;
  for (i = 0; i <= sz; i++) {
    for (j = 0; j <= sz; j++) {
      c[i][j] = 0;
      for (k = 0; k <= sz; k++) {
        c[i][j] = add(c[i][j], a[i][k] * b[k][j]);
      }
    }
  }
  for (i = 0; i <= sz; i++) {
    for (j = 0; j <= sz; j++) a[i][j] = c[i][j];
  }
}
void modexp(long long int x) {
  while (x) {
    if ((x & 1)) mult(cur, mat);
    mult(mat, mat);
    x >>= 1;
  }
}
int main() {
  int i;
  long long int n, k;
  cin >> n >> k;
  k++;
  for (i = k; i < 2 * k; i++) {
    mat[i][i - k] = 1;
  }
  pas1[0][0] = 1;
  pas2[0][0] = 1;
  for (i = 1; i <= 45; i++) {
    pas1[i][0] = 1;
    pas2[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      pas1[i][j] = add(pas1[i - 1][j], pas1[i - 1][j - 1]);
      pas2[i][j] = add(pas2[i - 1][j - 1] * 2, pas2[i - 1][j]);
    }
  }
  for (i = 0; i < k; i++) {
    for (int j = i; j < k; j++) {
      mat[i][j] = pas1[k - i - 1][j - i];
    }
    for (int j = i + k; j < 2 * k; j++) {
      mat[i][j] = pas2[k - i - 1][j - i - k];
    }
  }
  for (i = 0; i <= 2 * k; i++) {
    cur[i][i] = 1;
  }
  sz = 2 * k;
  mat[2 * k][2 * k] = 1;
  mat[2 * k][0] = 1;
  modexp(n);
  long long int ans = 0;
  for (i = 0; i < k; i++) {
    ans = add(ans, cur[sz][i]);
  }
  ans = add(ans, cur[sz][sz - 1]);
  cout << ans << endl;
  return 0;
}