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;
int a[100][100], tp[100][100];
int ans[100][100];
int m;
int f[100];
int c[100][100];
void multi(int a[100][100], int b[100][100], int c[100][100]) {
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      tp[i][j] = 0;
      for (int k = 1; k <= m; k++)
        tp[i][j] = (tp[i][j] + (long long)a[i][k] * b[k][j]) % 1000000007;
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) c[i][j] = tp[i][j];
  }
}
void pre() {
  f[0] = 1;
  for (int i = 1; i < 100; i++) f[i] = (long long)f[i - 1] * 2 % 1000000007;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j <= i; j++) {
      if (i == 0) {
        c[i][j] = 1;
        continue;
      }
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
      if (c[i][j] >= 1000000007) c[i][j] -= 1000000007;
    }
  }
}
int main() {
  pre();
  long long n;
  int k;
  scanf("%I64d%d", &n, &k);
  m = 2 * k + 3;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      if (i == j)
        ans[i][j] = 1;
      else
        ans[i][j] = 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      if (j == m) {
        if (i == m)
          a[i][j] = 1;
        else
          a[i][j] = 0;
        continue;
      }
      if (i == m) {
        if (j == 1 || j == m)
          a[i][j] = 1;
        else
          a[i][j] = 0;
        continue;
      }
      if (i > k + 1) {
        if (i - j == k + 1)
          a[i][j] = 1;
        else
          a[i][j] = 0;
        continue;
      }
      int ii = k + 1 - i;
      if (j <= k + 1 && j > k - ii) {
        a[i][j] = c[ii][k + 1 - j];
        continue;
      }
      if (j <= 2 * k + 2 && j > 2 * k + 2 - ii - 1) {
        a[i][j] = (long long)c[ii][2 * k + 2 - j] * f[ii - (2 * k + 2 - j)] %
                  1000000007;
        continue;
      }
    }
  }
  long long xx = n - 1;
  while (xx) {
    if (xx & 1) multi(ans, a, ans);
    multi(a, a, a);
    xx /= 2;
  }
  int res = 0;
  for (int i = 1; i <= m; i++) {
    if (i <= k + 1)
      res += (long long)ans[m][i] * f[k + 2 - i] % 1000000007;
    else
      res += ans[m][i];
    if (res >= 1000000007) res -= 1000000007;
  }
  printf("%d\n", res);
  return 0;
}