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;
struct Mat {
  long long n, m, a[((long long)90)][((long long)90)];
  Mat() {
    for (int i = 0; i < ((long long)90); i++)
      for (int j = 0; j < ((long long)90); j++) a[i][j] = 0;
  }
  Mat operator*(Mat B) {
    Mat ex;
    ex.n = n;
    ex.m = B.m;
    for (int k = 0; k < m; k++)
      for (int i = 0; i < ex.n; i++)
        for (int j = 0; j < ex.m; j++)
          ex.a[i][j] += (a[i][k] * B.a[k][j]),
              ex.a[i][j] %= ((long long)1e9 + 7);
    return ex;
  }
  Mat operator^(long long val) {
    Mat ex;
    ex.n = n;
    ex.m = m;
    for (int i = 0; i < n; i++) ex.a[i][i] = 1;
    Mat now = (*this);
    while (val) {
      if (val % 2) ex = ex * now;
      now = now * now;
      val /= 2;
    }
    return ex;
  }
};
long long n, k, tvn2[((long long)90)], c[((long long)90)][((long long)90)];
Mat res, ans;
int main() {
  cin >> n >> k;
  tvn2[0] = 1;
  for (int i = 1; i < ((long long)90); i++)
    tvn2[i] = (tvn2[i - 1] * 2) % ((long long)1e9 + 7);
  for (int i = 0; i < ((long long)90); i++) c[i][0] = c[i][i] = 1;
  for (int i = 1; i < ((long long)90); i++)
    for (int j = 1; j < i; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % ((long long)1e9 + 7);
  res.n = res.m = 83;
  for (int i = 41; i <= 81; i++) res.a[i][i - 41] = 1;
  for (int i = 0; i <= 40; i++) {
    for (int j = 0; j <= i; j++) res.a[i][j] = c[i][j];
    for (int j = 0; j <= i; j++)
      res.a[i][j + 41] = (tvn2[i - j] * c[i][j]) % ((long long)1e9 + 7);
  }
  res.a[82][82] = res.a[82][k] = 1;
  ans.n = 83;
  ans.m = 1;
  for (int i = 0; i <= 41; i++) ans.a[i][0] = 1;
  ans.a[82][0] = 1;
  res = res ^ n;
  ans = res * ans;
  cout << (ans.a[82][0] - 1 + ((long long)1e9 + 7)) % ((long long)1e9 + 7)
       << "\n";
  return 0;
}