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 double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const double esp = 1e-6;
const int MAXN = 100;
const int N = 120;
const int MOD = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return b / gcd(a, b) * a; }
long long qpow(long long x, long long n) {
  long long res = 1;
  for (; n; n >>= 1) {
    if (n & 1) res = (res * x) % MOD;
    x = (x * x) % MOD;
  }
  return res;
}
long long C[202][205];
void tab_init() {
  C[0][0] = 1;
  for (int i = 1; i <= 50; i++)
    for (int j = 0; j <= i; j++) {
      C[i][j] = (j == 0) ? 1 : (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
}
long long n, k;
struct Matrix {
  long long arr[N][N];
  void init() {
    memset(arr, 0, sizeof(arr));
    for (int i = 0; i < MAXN; i++) arr[i][i] = 1;
  }
  void iinit() {
    memset(arr, 0, sizeof(arr));
    for (int i = 0; i <= k; i++)
      for (int j = 0; j <= i; j++) {
        arr[i][j] = arr[i + k + 1][j] = arr[i][j + k + 1] = C[i][j];
      }
    arr[2 * k + 2][k] = arr[2 * k + 2][2 * k + 2] = 1;
  }
};
Matrix mul(Matrix X, Matrix Y) {
  Matrix ans;
  for (int i = 0; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++) {
      ans.arr[i][j] = 0;
      for (int k = 0; k < MAXN; k++) {
        ans.arr[i][j] += X.arr[i][k] * Y.arr[k][j];
        ans.arr[i][j] %= MOD;
      }
    }
  return ans;
}
Matrix Q_pow(Matrix B, long long n) {
  Matrix ans;
  ans.init();
  while (n) {
    if (n & 1) ans = mul(ans, B);
    n >>= 1;
    B = mul(B, B);
  }
  return ans;
}
int main() {
  tab_init();
  while (~scanf("%I64d %I64d", &n, &k)) {
    Matrix ans;
    ans.iinit();
    ans = Q_pow(ans, n);
    long long res = 0;
    for (int i = 0; i < 2 * k + 2; i++) res += (ans.arr[2 * k + 2][i]) % MOD;
    printf("%I64d\n", res % MOD);
  }
  return 0;
}