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 maxn = 100;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
struct matrice {
  long long n, m;
  vector<vector<long long> > a;
  matrice(long long n, long long m, bool f = 0) : n(n), m(m) {
    a.resize(n);
    for (long long i = 0; i < n; i++) {
      a[i].resize(m);
      fill(a[i].begin(), a[i].end(), 0);
      if (f) a[i][i] = 1;
    }
    return;
  }
  void set(long long i, long long j, long long x) {
    a[i][j] = x;
    return;
  }
  void add(long long i, long long j, long long x) {
    a[i][j] = (a[i][j] + x) % mod;
    return;
  }
  long long get(long long i, long long j) { return a[i][j]; }
  matrice operator*(const matrice &b) {
    matrice c = matrice(n, b.m);
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < b.m; j++) {
        for (long long k = 0; k < m; k++) {
          c.a[i][j] = (c.a[i][j] + a[i][k] * b.a[k][j]) % mod;
        }
      }
    }
    return c;
  }
};
matrice powmat(matrice a, long long b) {
  matrice c(a.n, a.m, 1);
  while (b) {
    if (b & 1) c = c * a;
    a = a * a;
    b >>= 1;
  }
  return c;
}
long long C[maxn][maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  C[0][0] = 1;
  for (long long i = 1; i < maxn; i++) {
    C[i][0] = 1;
    for (long long j = 1; j <= i; j++) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
  }
  cin >> n >> m;
  matrice A(2 * m + 3, 2 * m + 3);
  A.set(0, 0, 1);
  A.set(0, m + 1, 1);
  for (long long i = m + 2; i < m + m + 3; i++) {
    A.set(i, i - m - 1, 1);
  }
  for (long long i = 0; i <= m; i++) {
    for (long long j = 0; j <= i; j++) {
      A.set(i + 1, j + 1, C[i][j]);
      for (long long k = 0; k <= i; k++) {
        A.add(i + 1, m + 2 + k, C[i][j] * C[j][k]);
      }
    }
  }
  A = powmat(A, n);
  matrice B(m + m + 3, 1);
  for (long long i = 0; i < m + 2; i++) {
    B.set(i + 1, 0, 1);
  }
  A = A * B;
  cout << A.get(0, 0);
  return 0;
}