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 MAXN = 100, Mod = 1e9 + 7;
long long n;
int k, C[MAXN][MAXN], cnt, Pow[MAXN], a[MAXN], res;
struct Fuck {
  int s[MAXN][MAXN];
  Fuck() {}
  Fuck(int S[][MAXN]) {
    for (int i = 1; i <= cnt; i++)
      for (int j = 1; j <= cnt; j++) s[i][j] = S[i][j];
  }
  Fuck operator*(const Fuck P) const {
    Fuck ans;
    for (int i = 1; i <= cnt; i++)
      for (int j = 1; j <= cnt; j++) ans.s[i][j] = 0;
    for (int i = 1; i <= cnt; i++)
      for (int j = 1; j <= cnt; j++)
        for (int u = 1; u <= cnt; u++)
          ans.s[i][j] =
              (ans.s[i][j] + (long long)s[i][u] * P.s[u][j] % Mod) % Mod;
    return ans;
  }
};
Fuck Quick_Pow(Fuck x, long long T) {
  Fuck ans = x;
  for (; T; T >>= 1) {
    if (T & 1) ans = ans * x;
    x = x * x;
  }
  return ans;
}
int main() {
  Fuck t;
  scanf("%lld%d", &n, &k);
  Pow[0] = 1;
  cnt = (k << 1) + 5;
  for (int i = 0; i <= k; i++) C[0][i] = 1, C[i][i] = 1;
  for (int i = 1; i <= k; i++)
    for (int j = i + 1; j <= k; j++)
      C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % Mod;
  for (int i = 1; i <= k + 1; i++) Pow[i] = Pow[i - 1] * 2 % Mod;
  if (n == 1) {
    printf("1");
    return 0;
  }
  if (n == 2) {
    printf("%d", (Pow[k + 1] + 1) % Mod);
    return 0;
  }
  t.s[1][1] = t.s[2][1] = t.s[1][2] = t.s[3][3] = 1;
  for (int i = 4; i <= 4 + k; i++) t.s[i][3] = C[i - 4][k];
  for (int i = 5 + k; i <= 5 + 2 * k; i++)
    t.s[i][3] = (long long)C[i - 5 - k][k] * Pow[5 + 2 * k - i] % Mod;
  for (int i = 4; i <= 4 + k; i++) {
    for (int j = 4; j <= i; j++) t.s[j][i] = C[j - 4][i - 4];
    for (int j = k + 5; j <= k + i + 1; j++)
      t.s[j][i] = (long long)C[j - k - 5][i - 4] * Pow[k + i + 1 - j] % Mod;
  }
  for (int i = 5 + k; i <= 5 + 2 * k; i++) t.s[i - k - 1][i] = 1;
  t = Quick_Pow(t, n - 3);
  a[1] = 2;
  a[2] = 1;
  a[3] = ((1LL << (k + 1)) + 1) % Mod;
  for (int i = 4; i <= k + 4; i++) a[i] = Pow[i - 3];
  for (int i = k + 5; i <= 2 * k + 5; i++) a[i] = 1;
  for (int i = 1; i <= 2 * k + 5; i++)
    res = (res + (long long)a[i] * t.s[i][3] % Mod) % Mod;
  printf("%d", res);
  return 0;
}