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 mod = 1e9 + 7;
long long n;
int k;
struct mat {
  long long m[100][100];
  mat() { memset(m, 0, sizeof(m)); }
};
mat pre() {
  mat X;
  long long dp[50][50];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= k + 1; i++) dp[i][1] = 1;
  for (int i = 2; i <= k + 1; i++) {
    for (int j = 2; j <= i; j++) {
      dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
    }
  }
  X.m[1][1] = 1;
  mat();
  for (int i = 2; i <= k + 2; i++)
    X.m[1][i] = X.m[1][i + k + 1] = dp[k + 1][i - 1];
  for (int i = 2; i <= k + 2; i++) {
    for (int j = 2; j <= i; j++) {
      X.m[i][j] = X.m[i][j + k + 1] = X.m[i + k + 1][j] = dp[i - 1][j - 1];
    }
  }
  return X;
}
mat operator*(mat a, mat b) {
  mat t;
  mat();
  for (int i = 1; i <= 2 * k + 3; i++) {
    for (int j = 1; j <= 2 * k + 3; j++) {
      for (int u = 1; u <= 2 * k + 3; u++) {
        t.m[i][j] = (t.m[i][j] + a.m[i][u] * b.m[u][j] % mod) % mod;
      }
    }
  }
  return t;
}
mat operator^(mat a, long long b) {
  mat E;
  mat();
  for (int i = 1; i <= 2 * k + 3; i++) E.m[i][i] = 1;
  for (; b; b >>= 1, a = a * a) {
    if (b & 1) E = E * a;
  }
  return E;
}
int main() {
  scanf("%lld%d", &n, &k);
  mat U = pre();
  U = U ^ (n - 1);
  long long ans = 0;
  for (int i = 1; i <= 2 * k + 3; i++) {
    ans = (ans + U.m[1][i]) % mod;
  }
  printf("%lld\n", ans);
}