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 N, MOD;
struct mat {
  long long m[90][90];
  void clear() { memset(m, 0, sizeof m); }
  void unit() {
    clear();
    for (long long i = 0; i < N; i++) m[i][i] = 1;
  }
  void copy(mat x) {
    for (long long i = 0; i < N; i++)
      for (long long j = 0; j < N; j++) m[i][j] = x[i][j];
  }
  long long *operator[](long long r) { return m[r]; }
};
mat operator*(mat a, mat b) {
  mat c;
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < N; j++) {
      c[i][j] = 0;
      for (long long k = 0; k < N; k++) {
        c[i][j] += (a[i][k] * b[k][j]) % MOD;
        c[i][j] %= MOD;
      }
    }
  return c;
}
mat operator+(mat a, mat b) {
  mat c;
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < N; j++) {
      c[i][j] = (a[i][j] + b[i][j]) % MOD;
    }
  return c;
}
long long n, k, y[50][50];
void yanghui_init() {
  memset(y, -1, sizeof y);
  for (long long i = 0; i <= k; i++)
    for (long long j = 0; j <= i; j++) {
      if (i == j || j == 0)
        y[i][j] = 1;
      else {
        y[i][j] = y[i - 1][j] + y[i - 1][j - 1];
      }
    }
}
int main() {
  MOD = 1e9 + 7;
  cin >> n >> k;
  N = 1 + 2 * (k + 1);
  yanghui_init();
  mat base, res;
  base[0][0] = base[0][1] = 1;
  for (long long i = 1; i <= k + 1; i++) {
    for (long long j = i; j <= k + 1; j++) {
      base[i][j] = y[k + 1 - i][j - i];
    }
    for (long long j = i + k + 1; j < N; j++) {
      base[i][j] = base[i][j - k - 1];
    }
  }
  for (long long i = k + 2; i < N; i++) {
    for (long long j = i - k - 1; j <= k + 1; j++) {
      base[i][j] = y[2 * k + 2 - i][j - (i - k - 1)];
    }
  }
  res.unit();
  long long A[N];
  A[0] = 1;
  A[k + 1] = 2;
  A[N - 1] = 1;
  for (long long i = k; i >= 1; i--) {
    A[i] = (2 * A[i + 1]) % MOD;
  }
  for (long long i = N - 2; i >= k + 2; i--) {
    A[i] = (2 * A[i + 1]) % MOD;
  }
  if (n == 0)
    cout << "0\n";
  else {
    n--;
    while (n) {
      if (n & 1LL) res = res * base;
      base = base * base;
      n /= 2;
    }
    long long ans = 0;
    for (long long i = 0; i < N; i++) {
      ans += (A[i] * res[0][i]) % MOD;
      ans %= MOD;
    }
    cout << ans << endl;
  }
  return 0;
}