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 int mod = 1000000007;
const int N = 88;
long long c[N][N];
long long S2;
struct Matrix {
  int n, m;
  long long mt[N][N];
  Matrix(int r = 0, int c = 0) {
    n = r;
    m = c;
    memset(mt, 0, sizeof(mt));
  }
  Matrix unit() const {
    Matrix c(n, n);
    for (int i = 0; i < n; i++) c.mt[i][i] = 1;
    return c;
  }
  Matrix operator+(const Matrix &b) const {
    Matrix c(n, m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        c.mt[i][j] = mt[i][j] + b.mt[i][j];
        c.mt[i][j] %= mod;
      }
    return c;
  }
  Matrix operator*(const Matrix &b) const {
    Matrix c(n, b.m);
    for (int k = 0; k < m; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < b.m; j++) {
          c.mt[i][j] += mt[i][k] * b.mt[k][j];
          c.mt[i][j] %= mod;
        }
    return c;
  }
  Matrix pow(long long p) {
    Matrix s = unit(), t = *this;
    for (long long i = p; i; i >>= 1) {
      if (i & 1) s = s * t;
      t = t * t;
    }
    return s;
  }
  void seta(int k) {
    n = 1;
    m = 2 * k + 3;
    mt[0][0] = 1;
    for (int i = 1; i <= k; i++) mt[0][i] = mt[0][i - 1] * 3 % mod;
    mt[0][k + 1] = 2;
    for (int i = k + 2; i <= 2 * k + 1; i++) mt[0][i] = mt[0][i - 1] * 3 % mod;
    mt[0][2 * k + 2] = S2;
  }
  void setq(int k) {
    memset(mt, 0, sizeof(mt));
    n = m = 2 * k + 3;
    for (int j = 0; j <= k; j++) {
      for (int i = 0; i <= j; i++) mt[i + k + 1][j] = c[j][i];
    }
    for (int j = k + 1; j <= 2 * k + 1; j++) {
      int t = j - k - 1;
      for (int i = 0; i <= t; i++) {
        mt[i][j] = c[t][i];
        mt[i + k + 1][j] = c[t][i];
      }
    }
    mt[k][m - 1] = mt[2 * k + 1][m - 1] = mt[n - 1][m - 1] = 1;
  }
  void show() {
    printf("(%d, %d)\n", n, m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << mt[i][j] << ' ';
      }
      puts("");
    }
  }
};
Matrix a, q, s;
int main() {
  memset(c, 0, sizeof(c));
  for (int i = 0; i < N; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) {
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
      c[i][j] %= mod;
    }
  }
  long long n, k;
  cin >> n >> k;
  if (n == 1)
    puts("1");
  else {
    S2 = 2;
    for (int i = 0; i < k; i++) S2 = S2 * 2 % mod;
    S2++;
    a.seta(k);
    q.setq(k);
    s = a * q.pow(n - 2);
    long long ans = s.mt[0][s.m - 1];
    cout << ans << endl;
  }
  return 0;
}