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 LIM = 90;
const int SIZE = 50;
const long long MOD = 1e9 + 7;
long long n, C[SIZE][SIZE];
int k;
struct Matrix {
  long long v[LIM][LIM];
  int size;
  Matrix operator*(const Matrix &m) const {
    Matrix ret = {{0}};
    ret.size = size;
    for (int i = 0; i < size; i++)
      for (int k = 0; k < size; k++)
        if (v[i][k])
          for (int j = 0; j < size; j++)
            ret.v[i][j] = (ret.v[i][j] + v[i][k] * m.v[k][j] % MOD) % MOD;
    return ret;
  }
};
Matrix fastPow(long long p, Matrix base) {
  Matrix ret = {{0}};
  ret.size = base.size;
  for (int i = 0; i < ret.size; i++) ret.v[i][i] = 1;
  while (p) {
    if (p & 1) ret = base * ret;
    p >>= 1;
    if (p) base = base * base;
  }
  return ret;
}
void buildC() {
  for (int i = 0; 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]) % MOD;
  }
}
int main(void) {
  scanf("%lld%d", &n, &k);
  buildC();
  Matrix base = {{0}};
  base.size = (k + 1) * 2 + 1;
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= i; j++)
      base.v[i][j] = base.v[i][j + k + 1] = base.v[i + k + 1][j] = C[i][j];
  base.v[base.size - 1][base.size - 1] = base.v[base.size - 1][k] = 1;
  base = fastPow(n, base);
  long long ans = 0;
  for (int i = 0; i < base.size - 1; i++)
    ans = (ans + base.v[base.size - 1][i]) % MOD;
  printf("%lld\n", ans);
  return 0;
}