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;
long long c[500][500];
struct matrix {
  long long c[85][85];
  void operator~() {
    for (long long i = 1; i <= 2 * k + 4; i++) c[i][i] = 1;
  }
  matrix() { memset(c, 0, sizeof(c)); }
  matrix operator*(const matrix &a) {
    matrix r;
    for (long long i = 1; i <= 2 * k + 3; i++)
      for (long long j = 1; j <= 2 * k + 3; j++)
        for (long long t = 1; t <= 2 * k + 3; t++)
          r.c[i][j] = (r.c[i][j] + c[i][t] * a.c[t][j] % mod) % mod;
    return r;
  }
  void print() {
    for (long long i = 1; i <= 2 * k + 3; i++) {
      for (long long j = 1; j <= 2 * k + 3; j++) {
        printf("%d ", c[i][j]);
      }
      printf("\n");
    }
    printf("\n");
  }
} A, B;
matrix power(long long k) {
  matrix x, y;
  ~x, y = A;
  for (; k; k >>= 1) {
    if (k & 1) x = x * y;
    y = y * y;
  }
  return x;
}
signed main() {
  scanf("%lld%lld", &n, &k);
  for (long long i = 0; i < 500; i++) c[i][0] = 1;
  for (long long i = 1; i < 500; i++)
    for (long long j = 1; j < 500; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  for (long long i = 1; i <= k + 1; i++) B.c[1][i] = 1LL * (1LL << i - 1) % mod;
  for (long long i = k + 2; i <= k * 2 + 2; i++)
    B.c[1][i] = 2LL * (1LL << i - k - 2) % mod;
  B.c[1][k * 2 + 3] = 1LL;
  for (long long i = k + 2; i <= k * 2 + 2; i++) {
    for (long long j = 1; j <= k + 1; j++) {
      A.c[j][i] = c[i - k - 2][j - 1];
      A.c[j + k + 1][i] = c[i - k - 2][j - 1];
    }
  }
  for (long long i = 1; i <= k + 1; i++) {
    for (long long j = 1; j <= k + 1; j++) {
      A.c[j + k + 1][i] = c[i - 1][j - 1];
    }
  }
  A.c[k * 2 + 2][k * 2 + 3] = 1;
  A.c[k * 2 + 3][k * 2 + 3] = 1;
  matrix ans = B * power(n - 1);
  printf("%lld", ans.c[1][k * 2 + 3]);
}