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;
struct matrix {
  long long a[83][83];
};
matrix mat_prod(matrix &x, matrix &y) {
  matrix z;
  memset(z.a, 0, sizeof(z.a));
  for (long long i = 0; i < 83; i++)
    for (long long j = 0; j < 83; j++)
      for (long long k = 0; k < 83; k++)
        z.a[i][j] = (z.a[i][j] + x.a[i][k] * y.a[k][j]) % 1000000007LL;
  return z;
}
matrix mat_pow(matrix x, long long n) {
  matrix z;
  for (long long i = 0; i < 83; i++)
    for (long long j = 0; j < 83; j++) z.a[i][j] = (i == j ? 1 : 0);
  while (n > 0) {
    if (n & 1) z = mat_prod(z, x);
    x = mat_prod(x, x);
    n /= 2;
  }
  return z;
}
long long t[50], c[50][50];
int main() {
  long long n, k;
  cin >> n >> k;
  t[0] = 1;
  for (long long i = 1; i <= 49; i++) t[i] = (t[i - 1] * 2) % 1000000007LL;
  if (n == 1) {
    if (n == 1) cout << 1 << endl;
    return 0;
  }
  for (long long i = 0; i < 50; i++)
    for (long long j = 0; j < i + 1; j++) {
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007LL;
    }
  matrix ans;
  memset(ans.a, 0, sizeof(ans.a));
  for (long long i = 0; i < 41; i++) ans.a[i + 41][i] = 1;
  for (long long i = 0; i < 41; i++)
    for (long long j = 0; j < 41; j++)
      if (i <= j) {
        ans.a[i][j + 41] = (c[j][i] * t[j - i]) % 1000000007LL;
        ans.a[i + 41][j + 41] = c[j][i];
      }
  ans.a[82][82] = ans.a[41 + k][82] = 1;
  ans = mat_pow(ans, n - 1);
  long long result = 0;
  for (long long i = 0; i < 41; i++)
    result = (result + ans.a[i][82]) % 1000000007LL;
  for (long long i = 0; i < 41; i++)
    result = (result + t[i + 1] * ans.a[i + 41][82]) % 1000000007LL;
  result = (result + ans.a[82][82]) % 1000000007LL;
  cout << result << endl;
  return 0;
}