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;
char _;
const long long maxN = 80 + 5;
const long long maxM = 5000 + 5;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long base = 701;
const long long SQ = 500;
const long long maxL = 20;
long long c[maxN][maxN];
long long N;
struct Mat {
  long long a[maxN][maxN];
  Mat(long long fl = 0) {
    for (long long i = 0; i < N; i++)
      for (long long j = 0; j < N; j++)
        if (i == j)
          a[i][j] = fl;
        else
          a[i][j] = 0;
  }
};
Mat operator*(const Mat &p, const Mat &q) {
  Mat ans;
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < N; j++)
      for (long long k = 0; k < N; k++)
        ans.a[i][j] = (ans.a[i][j] + p.a[i][k] * q.a[k][j] % mod) % mod;
  return ans;
}
Mat power(Mat p, long long k) {
  Mat ans(1);
  while (k) {
    if (k & 1) ans = ans * p;
    k >>= 1;
    p = p * p;
  }
  return ans;
}
Mat p;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 0; i < maxN; i++) c[i][0] = 1;
  for (long long i = 1; i < maxN; i++)
    for (long long j = 1; j < maxN; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
  long long n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  k++;
  N = 2 * k + 1;
  for (long long i = 0; i < k; i++) p.a[i][i + k] = 1;
  for (long long i = k; i < 2 * k; i++) {
    long long po = i - k;
    for (long long j = 0; j < po + 1; j++) {
      long long pow = (1LL << (po - j)) % mod;
      pow = pow * c[po][j] % mod;
      p.a[i][j] = pow;
      p.a[i][k + j] = c[po][j];
    }
  }
  for (long long i = 0; i < 2 * k; i++) p.a[2 * k][i] = p.a[2 * k - 1][i];
  p.a[2 * k][2 * k] = 1;
  Mat ans = power(p, n - 2);
  long long res = 0;
  for (long long i = 0; i < k; i++) res = (res + ans.a[2 * k][i]) % mod;
  for (long long i = k; i < 2 * k; i++) {
    long long pow = (1LL << (i - k + 1)) % mod;
    res = (res + ans.a[2 * k][i] * pow % mod) % mod;
  }
  long long pow = (1LL << k) % mod;
  res = (res + ans.a[2 * k][2 * k] * (pow + 1) % mod) % mod;
  cout << res << endl;
  return 0;
}