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 long long MAXN = 83;
const long long Mod = 1e9 + 7;
long long c[MAXN][MAXN];
long long b[MAXN][MAXN];
long long temp[MAXN][MAXN];
long long matrix[MAXN][MAXN];
long long v[MAXN];
long long res[MAXN];
void mult_to_matrix() {
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < MAXN; j++) {
      temp[i][j] = 0;
      for (long long u = 0; u < MAXN; u++) {
        temp[i][j] += matrix[i][u] * matrix[u][j];
        temp[i][j] %= Mod;
      }
    }
  }
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < MAXN; j++) {
      matrix[i][j] = temp[i][j];
    }
  }
}
void mult_to_b() {
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < MAXN; j++) {
      temp[i][j] = 0;
      for (long long u = 0; u < MAXN; u++) {
        temp[i][j] += matrix[i][u] * b[u][j];
        temp[i][j] %= Mod;
      }
    }
  }
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < MAXN; j++) {
      matrix[i][j] = temp[i][j];
    }
  }
}
void matrix_pw(long long n) {
  if (n == 1) {
    return;
  }
  matrix_pw(n / 2);
  mult_to_matrix();
  if (n & 1) {
    mult_to_b();
  }
}
void mult_to_res() {
  for (long long i = 0; i < MAXN; i++) {
    v[i] = 0;
    for (long long j = 0; j < MAXN; j++) {
      v[i] += res[j] * matrix[i][j];
      v[i] %= Mod;
    }
  }
  for (long long i = 0; i < MAXN; i++) {
    res[i] = v[i];
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j <= i; j++) {
      if (j == 0) {
        c[i][j] = 1;
      } else {
        c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
        c[i][j] %= Mod;
      }
    }
  }
  res[0] = 1;
  for (long long i = 0; i <= k; i++) {
    matrix[i][i + k + 1] = 1;
  }
  for (long long i = k + 1; i <= 2 * k + 1; i++) {
    res[i] = 1;
    for (long long j = k + 1; j <= 2 * k + 1; j++) {
      matrix[i][j] = c[i - k - 1][j - k - 1];
    }
    for (long long j = k + 1; j <= 2 * k + 1; j++) {
      for (long long u = 0; u <= k; u++) {
        matrix[i][u] += c[i - k - 1][j - k - 1] * c[j - k - 1][u];
        matrix[i][u] %= Mod;
      }
    }
  }
  matrix[2 * k + 2][2 * k + 2] = 1;
  matrix[2 * k + 2][2 * k + 1] = 1;
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < MAXN; j++) {
      b[i][j] = matrix[i][j];
    }
  }
  matrix_pw(n);
  mult_to_res();
  cout << res[2 * k + 2];
}