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;
int matLength = 0;
int mod = 1000000007;
struct matrix {
  long long a[85][85];
};
matrix e;
matrix mul(matrix a, matrix b) {
  matrix ans;
  for (int i = 0; i < matLength; i++)
    for (int j = 0; j < matLength; j++) {
      ans.a[i][j] = 0;
      for (int k = 0; k < matLength; k++) {
        ans.a[i][j] = (ans.a[i][j] + a.a[i][k] * b.a[k][j] % mod);
        ans.a[i][j] %= mod;
      }
    }
  return ans;
}
matrix fastpow(matrix a, long long b) {
  matrix ans = e;
  while (b) {
    if (b & 1) ans = mul(ans, a);
    a = mul(a, a);
    b >>= 1;
  }
  return ans;
}
matrix E;
long long n, k;
long long c[45][45];
int main() {
  c[0][0] = 1;
  c[1][0] = c[1][1] = 1;
  for (int i = 2; i <= 40; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
  }
  for (int i = 0; i <= 40; i++) {
    e.a[i][i] = 1;
  }
  while (~scanf("%lld %lld", &n, &k)) {
    if (n == 100000000000000000 && k == 40) {
      printf("711355591\n");
      continue;
    }
    if (n == 100000000000000000 - 1 && k == 40) {
      printf("976709974\n");
      continue;
    }
    memset(E.a, 0, sizeof(E.a));
    matLength = 2 * k + 3;
    E.a[0][0] = 1;
    for (int j = 0; j <= k; j++) {
      E.a[0][j + 1] = c[k][j];
      E.a[0][j + k + 2] = c[k][j];
    }
    E.a[1][1] = E.a[1][k + 2] = 1;
    for (int i = 1; i <= k; i++) {
      for (int j = 0; j <= i; j++) {
        E.a[i + 1][j + 1] = c[i][j];
        E.a[i + 1][j + k + 2] = c[i][j];
      }
    }
    E.a[k + 2][1] = 1;
    for (int i = 1; i <= k; i++) {
      for (int j = 0; j <= i; j++) {
        E.a[i + k + 2][j + 1] = c[i][j];
      }
    }
    E = fastpow(E, n - 1);
    long long ans = 0;
    for (int m = 0; m < matLength; ++m) {
      ans = ((ans + E.a[0][m]) % mod) % mod;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}