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;
void add(int &a, int b) {
  a += b;
  if (a < 0) a += mod;
  a %= mod;
}
struct matrix {
  int e[85][85];
  int n, m;
  matrix() {}
  matrix(int _n, int _m) : n(_n), m(_m) { memset(e, 0, sizeof(e)); }
  matrix operator*(const matrix &temp) const {
    matrix ret = matrix(n, temp.m);
    for (int i = 1; i <= ret.n; i++) {
      for (int j = 1; j <= ret.m; j++) {
        for (int k = 1; k <= m; k++) {
          add(ret.e[i][j], 1LL * e[i][k] * temp.e[k][j] % mod);
        }
      }
    }
    return ret;
  }
  matrix operator+(const matrix &temp) const {
    matrix ret = matrix(n, m);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        add(ret.e[i][j], (e[i][j] + temp.e[i][j]) % mod);
      }
    }
    return ret;
  }
  void getE() {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        e[i][j] = i == j ? 1 : 0;
      }
    }
  }
};
matrix qpow(matrix temp, long long x) {
  int sz = temp.n;
  matrix base = matrix(sz, sz);
  base.getE();
  while (x) {
    if (x & 1) base = base * temp;
    x >>= 1;
    temp = temp * temp;
  }
  return base;
}
void print(matrix p) {
  int n = p.n;
  int m = p.m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", p.e[i][j]);
    }
    cout << endl;
  }
}
int c[50][50];
void init() {
  c[0][0] = c[1][0] = c[1][1] = 1;
  for (int i = 2; i <= 40; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
  }
}
int main() {
  init();
  long long n;
  int k;
  cin >> n >> k;
  int st = 1;
  matrix ans = matrix(1 + 2 * (k + 1), 1);
  for (int i = 1; i <= 3 + 2 * k; i++) ans.e[i][1] = 1;
  matrix temp = matrix(3 + 2 * k, 3 + 2 * k);
  temp.e[1][1] = 1;
  for (int i = 2; i <= k + 1 + 1; i++) temp.e[1][i] = c[k][i - 2];
  for (int i = k + 3; i <= 2 * k + 3; i++) temp.e[1][i] = c[k][i - (k + 3)];
  for (int i = 2; i <= k + 2; i++) {
    for (int j = 0; j <= i - 2; j++) temp.e[i][j + 2] = c[i - 2][j];
    for (int j = 0; j <= i - 2; j++) temp.e[i][j + k + 3] = c[i - 2][j];
  }
  for (int i = k + 3; i <= 2 * k + 3; i++) {
    for (int j = 0; j <= i - (k + 3); j++) temp.e[i][j + 2] = c[i - (k + 3)][j];
  }
  if (n == 1) {
    puts("1");
    return 0;
  }
  temp = qpow(temp, n - 1);
  ans = temp * ans;
  cout << ans.e[1][1] << endl;
}