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;
const long long MOD = 1e9 + 7;
long long add(long long a, long long b) { return (a + b) % MOD; }
long long sub(long long a, long long b) { return (a - b + MOD) % MOD; }
long long mult(long long a, long long b) {
  if (a * b < 0) {
    return sub(0, abs(a * b) % MOD);
  }
  return (a * b) % MOD;
}
vector<vector<long long> > operator*(const vector<vector<long long> > &a,
                                     const vector<vector<long long> > &b) {
  long long n1 = a.size();
  long long m1 = a[0].size();
  long long n2 = b.size();
  long long m2 = b[0].size();
  assert(m1 == n2);
  long long n = n1;
  long long m = m2;
  vector<vector<long long> > c(n, vector<long long>(m, 0));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      for (long long k = 0; k < m1; k++) {
        c[i][j] = add(c[i][j], mult(a[i][k], b[k][j]));
      }
    }
  }
  return c;
}
vector<vector<long long> > matPow(vector<vector<long long> > a, long long b) {
  long long n = a.size();
  vector<vector<long long> > ans =
      vector<vector<long long> >(n, vector<long long>(n, 0));
  for (long long i = 0; i < n; i++) {
    ans[i][i] = 1;
  }
  while (b > 0) {
    if (b & 1 == 1) {
      ans = ans * a;
    }
    a = a * a;
    b >>= 1;
  }
  return ans;
}
const int MX = 45;
long long comb[MX][MX];
long long pot[MX];
long long fastPow(long long a, long long b, long long mod = MOD) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1 == 1) {
      ans = mult(ans, a);
    }
    a = mult(a, a);
    b >>= 1;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pot[0] = 1;
  for (int i = 1; i < MX; i++) {
    pot[i] = mult(pot[i - 1], 2);
  }
  for (int i = 0; i < MX; i++) {
    comb[i][i] = 1;
    comb[i][0] = 1;
  }
  for (int i = 1; i < MX; i++) {
    for (int j = 1; j < MX; j++) {
      comb[i][j] = add(comb[i - 1][j - 1], comb[i - 1][j]);
    }
  }
  long long n, k;
  cin >> n >> k;
  vector<vector<long long> > M = vector<vector<long long> >(
      2 * (k + 1) + 1, vector<long long>(2 * (k + 1) + 1, 0));
  for (int i = 0; i <= k; i++) {
    M[i][i + k + 1] = 1;
  }
  M[2 * (k + 1)][2 * (k + 1)] = 1;
  M[2 * (k + 1)][2 * (k + 1) - 1] = 1;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) {
      M[i + k + 1][j] = mult(comb[i][j], pot[i - j]);
      M[i + k + 1][j + k + 1] = comb[i][j];
    }
  }
  vector<vector<long long> > B =
      vector<vector<long long> >(2 * (k + 1) + 1, vector<long long>(1, 0));
  int val = 2;
  for (int i = 0; i <= k; i++) {
    B[i][0] = 1;
    B[i + k + 1][0] = val;
    val = mult(val, 2);
  }
  B[2 * (k + 1)][0] = 1;
  vector<vector<long long> > ans = matPow(M, n - 1) * B;
  cout << ans[2 * (k + 1)][0] << "\n";
  return 0;
}