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 = (long long)1e9 + 7;
const int N = 90 + 5;
long long ch[N][N];
vector<vector<long long> > ones(int num) {
  vector<vector<long long> > p;
  vector<long long> q;
  p.clear();
  for (int i = 0; i < num; i++) {
    q.clear();
    for (int j = 0; j < num; j++)
      if (i == j)
        q.push_back(1ll);
      else
        q.push_back(0ll);
    p.push_back(q);
  }
  return p;
}
vector<vector<long long> > zeros(int num) {
  vector<vector<long long> > ret;
  vector<long long> c;
  for (int i = 0; i < num; i++) c.push_back(0);
  for (int i = 0; i < num; i++) ret.push_back(c);
  return ret;
}
vector<vector<long long> > dot(vector<vector<long long> > a,
                               vector<vector<long long> > b, int sz) {
  vector<vector<long long> > c = zeros(sz);
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < sz; j++)
      for (int k = 0; k < sz; k++)
        c[i][j] = (c[i][j] + a[i][k] * b[k][j] % mod) % mod;
  return c;
}
vector<vector<long long> > mat_pow(vector<vector<long long> > x, long long n,
                                   int sz) {
  vector<vector<long long> > ret = ones(sz);
  while (n) {
    if (n & 1) ret = dot(ret, x, sz);
    x = dot(x, x, sz);
    n >>= 1;
  }
  return ret;
}
void init() {
  for (int i = 0; i < N; i++) ch[i][0] = ch[i][i] = 1;
  for (int i = 1; i < N; i++)
    for (int j = 1; j < i; j++)
      ch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % mod;
}
int main() {
  init();
  int k;
  long long n;
  while (scanf("%I64d%d", &n, &k) == 2) {
    vector<vector<long long> > a;
    vector<long long> b;
    int p = 2 * k + 3;
    a.clear(), b.clear();
    b.push_back(1ll);
    for (int i = 1; i < k + 2; i++) b.push_back(ch[k][i - 1]);
    for (int i = 1; i < k + 2; i++) b.push_back(ch[k][i - 1]);
    a.push_back(b);
    for (int i = 1; i < k + 2; i++) {
      b.clear(), b.push_back(0ll);
      if (i == 1) {
        b.push_back(1ll);
        for (int j = 0; j < k; j++) b.push_back(0ll);
        b.push_back(1ll);
        for (int j = 0; j < k; j++) b.push_back(0ll);
      } else {
        for (int j = 0; j < i; j++) b.push_back(ch[i - 1][j]);
        for (int j = i; j < k + 1; j++) b.push_back(0ll);
        for (int j = 0; j < i; j++) b.push_back(ch[i - 1][j]);
        for (int j = i; j < k + 1; j++) b.push_back(0ll);
      }
      a.push_back(b);
    }
    for (int i = 1; i < k + 2; i++) {
      b.clear(), b.push_back(0ll);
      if (i == 1) {
        b.push_back(1ll);
        for (int j = 0; j < k; j++) b.push_back(0ll);
        for (int j = 0; j < k + 1; j++) b.push_back(0ll);
      } else {
        for (int j = 0; j < i; j++) b.push_back(ch[i - 1][j]);
        for (int j = i; j < k + 1; j++) b.push_back(0ll);
        for (int j = 0; j < k + 1; j++) b.push_back(0ll);
      }
      a.push_back(b);
    }
    vector<vector<long long> > d = mat_pow(a, n - 1, 2 * k + 3);
    long long ans = 0;
    for (int i = 0; i < 2 * k + 3; i++) ans = (ans + d[0][i]) % mod;
    printf("%I64d\n", ans);
  }
  return 0;
}