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 M = 1000000007;
struct mat {
  int a[2][2];
  mat() { memset(a, 0, sizeof a); }
  int *operator[](int x) { return a[x]; }
  const int *operator[](int x) const { return a[x]; }
};
mat operator+(const mat &a, const mat &b) {
  mat c;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) c[i][j] = (a[i][j] + b[i][j]) % M;
  return c;
}
mat operator*(const mat &a, const mat &b) {
  mat c;
  for (int k = 0; k < 2; ++k)
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) (c[i][j] += 1LL * a[i][k] * b[k][j] % M) %= M;
  return c;
}
mat operator*(const mat &a, int la) {
  mat c = a;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) c[i][j] = 1LL * c[i][j] * la % M;
  return c;
}
mat T;
long long n;
int k;
int C[41][41];
mat power(mat x, long long y) {
  mat p;
  p[0][0] = p[1][1] = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) p = p * x;
  return p;
}
int power(int x, int y) {
  int p = 1;
  for (; y; y >>= 1, x = 1LL * x * x % M)
    if (y & 1) p = 1LL * p * x % M;
  return p;
}
vector<mat> solve(long long n) {
  if (n == 1) return vector<mat>(k + 1, T);
  long long half = n / 2;
  vector<mat> f(k + 1), g = solve(half);
  mat t = power(T, half);
  for (int m = 0; m <= k; ++m) {
    mat s;
    int phalf = 1;
    for (int j = m; j >= 0; --j) {
      f[m] = f[m] + (g[j] * phalf * C[m][j]);
      phalf = 1LL * phalf * (half % M) % M;
    }
    f[m] = t * f[m] + g[m];
  }
  if (n & 1) {
    mat t = power(T, n);
    for (int i = 0; i <= k; ++i) f[i] = f[i] + t * power(n % M, i);
  }
  return f;
}
int main() {
  scanf("%lld%d", &n, &k);
  T[0][0] = T[0][1] = T[1][0] = 1;
  T[1][1] = 0;
  C[0][0] = 1;
  for (int i = 1; i <= k; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % M;
  }
  printf("%d\n", solve(n)[k][0][0]);
  return 0;
}