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;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
struct Matrix {
  int n, m;
  long long a[105][105];
  Matrix() {}
  Matrix(int n, int m) : n(n), m(m) {}
  void init(long long num) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[i][j] = num;
  }
  Matrix operator*(Matrix b) {
    Matrix o = Matrix(n, b.m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < b.m; j++) {
        o.a[i][j] = 0;
        for (int k = 0; k < m; k++) {
          o.a[i][j] =
              (o.a[i][j] + (a[i][k] * b.a[k][j]) % 1000000007) % 1000000007;
        }
      }
    }
    return o;
  }
  Matrix pow(long long p) {
    Matrix o = Matrix(n, m);
    Matrix b = *this;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) o.a[i][j] = (i == j);
    while (p > 0) {
      if (p & 1) o = o * b;
      b = b * b;
      p >>= 1;
    }
    return o;
  }
};
Matrix base;
long long p2[105], C[105][105];
void init(int n) {
  C[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;
    }
  }
}
void pp() {
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    for (int(j) = 0; (j) < (int)(n); (j)++) printf("%lld ", base.a[i][j]);
    puts("");
  }
}
void cal() {
  base.init(0);
  for (int(i) = 0; (i) < (int)(n); (i)++) base.a[0][i] = i == 0 || i == k + 1;
  for (int i = 1; i <= k + 1; i++) {
    for (int j = 0; j <= i - 1; j++) {
      base.a[i][j + 1] = C[i - 1][j];
      base.a[i][j + 1 + k + 1] = C[i - 1][j] * p2[(i - 1) - j] % 1000000007;
    }
  }
  for (int i = k + 2, j = 1; i < n; i++, j++) {
    base.a[i][j] = 1;
  }
  Matrix x = Matrix(n, 1);
  for (int(i) = 1; (i) <= (int)(k + 1); (i)++) {
    x.a[i][0] = p2[i];
  }
  for (int i = k + 2; i < n; i++) x.a[i][0] = 1;
  x.a[0][0] = 1;
  Matrix ans = base.pow(ln - 1) * x;
  printf("%lld\n", ans.a[0][0]);
}
int main() {
  scanf("%lld%d", &ln, &k);
  n = 2 * (k + 1) + 1;
  base = Matrix(n, n);
  p2[0] = 1;
  for (int(i) = 1; (i) <= (int)(k + 5); (i)++)
    p2[i] = p2[i - 1] * 2 % 1000000007;
  init(k);
  cal();
  return 0;
}