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 c[50][50], size;
long long n, k;
struct mat {
  long long m[100][100];
  mat() { memset(m, 0, sizeof(m)); }
};
mat M;
mat multiply(mat &A, mat &B) {
  mat tmp;
  int i, j, k;
  for (k = 1; k <= size; k++) {
    for (i = 1; i <= size; i++) {
      if (!A.m[i][k]) continue;
      for (j = 1; j <= size; j++)
        tmp.m[i][j] =
            (tmp.m[i][j] + (A.m[i][k] * B.m[k][j]) % 1000000007) % 1000000007;
    }
  }
  return tmp;
}
mat Quick_power(mat &A, long long n) {
  mat ans, tmp;
  memcpy(tmp.m, A.m, sizeof(tmp.m));
  for (int i = 1; i <= size; i++) ans.m[i][i] = 1;
  while (n) {
    if (n & 1) ans = multiply(ans, tmp);
    n >>= 1;
    tmp = multiply(tmp, tmp);
  }
  return ans;
}
void Combination() {
  int i, j;
  for (i = 0; i <= k; 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]) % 1000000007;
  }
}
void Init() {
  int i, j, l;
  M.m[1][1] = 1;
  for (i = 0; i <= k; i++) {
    M.m[1][i + 2] = M.m[1][i + k + 3] = c[k][i];
  }
  for (i = 2; i <= k + 2; i++) {
    for (j = i; j <= k + 2; j++) {
      M.m[i][j] = M.m[i][j + k + 1] = M.m[i + k + 1][j] = c[k + 2 - i][j - i];
    }
  }
}
int main() {
  int i, j;
  long long ans = 0;
  cin >> n >> k;
  Combination();
  Init();
  size = 2 * k + 3;
  M = Quick_power(M, n - 1);
  for (i = 1; i <= size; i++) ans = (ans + M.m[1][i]) % 1000000007;
  cout << ans;
  return 0;
}