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>
class Matrix {
 public:
  int N;
  int matrix[87][87];
  Matrix(int n) { N = n; }
  void setVal(int array[][87]) {
    int i, j;
    for (i = 0; i < N; ++i) {
      for (j = 0; j < N; ++j) matrix[i][j] = array[i][j] % 1000000007;
    }
  }
  Matrix operator*(Matrix &A) {
    Matrix ret(N);
    int i, j, k;
    for (i = 0; i < N; ++i) {
      for (j = 0; j < N; ++j) {
        ret.matrix[i][j] = 0;
        for (k = 0; k < N; ++k) {
          ret.matrix[i][j] +=
              ((long long)matrix[i][k] * A.matrix[k][j]) % 1000000007;
          ret.matrix[i][j] %= 1000000007;
        }
      }
    }
    return ret;
  }
  void printMatrix() {
    int i, j;
    puts("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    for (i = 0; i < N; ++i) {
      for (j = 0; j < N; ++j) printf("%3d ", matrix[i][j]);
      puts("");
    }
    puts("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  }
} base(87), ret(87);
Matrix bigmod(long long K) {
  if (K == 1) return base;
  if (K % 2) {
    ret = bigmod(K - 1);
    ret = ret * base;
    return ret;
  }
  ret = bigmod(K / 2);
  ret = ret * ret;
  return ret;
}
int temp[87][87];
void prep(int K) {
  memset(temp, 0, sizeof(temp));
  int i, j;
  temp[0][0] = 1;
  for (i = 2 * K + 1; i > 0; i -= 2) {
    temp[i + 1][2 * K + 1] = temp[i][2 * K + 2] = temp[i][2 * K + 1] = 1;
    for (j = 2 * K - 1; j > 0; j -= 2)
      temp[i + 1][j] = temp[i][j] = temp[i][j + 1] =
          (temp[i + 2][j] + temp[i + 2][j + 2]) % 1000000007;
  }
  for (j = 1; j <= 2 * K + 2; ++j) temp[0][j] = temp[1][j];
}
int main() {
  int K;
  long long N;
  while (scanf("%I64d %d", &N, &K) != EOF) {
    prep(K);
    base.N = ret.N = 2 * K + 3;
    base.setVal(temp);
    Matrix ans = bigmod(N);
    printf("%d\n", ans.matrix[0][2 * K + 1]);
  }
  return 0;
}