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>
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e2 + 5;
const double eps = 1e-9;
using namespace std;
long long a[MAXN][MAXN], f[MAXN], b[MAXN][MAXN], g[MAXN];
long long n, k;
void mul1() {
  memset(b, 0, sizeof b);
  for (int l = 0; l < k; l++)
    for (int i = 0; i < k; i++)
      for (int j = 0; j < k; j++)
        b[i][j] = (b[i][j] + a[i][l] * a[l][j] % MOD) % MOD;
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) a[i][j] = b[i][j];
}
void mul2() {
  memset(g, 0, sizeof g);
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) g[j] = (g[j] + f[i] * a[j][i] % MOD) % MOD;
  for (int i = 0; i < k; i++) f[i] = g[i];
}
int main() {
  scanf("%I64d", &(n)), scanf("%I64d", &(k));
  k++;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j <= i; j++)
      a[i][j] = i && j ? (a[i - 1][j] + a[i - 1][j - 1]) % MOD : 1;
    for (int j = 0; j < k; j++) a[i][j + k] = a[i + k][j] = a[i][j];
  }
  a[2 * k][k - 1] = a[k * 2][k * 2] = 1;
  k *= 2;
  for (int i = 0; i < k; i++) f[i] = 1;
  f[k++] = 0;
  for (; n; n /= 2, mul1())
    if (n & 1) mul2();
  printf("%I64d\n", (f[k - 1]));
  return 0;
}