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 &A, matrix &B) {
  int i, j, k;
  matrix C;
  for ((i) = 0; (i) < (int)(83); (i)++)
    for ((j) = 0; (j) < (int)(83); (j)++) {
      long long tmp = 0;
      for ((k) = 0; (k) < (int)(83); (k)++)
        tmp = (tmp + A.a[i][k] * B.a[k][j]) % 1000000007ll;
      C.a[i][j] = tmp;
    }
  return C;
}
matrix mat_power(matrix &A, long long N) {
  int i, j;
  matrix ans;
  for ((i) = 0; (i) < (int)(83); (i)++)
    for ((j) = 0; (j) < (int)(83); (j)++) ans.a[i][j] = ((i == j) ? 1 : 0);
  for (i = 62; i >= 0; i--)
    if (N & (1ll << i)) break;
  for (; i >= 0; i--) {
    ans = mat_prod(ans, ans);
    if (N & (1ll << i)) ans = mat_prod(ans, A);
  }
  return ans;
}
long long two[50];
long long C[50][50];
long long func(long long N, int K) {
  int i, j;
  two[0] = 1;
  for ((i) = 0; (i) < (int)(49); (i)++) two[i + 1] = two[i] * 2 % 1000000007ll;
  for ((i) = 0; (i) < (int)(50); (i)++)
    for ((j) = 0; (j) < (int)(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 A;
  for ((i) = 0; (i) < (int)(83); (i)++)
    for ((j) = 0; (j) < (int)(83); (j)++) A.a[i][j] = 0;
  A.a[82][82] = 1;
  for ((i) = 0; (i) < (int)(41); (i)++) A.a[i + 41][i] = 1;
  for ((i) = 0; (i) < (int)(41); (i)++)
    for ((j) = 0; (j) < (int)(41); (j)++)
      if (i <= j) {
        A.a[i][j + 41] = C[j][i] * two[j - i] % 1000000007ll;
        A.a[i + 41][j + 41] = C[j][i];
      }
  for ((i) = 0; (i) < (int)(41); (i)++)
    A.a[82][i + 41] = (1 + two[i]) % 1000000007ll;
  matrix B = mat_power(A, N);
  long long ans = 0;
  for (i = 41; i < 83; i++) ans = (ans + B.a[i][K]) % 1000000007ll;
  return ans;
}
int main(void) {
  long long N;
  int K;
  cin >> N >> K;
  cout << func(N, K) << endl;
  return 0;
}