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 mod = 1000000007;
long long n, m, lim;
long long C[41][41], a[90], b[90][90];
inline void mul1(long long a[90], long long b[90][90]) {
  int i, j;
  long long c[90];
  memset(c, 0, sizeof(c));
  for (int i = 0; i <= lim; i++) {
    for (int j = 0; j <= lim; j++) {
      c[j] = (a[i] * b[i][j] + c[j]) % mod;
    }
  }
  for (int i = 0; i <= lim; i++) {
    a[i] = c[i];
  }
}
inline void mul2(long long a[90][90], long long b[90][90]) {
  int i, j, k;
  long long c[90][90];
  memset(c, 0, sizeof(c));
  for (int i = 0; i <= lim; i++) {
    for (int j = 0; j <= lim; j++) {
      for (int k = 0; k <= lim; k++) {
        c[i][k] = (a[i][j] * b[j][k] + c[i][k]) % mod;
      }
    }
  }
  for (int i = 0; i <= lim; i++) {
    for (int j = 0; j <= lim; j++) {
      a[i][j] = c[i][j];
    }
  }
}
int main() {
  scanf("%I64d%I64d", &n, &m);
  lim = m + m + 2;
  for (int i = 0; i <= m; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    }
  }
  for (int i = 0; i < lim; i++) a[i] = 1;
  b[lim - 1][lim] = b[lim][lim] = 1;
  for (int i = 0; i <= m; i++) {
    for (int j = i; j <= m; j++) {
      b[i][j + m + 1] = b[i + m + 1][j + m + 1] = b[i + m + 1][j] = C[j][i];
    }
  }
  while (n) {
    if (n & 1) mul1(a, b);
    mul2(b, b);
    n >>= 1;
  }
  printf("%I64d\n", a[lim]);
  return 0;
}