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 N = 84;
long long a[N][N], e[N][N];
long long t;
int k, n;
const long long mod = 1e9 + 7;
void mult(long long a[N][N], long long b[N][N]) {
  long long c[N][N] = {0};
  int i, j, k;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (a[i][j])
        for (k = 0; k < n; k++) {
          c[i][k] += a[i][j] * b[j][k] % mod;
          c[i][k] %= mod;
        }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) a[i][j] = c[i][j];
}
long long C[N][N];
long long tp[N];
int main() {
  int i, j;
  for (i = 0; i < N; i++) {
    C[i][0] = C[i][i] = 1;
    for (j = 1; j < i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
  }
  cin >> t >> k;
  n = k * 2 + 3;
  if (t == 1) {
    puts("1");
    return 0;
  }
  t--;
  tp[k] = 2;
  for (i = k - 1; i >= 0; i--) tp[i] = tp[i + 1] * 2 % mod;
  tp[n - 1] = tp[n - 2] = 1;
  for (i = n - 3; i > k; i--) tp[i] = tp[i + 1] * 2 % mod;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) e[i][j] = (i == j);
  for (i = 0; i <= k; i++)
    for (j = i; j <= k; j++)
      a[j][i] = a[j + k + 1][i] = a[j][i + k + 1] = C[k - i][k - j];
  a[0][n - 1] = a[n - 1][n - 1] = 1;
  while (t > 0) {
    if (t & 1) mult(e, a);
    mult(a, a);
    t >>= 1;
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    ans += tp[i] * e[i][n - 1] % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}