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 mat {
  long long a[83][83];
};
mat mult(mat &A, mat &B) {
  mat C;
  for (int i = 0; i < 83; i++) {
    for (int j = 0; j < 83; j++) {
      long long tmp = 0;
      for (int k = 0; k < 83; k++) {
        tmp = (tmp + A.a[i][k] * B.a[k][j]) % 1000000007;
      }
      C.a[i][j] = tmp;
    }
  }
  return C;
}
mat pow(mat &A, long long N) {
  int i, j;
  mat ans;
  for (i = 0; i < 83; i++) {
    for (j = 0; j < 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 = mult(ans, ans);
    if (N & (1LL << i)) ans = mult(ans, A);
  }
  return ans;
}
long long two[50];
long long C[50][50];
int main() {
  long long N;
  int K;
  cin >> N >> K;
  two[0] = 1;
  for (int i = 0; i < 49; i++) {
    two[i + 1] = two[i] * 2 % 1000000007;
  }
  for (int i = 0; i < 50; i++) {
    for (int 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]) % 1000000007;
    }
  }
  mat A;
  for (int i = 0; i < 83; i++) {
    for (int j = 0; j < 83; j++) {
      A.a[i][j] = 0;
    }
  }
  A.a[82][82] = 1;
  for (int i = 0; i < 41; i++) {
    A.a[i + 41][i] = 1;
  }
  for (int i = 0; i < 41; i++) {
    for (int j = 0; j < 41; j++) {
      if (i <= j) {
        A.a[i][j + 41] = C[j][i] * two[j - i] % 1000000007;
        A.a[i + 41][j + 41] = C[j][i];
      }
    }
  }
  for (int i = 0; i < 41; i++) {
    A.a[82][i + 41] = (1 + two[i]) % 1000000007;
  }
  mat B = pow(A, N);
  long long ans = 0;
  for (int i = 41; i < 83; i++) {
    ans = (ans + B.a[i][K]) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}