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>
template <class T>
void Cmin(T &t, T x) {
  if (x < t) t = x;
}
template <class T>
void Cmax(T &t, T x) {
  if (x > t) t = x;
}
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = 0x7FFFFFFF;
const int maxN = 400010;
const int MOD = 1000000007;
struct matrix {
  long long m[100][100];
  matrix() { memset(m, 0, sizeof(m)); }
};
int m = 0;
matrix mul(matrix a, matrix b) {
  matrix c;
  for (int i = 0; i <= m; i++) {
    for (int k = 0; k <= m; k++) {
      for (int j = 0; j <= m; j++) {
        c.m[i][j] = (c.m[i][j] + a.m[i][k] * b.m[k][j]) % MOD;
      }
    }
  }
  return c;
}
long long Comb[50][50];
long long POW(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
int main() {
  std::ios::sync_with_stdio(false);
  for (int i = 0; i <= 40; i++) {
    Comb[i][0] = Comb[i][i] = 1;
    for (int j = 1; j < i; j++) {
      Comb[i][j] = (Comb[i - 1][j] + Comb[i - 1][j - 1]) % MOD;
    }
  }
  long long n, k;
  while (cin >> n >> k) {
    if (n == 1) {
      cout << 1 << endl;
      continue;
    }
    matrix a, b, ans;
    m = (k + 1) * 2;
    b.m[0][0] = (1 + 2 * POW(2, k)) % MOD;
    for (int i = 1; i <= k + 1; i++) b.m[i][0] = 2 * POW(2, i - 1) % MOD;
    for (int i = 1; i <= k + 1; i++) b.m[i + k + 1][0] = POW(2, i - 1) % MOD;
    a.m[0][0] = 1;
    for (int i = 1; i <= k + 1; i++)
      a.m[0][i] = a.m[0][i + k + 1] = Comb[k][i - 1];
    for (int i = 1; i <= k + 1; i++) {
      for (int j = 1; j <= i; j++) {
        a.m[i][j] = a.m[i][j + k + 1] = Comb[i - 1][j - 1];
      }
    }
    for (int i = 1; i <= k + 1; i++) {
      for (int j = 1; j <= i; j++) {
        a.m[k + 1 + i][j] = Comb[i - 1][j - 1];
      }
    }
    for (int i = 0; i <= m; i++) ans.m[i][i] = 1;
    n -= 2;
    while (n) {
      if (n & 1) ans = mul(ans, a);
      a = mul(a, a);
      n >>= 1;
    }
    ans = mul(ans, b);
    cout << ans.m[0][0] << endl;
  }
  return 0;
}