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 int mod = 1e9 + 7;
const int maxn = 100;
struct Matrix {
  int n, m;
  long long v[maxn][maxn];
  Matrix(int n, int m) : n(n), m(m) { init(); }
  void init() { memset(v, 0, sizeof(v)); }
  Matrix operator*(const Matrix B) const {
    Matrix C(n, B.m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < B.m; j++)
        for (int k = 0; k < m; k++)
          C.v[i][j] = (v[i][k] * B.v[k][j] % mod + C.v[i][j]) % mod;
    return C;
  }
};
long long k;
Matrix unit(maxn, maxn);
Matrix qpow(Matrix a, long long x) {
  Matrix ret = unit;
  while (x) {
    if (x & 1) ret = ret * a;
    a = a * a;
    x >>= 1;
  }
  return ret;
}
long long c[45][45];
int main() {
  c[0][0] = c[1][0] = c[1][1] = 1;
  for (int i = 2; i <= 40; i++) {
    for (int j = 0; j <= i; j++)
      if (j == i || j == 0)
        c[i][j] = 1;
      else
        c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  for (int i = 0; i < maxn; i++) unit.v[i][i] = 1;
  long long n;
  scanf("%lld%lld", &n, &k);
  Matrix left(2 * k + 3, 2 * k + 3), right(2 * k + 3, 1);
  left.v[0][0] = 1;
  for (int i = 1; i <= k + 1; i++)
    left.v[0][i] = left.v[0][i + k + 1] = c[k][i - 1];
  for (int i = 1; i <= k + 1; i++) {
    for (int j = 1; j <= i; j++) {
      left.v[i][j] = c[i - 1][j - 1];
      left.v[i][j + k + 1] = c[i - 1][j - 1];
      left.v[i + k + 1][j] = c[i - 1][j - 1];
    }
  }
  left = qpow(left, n - 1);
  long long ans = 0;
  for (int i = 0; i < left.m; i++) ans = (ans + left.v[0][i] % mod) % mod;
  printf("%lld\n", ans);
}