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;
int k, n, C[90][90];
long long m;
struct mat {
  long long a[90][90];
  mat() { memset(a, 0, sizeof(a)); }
  mat operator*(const mat &b) const {
    mat tmp;
    for (int i = 0; i < (n); i++)
      for (int j = 0; j < (n); j++)
        for (int k = 0; k < (n); k++)
          tmp.a[i][j] =
              (tmp.a[i][j] + (long long)a[i][k] * b.a[k][j]) % 1000000007;
    return tmp;
  }
  inline void print() {
    for (int i = 0; i < n; i++, puts(""))
      for (int j = 0; j < (n); j++) printf("%d ", a[i][j]);
  }
};
inline long long _pow(long long a, long long b) {
  long long tmp = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) tmp = tmp * a % 1000000007;
    a = a * a % 1000000007;
  }
  return tmp;
}
inline void R(int &xx) {
  xx = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
}
inline void R(long long &xx) {
  xx = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
}
inline mat _pow(mat a, long long b) {
  mat tmp;
  for (int i = 0; i < (n); i++) tmp.a[i][i] = 1;
  for (; b; b >>= 1) {
    if (b & 1) tmp = tmp * a;
    a = a * a;
  }
  return tmp;
}
inline void add(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
inline void dec(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
}
int main() {
  R(m);
  R(k);
  n = k * 2 + 3;
  for (int i = 0; i <= (k); i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j <= (i - 1); j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;
  }
  mat a;
  a.a[n - 1][k] = a.a[n - 1][n - 1] = 1;
  for (int i = 0; i <= (k); i++)
    for (int j = 0; j <= (i); j++)
      a.a[i][j] = a.a[i + k + 1][j] = a.a[i][j + k + 1] = C[i][j];
  a = _pow(a, m);
  int ans = 0;
  for (int i = 0; i < (n - 1); i++) add(ans, (int)a.a[n - 1][i]);
  printf("%d\n", ans);
  return 0;
}