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 mx = 90;
const long long int mod = 1e9 + 7;
long long int cmb[mx][mx];
struct matrix {
  long long int d[mx][mx];
  int s;
  matrix(int s) : s(s) { memset(d, 0, sizeof d); }
  void identity() {
    for (int i = 0; i < s; i++) d[i][i] = 1;
  }
  matrix operator*(matrix a) {
    matrix ans(s);
    for (int i = 0; i < s; i++) {
      for (int j = 0; j < s; j++) {
        ans.d[i][j] = 0;
        for (int k = 0; k < s; k++) {
          ans.d[i][j] += d[i][k] * a.d[k][j];
          ans.d[i][j] %= mod;
        }
      }
    }
    return ans;
  }
};
matrix fexp(matrix base, long long int expo) {
  matrix ans(base.s);
  ans.identity();
  while (expo != 0) {
    if (expo % 2 == 1) {
      ans = ans * base;
    }
    base = base * base;
    expo >>= 1;
  }
  return ans;
}
int main() {
  cmb[0][0] = 1;
  for (int i = 1; i < mx; i++) {
    cmb[i][0] = cmb[i][i] = 1;
    for (int j = 1; j < i; j++) {
      cmb[i][j] = (cmb[i - 1][j - 1] + cmb[i - 1][j]) % mod;
    }
  }
  long long int n;
  int k;
  cin >> n >> k;
  int side = 2 * k + 3;
  matrix m(side);
  m.d[0][0] = 1;
  for (int i = 1; i < k + 2; i++) m.d[i][0] = cmb[k][i - 1];
  for (int i = 1; i < 2 * k + 3; i++) {
    int q = (i - 1) % (k + 1);
    for (int j = 0; j <= k - q; j++) {
      m.d[i][k + 1 - j] = cmb[k - j][q];
    }
  }
  for (int i = 1; i < k + 2; i++) {
    for (int j = k + 2; j < 2 * k + 3; j++) {
      m.d[i][j] = m.d[i][j - (k + 1)];
    }
  }
  matrix base(side);
  base.d[0][0] = 1;
  base.d[0][1] = 2;
  for (int i = 2; i <= k + 1; i++) base.d[0][i] = (base.d[0][i - 1]) % mod;
  base.d[0][k + 2] = 1;
  for (int i = k + 3; i <= 2 * k + 2; i++)
    base.d[0][i] = (base.d[0][i - 1]) % mod;
  matrix e = fexp(m, n - 1);
  matrix ans = base * e;
  long long int resp = ans.d[0][0];
  cout << resp << endl;
  return 0;
}