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;
vector<long long> a;
long long c[1000][1000];
long long sz, n, m;
vector<vector<long long> > v;
vector<long long> mult(vector<long long> a, vector<vector<long long> > b) {
  vector<long long> res;
  res.resize(a.size());
  for (int i = 0; i < res.size(); i++) res[i] = 0;
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < b.size(); j++)
      res[j] += a[i] * b[i][j], res[j] %= 1000000007;
  return res;
}
vector<vector<long long> > mult(vector<vector<long long> > a,
                                vector<vector<long long> > b) {
  vector<vector<long long> > res;
  res.resize(a.size());
  for (int i = 0; i < res.size(); i++) res[i].resize(a.size());
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a.size(); j++) res[i][j] = 0;
  for (int k = 0; k < a.size(); k++)
    for (int i = 0; i < a.size(); i++)
      for (int j = 0; j < b.size(); j++) {
        res[i][j] += a[i][k] * b[k][j];
        res[i][j] %= 1000000007;
      }
  return res;
}
vector<vector<long long> > one(long sz) {
  vector<vector<long long> > r;
  r.resize(sz);
  for (int i = 0; i < r.size(); i++) r[i].resize(sz);
  for (int i = 0; i < r.size(); i++)
    for (int j = 0; j < r.size(); j++)
      if (i == j)
        r[i][j] = 1;
      else
        r[i][j] = 0;
  return r;
}
vector<vector<long long> > pw(vector<vector<long long> > a, long long b) {
  if (b == 0) return one(a.size());
  if (b % 2) return mult(a, pw(a, b - 1));
  return pw(mult(a, a), b / 2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  c[0][0] = 1;
  for (int i = 1; i <= 50; i++) {
    for (int j = 0; j <= i; j++)
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % 1000000007;
  }
  sz = m * 2 + 3;
  a.resize(sz);
  v.resize(sz);
  for (int i = 0; i < v.size(); i++) v[i].resize(a.size());
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a.size(); j++) {
      v[i][j] = 0;
      a[i] = 0;
    }
  for (int i = 0; i < sz - 1; i++) a[i] = 1;
  v[sz - 2][sz - 1] = v[sz - 1][sz - 1] = 1;
  for (int i = 0; i <= m; i++)
    for (int j = i; j <= m; j++)
      v[i][j + m + 1] = v[i + m + 1][j] = v[i + m + 1][j + m + 1] = c[j][i];
  v = pw(v, n);
  a = mult(a, v);
  cout << a[sz - 1] << endl;
  cin.get();
  cin.get();
  return 0;
}