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>
const long long MOD = 1000000007;
const int MAX_K = 45;
struct Matrix {
  long long a[MAX_K * 2][MAX_K * 2], n, m;
  Matrix(int _n = 0, int _m = 0) : n(_n), m(_m) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j) a[i][j] = 0;
  }
  void dw(int _n, int _m) {
    n = _n, m = _m;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j) a[i][j] = (i == j ? 1 : 0);
  }
  long long& operator()(int i, int j) { return a[i][j]; }
  void print() {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j)
        printf("%I64d%c", a[i][j], j == m ? '\n' : ' ');
  }
};
Matrix operator*(Matrix a, Matrix b) {
  Matrix res(a.n, b.m);
  for (int i = 1; i <= a.n; ++i)
    for (int j = 1; j <= b.m; ++j)
      for (int k = 1; k <= a.m; ++k) (res(i, j) += a(i, k) * b(k, j)) %= MOD;
  return res;
}
Matrix operator^(Matrix a, long long x) {
  Matrix res;
  res.dw(a.n, a.m);
  for (; x; a = a * a, x >>= 1)
    if (x & 1) res = res * a;
  return res;
}
long long pow2[MAX_K * 2];
long long c[MAX_K * 2][MAX_K * 2];
void getC(int x) {
  c[0][0] = 1;
  pow2[0] = 1;
  for (int i = 1; i <= x; ++i) {
    c[i][0] = 1;
    pow2[i] = (pow2[i - 1] * 2) % MOD;
    for (int j = 1; j <= i; ++j)
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
  }
}
long long n, k;
int main() {
  scanf("%I64d%I64d", &n, &k);
  getC(k);
  Matrix a(1, 2 * k + 3), dp(2 * k + 3, 2 * k + 3);
  for (int i = 1; i <= k + 1; ++i) a(1, i) = 2 * pow2[k - i + 1];
  for (int i = k + 2; i <= 2 * k + 2; ++i) a(1, i) = 1;
  a(1, 2 * k + 3) = 1;
  for (int i = 1; i <= k + 1; ++i)
    for (int j = 1; j <= i; ++j) dp(i, j) = c[k - j + 1][k - i + 1];
  for (int i = k + 2; i <= 2 * k + 2; ++i)
    for (int j = 1; j <= i - (k + 1); ++j)
      dp(i, j) = pow2[i - (k + 1) - 1 - (j - 1)] *
                 c[k - j + 1][k - (i - (k + 1)) + 1] % MOD;
  for (int i = k + 2; i <= 2 * k + 2; ++i) dp(i - (k + 1), i) = 1;
  dp(1, 2 * k + 3) = dp(2 * k + 3, 2 * k + 3) = 1;
  a = a * (dp ^ (n - 1));
  printf("%I64d\n", a(1, 2 * k + 3));
}