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;
namespace Tzh {
const long long p = 1e9 + 7;
long long n, m, k, ans, c[110][110];
struct Matrix {
  long long g[110][110];
  void init() { memset(g, 0, sizeof(g)); }
  Matrix operator*(const Matrix &b) const {
    Matrix tmp;
    tmp.init();
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++)
        for (int k = 1; k <= m; k++)
          tmp.g[i][j] = (tmp.g[i][j] + g[i][k] * b.g[k][j] % p) % p;
    return tmp;
  }
};
Matrix qpow(Matrix a, long long b) {
  Matrix tmp;
  tmp.init();
  for (int i = 1; i <= m; i++) tmp.g[i][i] = 1;
  while (b) {
    if (b & 1) tmp = tmp * a;
    a = a * a;
    b >>= 1;
  }
  return tmp;
}
void work() {
  scanf("%lld%lld", &n, &k);
  m = 2 * k + 3;
  c[0][0] = 1;
  for (int i = 1; i <= k; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= k; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;
  }
  Matrix a;
  a.init();
  a.g[1][1] = 1;
  for (int i = 2; i <= m; i += 2)
    for (int j = i; j <= m; j += 2)
      a.g[i][j] = a.g[i][j + 1] = a.g[i + 1][j] = c[k - i / 2 + 1][(j - i) / 2];
  for (int i = 2; i <= m; i++) a.g[1][i] = a.g[2][i];
  a = qpow(a, n - 1);
  for (int i = 1; i <= m; i++) ans = (ans + a.g[1][i]) % p;
  printf("%lld", ans);
  return;
}
}  // namespace Tzh
int main() {
  Tzh::work();
  return 0;
}