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 long long mod = 1e9 + 7;
long long n, m;
struct mat {
  long long m[88][88];
} ans, a;
void init(mat &a) {
  memset(a.m, 0, sizeof(a.m));
  for (int i = 0; i < 2 * m + 3; i++) a.m[i][i] = 1;
}
mat mul(mat a, mat b) {
  mat c;
  memset(c.m, 0, sizeof(c.m));
  for (int i = 0; i < 2 * m + 3; i++) {
    for (int k = 0; k < 2 * m + 3; k++) {
      if (a.m[i][k] == 0) continue;
      for (int j = 0; j < 2 * m + 3; j++) {
        c.m[i][j] = (c.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
        if (c.m[i][j] < 0) c.m[i][j] += mod;
      }
    }
  }
  return c;
}
mat mat_pow(mat a, long long k) {
  mat b;
  init(b);
  while (k > 0) {
    if (k & 1) b = mul(a, b);
    a = mul(a, a);
    k >>= 1;
  }
  return b;
}
long long power(long long a, long long b) {
  return b ? power(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1;
}
long long C(int n, int k) {
  long long x = 1, y = 1;
  for (int i = 1; i <= k; i++) {
    x = x * (n - i + 1) % mod;
    y = y * i % mod;
  }
  return x * power(y, mod - 2) % mod;
}
int main() {
  memset(a.m, 0, sizeof(a.m));
  cin >> n >> m;
  a.m[0][0] = a.m[0][m + 1] = 1;
  for (int i = 1; i < 2 + m; i++) {
    for (int j = 1; j < 2 + m; j++) {
      if (j <= i)
        a.m[i][j] = C(i - 1, j - 1);
      else
        continue;
    }
  }
  for (int i = 1; i < 2 + m; i++) {
    for (int j = 2 + m; j < 3 + 2 * m; j++) {
      if (j - m - 2 <= i - 1)
        a.m[i][j] = C(i - 1, j - 2 - m);
      else
        continue;
    }
  }
  for (int i = 2 + m; i < 3 + 2 * m; i++) {
    for (int j = 1; j < 2 + m; j++) {
      if (j - 1 <= i - m - 2)
        a.m[i][j] = C(i - 2 - m, j - 1);
      else
        continue;
    }
  }
  memset(ans.m, 0, sizeof(ans.m));
  for (int i = 1; i < 2 * m + 3; i++) ans.m[i][0] = 1;
  ans = mul(mat_pow(a, n), ans);
  cout << ans.m[0][0];
}