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 INF = 0x3f3f3f3f;
const int E = 2;
const int MOD = 1e9 + 7;
struct Matrix {
  int row, column;
  long long **num;
  Matrix(int row, int column) : row(row), column(column) {
    num = new long long *[row];
    for (int i = 0; i < row; ++i) {
      num[i] = new long long[column];
      for (int j = 0; j < column; ++j) num[i][j] = 0;
    }
  }
  Matrix(int row, int column, long long **temp) : row(row), column(column) {
    num = new long long *[row];
    for (int i = 0; i < row; ++i) {
      num[i] = new long long[column];
      for (int j = 0; j < column; ++j) num[i][j] = temp[i][j];
    }
  }
  Matrix(const Matrix &temp) : row(temp.row), column(temp.column) {
    num = new long long *[row];
    for (int i = 0; i < row; ++i) {
      num[i] = new long long[column];
      for (int j = 0; j < column; ++j) num[i][j] = temp.num[i][j];
    }
  }
  Matrix operator*(Matrix temp) {
    Matrix res(row, temp.column);
    for (int i = 0; i < row; ++i)
      for (int k = 0; k < column; ++k)
        for (int j = 0; j < temp.column; ++j)
          res.num[i][j] = (res.num[i][j] + num[i][k] * temp.num[k][j]) % MOD;
    return res;
  }
  Matrix quickPow(long long x) {
    Matrix res(row, row);
    for (int i = 0; i < row; ++i) res.num[i][i] = 1;
    Matrix temp(row, row, num);
    while (x > 0) {
      if (x & 1) res = res * temp;
      temp = temp * temp;
      x >>= 1;
    }
    return res;
  }
  void display(int row, int column) {
    for (int i = 0; i < row; ++i)
      for (int j = 0; j < column; ++j)
        printf("%I64d%c", num[i][j], j == column - 1 ? '\n' : ' ');
  }
};
int main() {
  Matrix c(41, 41);
  for (int i = 0; i < 41; ++i)
    for (int j = 0; j <= i; ++j) {
      if (j == 0 || j == i)
        c.num[i][j] = 1;
      else
        c.num[i][j] = c.num[i - 1][j - 1] + c.num[i - 1][j];
      if (c.num[i][j] >= MOD) c.num[i][j] %= MOD;
    }
  long long n, x;
  cin >> n >> x;
  Matrix temp(3 + 2 * x, 3 + 2 * x);
  temp.num[0][0] = 1;
  for (int i = 1; i < 2 + x; ++i)
    temp.num[0][i] = temp.num[0][i + x + 1] = c.num[x][i - 1];
  for (int i = 1; i < 2 + x; ++i)
    for (int j = 1; j <= i; ++j)
      temp.num[i][j] = temp.num[i][j + 1 + x] = c.num[i - 1][j - 1];
  for (int i = 2 + x; i < 3 + 2 * x; ++i)
    for (int j = 1; j <= i - 1 - x; ++j)
      temp.num[i][j] = c.num[i - 2 - x][j - 1];
  Matrix ans(3 + 2 * x, 1);
  ans.num[0][0] = 1;
  for (int i = 1; i < 3 + 2 * x; ++i) ans.num[i][0] = 1;
  ans = temp.quickPow(n - 1) * ans;
  cout << ans.num[0][0] << endl;
  return 0;
}