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 MOD = 1e9 + 7;
long long N, K, c[45][45], pow2[45];
long long C(long long x, long long y) {
  if (y == 0) return 1;
  if (x < y) return 0;
  if (c[x][y]) return c[x][y];
  return c[x][y] = (C(x - 1, y) + C(x - 1, y - 1)) % MOD;
}
struct Matrix {
  long long z[90][90];
  Matrix operator*(Matrix T) {
    Matrix RES;
    memset(RES.z, 0, sizeof(RES.z));
    for (long long i = 1; i <= 2 * K + 3; i++)
      for (long long j = 1; j <= 2 * K + 3; j++)
        for (long long k = 1; k <= 2 * K + 3; k++)
          RES.z[i][j] += z[i][k] * T.z[k][j], RES.z[i][j] %= MOD;
    return RES;
  }
} BASE;
Matrix quickMul(Matrix X, long long num) {
  if (num == 1) return X;
  Matrix T = quickMul(X, num >> 1);
  return (num & 1) ? T * T * X : T * T;
}
int main() {
  scanf("%lld%lld", &N, &K);
  if (N == 1) {
    printf("1");
    return 0;
  }
  pow2[0] = 1;
  for (long long i = 1; i < 45; i++) pow2[i] = pow2[i - 1] * 2 % MOD;
  memset(BASE.z, 0, sizeof(BASE.z));
  BASE.z[1][1] = 1;
  for (long long j = 2; j <= K + 2; j++) BASE.z[1][j] = C(K, j - 2);
  for (long long j = K + 3; j <= 2 * K + 3; j++)
    BASE.z[1][j] = C(K, j - (K + 3)) * pow2[K - (j - (K + 3))];
  for (long long i = 2; i <= K + 2; i++)
    for (long long j = 2; j <= i; j++) BASE.z[i][j] = C(i - 2, j - 2);
  for (long long i = 2; i <= K + 2; i++)
    for (long long j = K + 3; j <= i + K + 1; j++)
      BASE.z[i][j] = C(i - 2, j - (K + 3)) * pow2[i - 2 - (j - (K + 3))] % MOD;
  for (long long i = K + 3; i <= 2 * K + 3; i++) BASE.z[i][i - K - 1] = 1;
  BASE = quickMul(BASE, N - 1);
  long long ans = 0;
  for (long long j = 1; j <= K + 3; j++) ans += BASE.z[1][j], ans %= MOD;
  printf("%lld", ans);
  return 0;
}