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>
const int maxk = 45;
const int MOD = 1e9 + 7;
long long n;
int k;
int C[maxk][maxk];
void inc(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
void init() {
  for (int i = 0; i < maxk; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++)
      inc(C[i][j], (C[i - 1][j - 1] + C[i - 1][j]) % MOD);
  }
}
struct Matrix {
  int mp[maxk << 1][maxk << 1];
  int size;
  Matrix(int s) { size = s; }
  void zero() {
    for (int i = 0; i < size; i++)
      for (int j = 0; j < size; j++) mp[i][j] = 0;
  }
  void one() {
    for (int i = 0; i < size; i++)
      for (int j = 0; j < size; j++) mp[i][j] = i == j;
  }
  Matrix operator*(const Matrix &A) const {
    Matrix ans(A.size);
    ans.zero();
    for (int i = 0; i < size; i++)
      for (int j = 0; j < size; j++)
        for (int k = 0; k < size; k++)
          inc(ans.mp[i][j], 1ll * mp[i][k] * A.mp[k][j] % MOD);
    return ans;
  }
};
Matrix pow_mod(Matrix a, long long b) {
  Matrix ans(a.size);
  ans.one();
  while (b) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
int solve() {
  Matrix res(2 * k + 3);
  res.zero();
  res.mp[0][0] = 1;
  for (int i = 0; i <= k; i++)
    res.mp[0][i + 1] = res.mp[0][k + 2 + i] = C[k][i];
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= i; j++)
      res.mp[i + 1][j + 1] = res.mp[i + 1][j + k + 2] =
          res.mp[i + k + 2][j + 1] = C[i][j];
  res = pow_mod(res, n - 1);
  int ans = 0;
  for (int i = 0; i < 2 * k + 3; i++) inc(ans, res.mp[0][i]);
  return ans;
}
int main() {
  init();
  while (~scanf("%I64d %d", &n, &k)) printf("%d\n", solve());
  return 0;
}