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
#include <bits/stdc++.h>
using namespace std;
struct matrix {
  long long m[90][90];
  matrix() { memset(m, 0, sizeof m); }
  long long *operator[](int i) { return m[i]; }
  friend matrix operator*(const matrix &a, const matrix &b) {
    matrix r;
    for (int i = (0); i < (90); ++i)
      for (int j = (0); j < (90); ++j)
        for (int k = (0); k < (90); ++k)
          r[i][j] =
              (r[i][j] + ((long long)a.m[i][k]) * b.m[k][j]) % (int)(1e9 + 7);
    return r;
  }
};
matrix pow(matrix a, long long e) {
  if (e == 1) return a;
  if (e % 2) return a * pow(a, e - 1);
  a = pow(a, e / 2);
  return a * a;
}
long long n;
int k;
long long C[90][90];
int main() {
  scanf("%I64d %d", &n, &k);
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  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]) % (int)(1e9 + 7);
  }
  matrix a, b;
  k++;
  for (int i = 0; i < k; ++i) {
    a[i][0] = 2;
    a[i + k][0] = 1;
    for (int j = 0; j < i; ++j) a[i][0] = (2L * a[i][0]) % (int)(1e9 + 7);
  }
  a[2 * k][0] = 1;
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j <= i; ++j) {
      b[i][j] = b[i][j + k] = C[i][j];
      for (int d = 0; d < i - j; ++d)
        b[i][j + k] = (2L * b[i][j + k]) % (int)(1e9 + 7);
    }
    b[i + k][i] = 1;
  }
  b[2 * k][k - 1] = 1;
  b[2 * k][2 * k] = 1;
  matrix ret = pow(b, n - 1) * a;
  printf("%d\n", (int)ret[2 * k][0]);
  return 0;
}
