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;
long long C[55][55];
long long** step;
long long n, k;
inline void init() {
  for (int i = 0; i < 50; ++i)
    for (int j = 0; j < 50; ++j)
      if (!j)
        C[i][j] = 1;
      else if (!i)
        C[i][j] = 0;
      else
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % 1000000007;
}
long long** matrixMul(long long** A, long long** B, int siz) {
  long long** ret = new long long*[siz + 2];
  for (int i = 0; i < siz; ++i) {
    ret[i] = new long long[siz + 2];
    for (int j = 0; j < siz; ++j) {
      ret[i][j] = 0;
      for (int k = 0; k < siz; ++k) {
        ret[i][j] += A[i][k] * B[k][j];
        ret[i][j] %= 1000000007;
      }
    }
  }
  return ret;
}
long long** matrixExpo(long long exp, int siz) {
  if (!exp) {
    long long** ret = new long long*[siz + 2];
    for (int i = 0; i < siz; ++i) ret[i] = new long long[siz + 2];
    for (int i = 0; i < siz; ++i)
      for (int j = 0; j < siz; ++j)
        if (i == j)
          ret[i][j] = 1;
        else
          ret[i][j] = 0;
    return ret;
  }
  long long** A = matrixExpo(exp >> 1, siz);
  long long** B = matrixMul(A, A, siz);
  if (exp & 1) {
    long long** C = matrixMul(B, step, siz);
    return C;
  }
  return B;
}
int main() {
  init();
  scanf("%I64d%I64d", &n, &k);
  int siz = (k << 1) + 3;
  step = new long long*[siz];
  for (int i = 0; i < siz; ++i) step[i] = new long long[siz];
  for (int i = 0; i < siz; ++i)
    for (int j = 0; j < siz; ++j) step[i][j] = 0;
  for (int i = 0; i < k + 1; ++i)
    for (int j = i; j < k + 1; ++j) step[i][j] = C[k - i][j - i];
  for (int i = 0; i < k + 1; ++i)
    for (int j = k + i + 1; j < siz - 1; ++j)
      step[i][j] = C[k - i][j - (k + i + 1)];
  for (int i = k + 1; i < siz - 1; ++i)
    for (int j = i - (k + 1); j < k + 1; ++j)
      step[i][j] = C[siz - 2 - i][j - i + k + 1];
  step[siz - 1][0] = step[siz - 1][siz - 1] = 1;
  long long** A = matrixExpo(n, siz);
  long long ans = 0;
  for (int i = 0; i < siz - 1; ++i) ans += A[siz - 1][i];
  ans %= 1000000007;
  printf("%I64d", ans);
  return 0;
}