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 N = 45;
const long long M = 1000000007ll;
long long c[N][N];
long long n, m, len;
struct aa {
  long long a[N * 2][N * 2];
} ori, one, dat;
void work(aa &x, aa &y, aa &z) {
  int i, j, k;
  memset(dat.a, 0, sizeof(dat.a));
  for (i = 1; i <= len; i++)
    for (j = 1; j <= len; j++)
      for (k = 1; k <= len; k++)
        dat.a[i][j] = (dat.a[i][j] + x.a[i][k] * y.a[k][j] % M) % M;
  for (i = 1; i <= len; i++)
    for (j = 1; j <= len; j++) z.a[i][j] = dat.a[i][j];
  return;
}
int main(void) {
  int i, j;
  cin >> n >> m;
  len = 2 * m + 3;
  c[0][0] = c[1][0] = c[1][1] = 1;
  for (i = 2; i <= m; i++) {
    c[i][0] = c[i][i] = 1;
    for (j = 1; j < i; j++) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % M;
  }
  memset(ori.a, 0, sizeof(ori.a));
  memset(one.a, 0, sizeof(one.a));
  for (i = 1; i <= len; i++) one.a[i][i] = 1;
  ori.a[1][1] = 1;
  for (j = 0; j <= m; j++) ori.a[1][2 + j] = ori.a[1][2 + j + m + 1] = c[m][j];
  for (i = 0; i <= m; i++)
    for (j = 0; j <= i; j++)
      ori.a[2 + i][2 + j] = ori.a[2 + i][2 + j + m + 1] = c[i][j];
  for (i = 0; i <= m; i++)
    for (j = 0; j <= i; j++) ori.a[m + 3 + i][2 + j] = c[i][j];
  n--;
  while (n) {
    if (n & 1) work(one, ori, one);
    work(ori, ori, ori);
    n >>= 1;
  }
  long long k = 0;
  for (i = 1; i <= len; i++) k = (k + one.a[1][i]) % M;
  cout << k;
  return 0;
}