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 inf = 1000000000, MAX = 83;
const long long mod = 1000000007;
struct Matrix {
  long long a[MAX + 3][MAX + 3];
  Matrix() {
    for (int i = 1; i <= MAX; i++)
      for (int j = 1; j <= MAX; j++) a[i][j] = 0;
  }
  long long* operator[](int x) { return a[x]; }
};
long long sz, n, k, comb[45][45], pw[80] = {1};
Matrix operator*(Matrix a, Matrix b) {
  Matrix res;
  for (int i = 1; i <= sz; i++) {
    for (int j = 1; j <= sz; j++) {
      for (int k = 1; k <= sz; k++) {
        res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % mod;
      }
    }
  }
  return res;
}
int main() {
  cin >> n >> k;
  if (n == 1) {
    puts("1");
    return 0;
  }
  sz = 2 * k + 3;
  Matrix a;
  for (int i = 1; i <= 80; i++) pw[i] = (pw[i - 1] << 1ll) % mod;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (j == 0)
        comb[i][j] = 1;
      else if (i != 0)
        comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod;
    }
  }
  for (int i = 1; i <= k + 1; i++) {
    for (int j = i; j <= k + 1; j++) {
      a[i][j] = comb[k - i + 1][j - i];
    }
    for (int j = k + i + 1; j <= 2 * k + 2; j++) {
      a[i][j] = (comb[k - i + 1][j - k - i - 1] * pw[j - k - i - 1]) % mod;
    }
  }
  for (int i = k + 2; i <= 2 * k + 2; i++) {
    a[i][i - k - 1] = 1;
  }
  for (int i = 1; i <= 2 * k + 2; i++) a[sz][i] = a[1][i];
  a[sz][sz] = 1;
  Matrix ans;
  for (int i = 1; i <= sz; i++) ans[i][i] = 1;
  for (n -= 2; n; n >>= 1) {
    if (n & 1ll) ans = ans * a;
    a = a * a;
  }
  long long res = 0;
  for (int i = 1; i <= k + 1; i++)
    res = (res + ans[sz][i] * pw[k - i + 2]) % mod;
  for (int i = k + 2; i <= 2 * k + 2; i++) res = (res + ans[sz][i]) % mod;
  res = (res + ans[sz][sz] * (1 + pw[k + 1])) % mod;
  cout << res << endl;
  return 0;
}