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 = 41, maxl = maxk * 2 + 1;
const long long mo = 1e9 + 7;
struct mat {
  long long a[maxl][maxl];
  void clear() { memset(a, 0, sizeof(a)); }
  mat operator*(const mat &t) const {
    mat ans;
    ans.clear();
    for (int i = 0; i < maxl; ++i)
      for (int j = 0; j < maxl; ++j)
        for (int k = 0; k < maxl; ++k) {
          ans.a[i][j] = (ans.a[i][j] + a[i][k] * t.a[k][j]) % mo;
        }
    return ans;
  }
} trans;
long long mpow(long long a, long long k) {
  long long ans = 1;
  for (; k > 0; k /= 2, a = a * a % mo)
    if (k % 2) ans = ans * a % mo;
  return ans;
}
mat mpow(mat a, long long k) {
  mat ans;
  ans.clear();
  for (int i = 0; i < maxl; ++i) ans.a[i][i] = 1;
  for (; k > 0; k /= 2, a = a * a)
    if (k % 2) ans = ans * a;
  return ans;
}
long long N, K, c[maxk + 1][maxk + 1];
void initC() {
  for (int i = 0; i <= maxk; ++i) c[i][i] = c[i][0] = 1;
  for (int i = 1; i <= maxk; ++i)
    for (int j = 1; j < i; ++j) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mo;
}
void initTrans() {
  auto &a = trans.a;
  for (int i = 0; i < maxk; ++i) a[i][i + maxk] = 1;
  for (int i = 0; i < maxk; ++i) {
    for (int j = 0; j <= i; ++j) {
      a[i + maxk][j + maxk] = c[i][j];
      a[i + maxk][j] = c[i][j] * mpow(2, i - j) % mo;
    }
  }
  memcpy(a[maxl - 1], a[maxk + K], sizeof(a[maxl - 1]));
  a[maxl - 1][maxl - 1] = (a[maxl - 1][maxl - 1] + 1) % mo;
}
long long row[maxl];
long long geneAns(const mat &final) {
  row[maxk] = 1;
  long long ans = 0;
  for (int i = 0; i < maxl; ++i)
    ans = (ans + final.a[maxl - 1][i] * row[i]) % mo;
  return ans;
}
int main() {
  scanf("%lld%lld", &N, &K);
  initC();
  initTrans();
  mat final = mpow(trans, N);
  printf("%lld\n", (geneAns(final) + mo) % mo);
  return 0;
}