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;
const long long MX = 45;
long long ex[MX];
long long combi[MX][MX];
long long mul(long long a, long long b) { return (a * b) % MOD; }
long long sum(long long a, long long b) { return (a + b) % MOD; }
vector<vector<long long> > mult(vector<vector<long long> > &a,
                                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();
  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] += a[i][k] * b[k][j];
        c[i][j] %= MOD;
      }
    }
  }
  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 = 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);
  cout.precision(10);
  cout << fixed;
  ex[0] = 1;
  combi[0][0] = 1;
  for (long long i = 1; i < MX; i++) {
    ex[i] = (ex[i - 1] * 2) % MOD;
    combi[i][0] = 1;
    for (long long j = 1; j <= i; j++) {
      combi[i][j] = (combi[i - 1][j] + combi[i - 1][j - 1]) % MOD;
    }
  }
  long long n, k;
  cin >> n >> k;
  long long sz = (k + 1) * 2 + 1;
  vector<vector<long long> > a(sz, vector<long long>(sz, 0));
  for (long long i = 0; i <= k; i++) {
    a[i][k + 1 + i] = 1;
    a[i][sz - 1] = combi[k][i];
    a[i + k + 1][sz - 1] = mul(ex[k - i], combi[k][i]);
    for (long long j = i; j <= k; j++) {
      a[i][j] = combi[j][i];
      a[i + k + 1][j] = mul(ex[j - i], combi[j][i]);
    }
  }
  a[sz - 1][sz - 1] = 1;
  vector<vector<long long> > b(1, vector<long long>(sz, 0));
  for (long long i = 0; i <= k; i++) {
    b[0][i] = mul(2, ex[i]);
    b[0][i + k + 1] = 1;
  }
  b[0][sz - 1] = sum(1, mul(2, ex[k]));
  if (n == 1) {
    cout << 1 << "\n";
    return 0;
  }
  n -= 2;
  a = matPow(a, n);
  a = mult(b, a);
  cout << a[0][sz - 1] << "\n";
  return 0;
}