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>
inline int Input() {
  int ret = 0;
  bool isN = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') isN = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return isN ? -ret : ret;
}
inline void Output(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int len = 0, data[20];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
  putchar('\n');
}
#pragma comment(linker, "/STACK:124000000,124000000")
const double PI = acos(-1.0);
using namespace std;
const int MAX = 85;
int N;
struct Matrix {
  long long m[MAX][MAX];
  Matrix operator*(Matrix y) {
    Matrix ans;
    memset(ans.m, 0, sizeof(ans.m));
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        for (int k = 0; k < N; k++) {
          ans.m[i][j] = ans.m[i][j] + m[i][k] * y.m[k][j] % 1000000007;
        }
        ans.m[i][j] %= 1000000007;
      }
    }
    return ans;
  }
  Matrix operator+(Matrix y) {
    Matrix ans;
    ans.init();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) ans.m[i][j] = m[i][j] + y.m[i][j];
    }
    return ans;
  }
  void Debug() {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        printf("%I64d%c", m[i][j], j == N - 1 ? '\n' : ' ');
      }
    }
  }
  void init() { memset(m, 0, sizeof(m)); }
};
Matrix Fast(Matrix x, long long ci) {
  Matrix ans;
  memset(ans.m, 0, sizeof(ans.m));
  for (int i = 0; i < N; i++) ans.m[i][i] = 1;
  while (ci) {
    if (ci & 1) ans = ans * x;
    x = x * x;
    ci = ci >> 1;
  }
  return ans;
}
long long c[55][55];
void pre() {
  memset(c, 0, sizeof(c));
  c[0][0] = 1;
  c[1][0] = c[1][1] = 1;
  for (int i = 2; i < 55; 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]) % 1000000007;
    }
  }
}
long long two[55];
int main() {
  long long n;
  int k;
  two[0] = 1;
  for (int i = 1; i < 55; i++) two[i] = two[i - 1] * 2 % 1000000007;
  pre();
  while (scanf("%I64d%d", &n, &k) != EOF) {
    if (n == 1) {
      printf("1\n");
      return 0;
    }
    N = 2 * k + 3;
    Matrix tmp;
    tmp.init();
    for (int i = 0; i <= k; i++) {
      for (int j = 0; j <= k; j++)
        tmp.m[i][j] = tmp.m[i][j + k + 1] = c[k - i][k - j];
    }
    for (int i = 0; i <= k; i++) {
      for (int j = 0; j <= k; j++) tmp.m[i + k + 1][j] = c[k - i][k - j];
    }
    tmp.m[2 * k + 2][0] = 1;
    tmp.m[2 * k + 2][2 * k + 2] = 1;
    tmp = Fast(tmp, n);
    long long ans = 0;
    long long ans1 = 0;
    for (int i = 0; i <= k; i++) {
      ans1 = (ans1 + tmp.m[2 * k + 2][i] + tmp.m[2 * k + 2][i + k + 1]) %
             1000000007;
    }
    printf("%I64d\n", ans1);
  }
  return 0;
}