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>
long long constexpr mod = 1000000007;
struct matrix {
  using value_type = long long;
  using row_type = std::vector<value_type>;
  matrix(int ro, int co) {
    mat.resize(ro);
    for (auto& i : mat) i.resize(co);
  }
  matrix(int n) : matrix(n, n) {
    for (int i = 0; i < n; i++) mat[i][i] = 1;
  }
  matrix() = default;
  int row() const { return mat.size(); }
  int col() const { return mat[0].size(); }
  row_type& operator[](int x) { return mat[x]; }
  row_type const& operator[](int x) const { return mat[x]; }

 private:
  std::vector<row_type> mat;
};
matrix operator*(matrix const& a, matrix const& b) {
  int n = a.row(), m = b.col(), t = a.col();
  matrix r(n, m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < t; k++)
        r[i][j] = (r[i][j] + (a[i][k] * b[k][j]) % mod) % mod;
  return r;
}
matrix quick_pow(matrix const& a, long long b) {
  if (!b) return matrix(a.row());
  matrix ret = quick_pow(a, b / 2);
  ret = ret * ret;
  if (b & 1) ret = ret * a;
  return ret;
}
long long c[50][50];
long long pow2[50];
void init() {
  c[0][0] = 1;
  for (int i = 1; i < 50; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
  }
  pow2[0] = 1;
  for (int i = 1; i < 50; i++) pow2[i] = (pow2[i - 1] * 2) % mod;
}
int main() {
  std::ios::sync_with_stdio(false);
  init();
  long long n, k;
  std::cin >> n >> k;
  if (n == 1) {
    std::cout << "1\n";
    return 0;
  }
  matrix a(2 * k + 3, 2 * k + 3);
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) a[i][j] = c[i][j];
    for (int j = 0; j <= i; j++)
      a[i][j + k + 1] = (c[i][j] * pow2[i - j]) % mod;
  }
  for (int i = 0; i <= k; i++) a[i + k + 1][i] = 1;
  a[2 * k + 2][2 * k + 2] = 1;
  for (int j = 0; j <= k; j++) {
    a[2 * k + 2][j] = c[k][j];
    a[2 * k + 2][j + k + 1] = (c[k][j] * pow2[k - j]) % mod;
  }
  matrix init(2 * k + 3, 1);
  for (int i = 0; i <= k; i++) {
    init[i][0] = pow2[i + 1];
    init[k + i + 1][0] = 1;
  }
  init[2 * k + 2][0] = (pow2[k + 1] + 1) % mod;
  a = quick_pow(a, n - 2);
  init = a * init;
  std::cout << init[2 * k + 2][0] << '\n';
}