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 ll = long long;
const int M = 83, MOD = 1e9 + 7, L = 41, LIMIT = 63;
struct _mt {
  int m[M][M], n;
  void E() {
    for (int i = 0; i < n; i++) m[i][i] = 1;
  }
  void rs(int n) {
    this->n = n;
    memset(m, 0, sizeof m);
  }
  _mt operator*(const _mt& o) {
    _mt r;
    r.rs(n);
    int i, j, k;
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++)
        for (k = 0; k < n; k++)
          r.m[i][j] = (r.m[i][j] + (ll)m[i][k] * o.m[k][j] % MOD) % MOD;
    return r;
  }
} P[LIMIT], X;
int main() {
  ll n;
  int i, j, k, A0[M], nCr[L][L] = {}, ans = 0;
  scanf("%lld%d", &n, &k);
  nCr[0][0] = 1;
  for (i = 1; i <= k; i++) {
    nCr[i][0] = 1;
    for (j = 1; j <= i; j++)
      nCr[i][j] = (nCr[i - 1][j - 1] + nCr[i - 1][j]) % MOD;
  }
  P[0].rs(2 * k + 2 + 1);
  for (i = 1; i <= 2 * k + 2; i++)
    A0[i] = i <= k + 1 ? ((1LL << (k + 2 - i)) % MOD) : 1;
  A0[0] = 1;
  P[0].m[0][1] = P[0].m[0][0] = 1;
  for (i = k + 2; i <= 2 * k + 2; i++) P[0].m[i][i - k - 2 + 1] = 1;
  for (i = 0; i <= k; i++)
    for (j = i; j <= k; j++) {
      P[0].m[i + 1][j + 1] = nCr[k - i][k - j];
      P[0].m[i + 1][j + k + 2] =
          nCr[k - i][k - j] * ((1LL << (j - i)) % MOD) % MOD;
    }
  for (i = 1; i < LIMIT; i++) P[i] = P[i - 1] * P[i - 1];
  X.rs(2 * k + 2 + 1);
  X.E();
  n--;
  for (i = 0; i < LIMIT; i++)
    if ((1LL << i) & n) X = X * P[i];
  for (i = 0; i <= 2 * k + 2; i++)
    ans = (ans + (ll)X.m[0][i] * A0[i] % MOD) % MOD;
  printf("%d", ans);
  return 0;
}