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 = 1e9 + 7;
int add(int a, int b) {
  if (a + b < MOD) return a + b;
  return a + b - MOD;
}
int sub(int a, int b) {
  if (a - b >= 0) return a - b;
  return a - b + MOD;
}
int mult(int a, int b) { return (long long)a * b % MOD; }
vector<vector<int>> operator*(const vector<vector<int>> &a,
                              const vector<vector<int>> &b) {
  int n1 = a.size();
  int m1 = a[0].size();
  int n2 = b.size();
  int m2 = b[0].size();
  assert(m1 == n2);
  int n = n1;
  int m = m2;
  vector<vector<int>> c = vector<vector<int>>(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < m1; k++) {
        c[i][j] = add(c[i][j], mult(a[i][k], b[k][j]));
      }
    }
  }
  return c;
}
vector<vector<int>> matPow(vector<vector<int>> a, long long b) {
  int n = a.size();
  vector<vector<int>> ans = vector<vector<int>>(n, vector<int>(n, 0));
  for (int i = 0; i < n; i++) {
    ans[i][i] = 1;
  }
  while (b > 0) {
    if (b & 1 == 1) {
      ans = ans * a;
    }
    a = a * a;
    b >>= 1;
  }
  return ans;
}
const int MX = 45;
int comb[MX][MX];
int pot[MX];
int fastPow(int a, int b) {
  int ans = 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);
  pot[0] = 1;
  for (int i = 1; i < MX; i++) {
    pot[i] = mult(pot[i - 1], 2);
  }
  for (int i = 0; i < MX; i++) {
    comb[i][i] = 1;
    comb[i][0] = 1;
  }
  for (int i = 1; i < MX; i++) {
    for (int j = 1; j < MX; j++) {
      comb[i][j] = add(comb[i - 1][j - 1], comb[i - 1][j]);
    }
  }
  long long n;
  int k;
  cin >> n >> k;
  vector<vector<int>> M =
      vector<vector<int>>(2 * (k + 1) + 1, vector<int>(2 * (k + 1) + 1, 0));
  for (int i = 0; i <= k; i++) {
    M[i][i + k + 1] = 1;
  }
  M[2 * (k + 1)][2 * (k + 1)] = 1;
  M[2 * (k + 1)][2 * (k + 1) - 1] = 1;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) {
      M[i + k + 1][j] = mult(comb[i][j], pot[i - j]);
      M[i + k + 1][j + k + 1] = comb[i][j];
    }
  }
  vector<vector<int>> B =
      vector<vector<int>>(2 * (k + 1) + 1, vector<int>(1, 0));
  int val = 2;
  for (int i = 0; i <= k; i++) {
    B[i][0] = 1;
    B[i + k + 1][0] = val;
    val = mult(val, 2);
  }
  B[2 * (k + 1)][0] = 1;
  vector<vector<int>> ans = matPow(M, n - 1) * B;
  cout << ans[2 * (k + 1)][0] << "\n";
  return 0;
}