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 inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
const int mod = 1000000007;
long long data[3][100][100];
long long comb[100][100];
void init() {
  for (int i = 0; i < 100; ++i)
    for (int j = 0; j <= i; ++j)
      comb[i][j] =
          j == 0 || j == i ? 1 : (comb[i - 1][j] + comb[i - 1][j - 1]) % mod;
}
long long M[100][100];
long long M2[100][100];
static inline void mul(long long (*a)[100], long long (*b)[100],
                       long long (*c)[100], int n) {
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      long long s = 0;
      for (int k = 0; k < n; ++k) s += a[i][k] * b[k][j] % mod;
      c[i][j] = s % mod;
    }
}
long long cal(long long n, const int k) {
  long long(*m)[100] = data[0];
  long long(*r)[100] = data[1];
  long long(*t)[100] = data[2];
  const int size = k + 1 + k + 1 + 1;
  const int s1 = 1, t1 = s1 + k;
  const int s2 = k + 2, t2 = s2 + k;
  {
    for (int i = 0, all = k; i < k + 1; ++i, --all)
      for (int j = i, choose = all; j < k + 1; ++j, --choose)
        M[i][j] = comb[all][choose];
    mul(M, M, M2, k + 1);
    for (int i = s2, j = s1; i <= t2; ++i, ++j) m[i][j] = 1;
    for (int i = s1; i <= t1; ++i)
      for (int j = s1; j <= t1; ++j) m[i][j] = M[i - s1][j - s1];
    for (int i = s1; i <= t1; ++i)
      for (int j = s2; j <= t2; ++j) m[i][j] = M2[i - s1][j - s2];
    m[0][0] = 1;
    for (int i = s1; i <= t2; ++i) m[0][i] = m[s1][i];
    for (int i = s1, p = k; i <= t1; ++i, --p) r[i][0] = (1LL << p + 1) % mod;
    for (int i = s2; i <= t2; ++i) r[i][0] = 1;
    r[0][0] = (r[1][0] + 1) % mod;
  }
  for (n -= 2; n; n >>= 1) {
    if (n & 1) {
      for (int i = 0; i < size; ++i) {
        long long s = 0;
        for (int k = 0; k < size; ++k) s += m[i][k] * r[k][0] % mod;
        t[i][0] = s % mod;
      }
      swap(t, r);
    }
    for (int i = 0; i < size; ++i)
      for (int j = 0; j < size; ++j) {
        long long s = 0;
        for (int k = 0; k < size; ++k) s += m[i][k] * m[k][j] % mod;
        t[i][j] = s % mod;
      }
    swap(t, m);
  }
  return r[0][0];
}
int main() {
  long long n;
  scanf("%I64d", &n);
  int k = Rint();
  if (n == 1) {
    puts("1");
    return 0;
  }
  init();
  printf("%I64d\n", cal(n, k));
  return 0;
}