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 = 1e8;
const int MN = 2000;
const int Mo = 1e9 + 7;
long long C[50][50], a[90], b[90][90];
long long n, m, M;
void comb() {
  C[0][0] = 1;
  for (int i = 1; i <= 40; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mo;
  }
}
void mula(long long a[], long long b[][90]) {
  long long c[90] = {};
  for (int i = 0; i <= M; i++)
    for (int j = 0; j <= M; j++) c[i] = (c[i] + b[i][j] * a[j]) % Mo;
  for (int i = 0; i <= M; i++) a[i] = c[i];
}
void multi(long long a[][90], long long b[][90]) {
  long long c[90][90] = {};
  for (int i = 0; i <= M; i++)
    for (int j = 0; j <= M; j++)
      for (int k = 0; k <= M; k++) c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % Mo;
  for (int i = 0; i <= M; i++)
    for (int j = 0; j <= M; j++) b[i][j] = c[i][j];
}
int main() {
  comb();
  cin >> n >> m;
  for (int i = 0; i <= m; i++)
    for (int j = i; j <= m; j++) {
      b[i][j] = C[m - i][j - i];
      b[i][j + m + 1] = C[m - i][j - i] * (1ll << (j - i)) % Mo;
    }
  for (int i = m + 1; i <= m + m + 1; i++) b[i][i - (m + 1)] = 1;
  M = m + m + 2;
  b[M][0] = b[M][M] = 1;
  for (int i = 0; i <= m; i++) a[i] = 1;
  a[m + m + 1] = 1;
  while (n > 1) {
    if (n & 1) mula(a, b);
    multi(b, b);
    n >>= 1;
  }
  mula(a, b);
  cout << a[M] << endl;
  return 0;
}