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 N = 100 + 7;
const int M = 3;
const int inf = 1e9 + 7;
const long long base = 1e18;
const double pi = acos(-1);
const double ep = 1e-9;
struct matrix {
  long long a[N][N];
  int n, m;
  matrix(int _n, int _m) {
    n = _n;
    m = _m;
  }
  matrix operator*(matrix c) {
    matrix ans(n, c.m);
    for (int i = 1; i <= ans.n; i++) {
      for (int j = 1; j <= ans.m; j++) {
        long long tmp = 0;
        for (int k = (int)1; k < (int)m + 1; k++) {
          tmp = (tmp + a[i][k] * c.a[k][j] % inf) % inf;
        }
        ans.a[i][j] = tmp;
      }
    }
    return ans;
  }
  void print() {
    for (int i = (int)1; i < (int)n + 1; i++) {
      for (int j = (int)1; j < (int)m + 1; j++) cout << a[i][j] << " ";
      cout << endl;
    }
  }
};
long long C[N][N];
long long lt[2];
long long b[N][N];
long long tmp[N][N];
long long I[N][N];
void doub(int n) {
  for (int i = (int)1; i < (int)n + 1; i++) {
    for (int j = (int)1; j < (int)n + 1; j++) {
      tmp[i][j] = 0;
      for (int k = (int)1; k < (int)n + 1; k++)
        tmp[i][j] = (tmp[i][j] + b[i][k] * b[k][j]) % inf;
    }
  }
  for (int i = (int)1; i < (int)n + 1; i++)
    for (int j = (int)1; j < (int)n + 1; j++) b[i][j] = tmp[i][j];
}
void mul(int n) {
  for (int i = (int)1; i < (int)n + 1; i++) {
    for (int j = (int)1; j < (int)n + 1; j++) {
      tmp[i][j] = 0;
      for (int k = (int)1; k < (int)n + 1; k++)
        tmp[i][j] = (tmp[i][j] + I[i][k] * b[k][j]) % inf;
    }
  }
  for (int i = (int)1; i < (int)n + 1; i++)
    for (int j = (int)1; j < (int)n + 1; j++) I[i][j] = tmp[i][j];
}
int main() {
  C[0][0] = 1;
  lt[0] = 1;
  for (int i = (int)1; i < (int)N; i++) {
    lt[i] = ((long long)lt[i - 1] * 2) % inf;
    C[i][0] = C[i][i] = 1;
    for (int j = (int)1; j < (int)i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % inf;
  }
  long long n;
  int k;
  cin >> n >> k;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  int t = 2 * k + 3;
  long long ans[2][N];
  for (int u = (int)1; u < (int)k + 2; u++) {
    ans[1][u] = 1;
  }
  for (int i = (int)k + 2; i < (int)2 * k + 3; i++) {
    ans[1][i] = (long long)2 * lt[i - k - 2] % inf;
  }
  ans[1][2 * k + 3] = (1 + lt[k + 1]) % inf;
  for (int i = (int)1; i < (int)k + 2; i++) {
    b[k + 1 + i][i] = 1;
  }
  for (int i = (int)k + 2; i < (int)2 * k + 3; i++) {
    t = i - k - 2;
    if (t == 0) {
      b[1][i] = 1;
      b[k + 2][i] = 1;
    } else {
      for (int j = (int)0; j < (int)t + 1; j++) {
        b[j + 1][i] = lt[t - j] * C[t][j] % inf;
        b[j + 1 + k + 1][i] = C[t][j] % inf;
        if (t == k) {
          b[j + 1][i + 1] = b[j + 1][i];
          b[j + 1 + k + 1][i + 1] = b[j + 1 + k + 1][i];
        }
      }
    }
  }
  b[2 * k + 3][2 * k + 3] = 1;
  for (int i = (int)1; i < (int)2 * k + 4; i++) I[i][i] = 1;
  n -= 2;
  while (n > 0) {
    if (n & 1) {
      mul(2 * k + 3);
    }
    doub(2 * k + 3);
    n /= 2;
  }
  t = 2 * k + 3;
  for (int j = 1; j <= t; j++) {
    tmp[1][j] = 0;
    for (int k = 1; k <= t; k++)
      tmp[1][j] = (tmp[1][j] + ans[1][k] * I[k][j]) % inf;
  }
  cout << tmp[1][t];
}