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 maxn = 85;
const long long mod = 1e9 + 7;
long long c[50][50], pw2[50];
void init() {
  pw2[0] = c[0][0] = 1;
  for (int i = 1; i <= 43; ++i) {
    c[i][0] = c[i][i] = 1;
    pw2[i] = pw2[i - 1] * 2 % mod;
    for (int j = 1; j < i; ++j) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
  }
}
struct Mat {
  long long m[maxn][maxn];
};
Mat Mul_Mat(Mat a, Mat b, int n, int m) {
  Mat ret;
  memset(ret.m, 0, sizeof ret.m);
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      for (int k = 0; k <= m; ++k) {
        ret.m[i][j] = (ret.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
      }
    }
  }
  return ret;
}
Mat pow_Mat(Mat b, long long p, int k) {
  Mat ret;
  memset(ret.m, 0, sizeof ret.m);
  for (int i = 0; i <= k; ++i) ret.m[i][i] = 1;
  while (p) {
    if (p & 1) ret = Mul_Mat(ret, b, k, k);
    b = Mul_Mat(b, b, k, k);
    p >>= 1;
  }
  return ret;
}
Mat a, b;
void Work(int k) {
  memset(b.m, 0, sizeof b.m);
  memset(a.m, 0, sizeof a.m);
  for (int i = 0; i <= k; ++i) {
    a.m[0][i] = pw2[i + 1];
    for (int j = 0; j <= i; ++j) {
      b.m[j][i] = c[i][j];
      b.m[j + k + 1][i] = c[i][j] * pw2[i - j] % mod;
    }
    a.m[0][i + k + 1] = b.m[i][i + k + 1] = 1;
    b.m[i][2 * k + 2] = c[k][i];
    b.m[i + k + 1][2 * k + 2] = c[k][i] * pw2[k - i] % mod;
  }
  b.m[2 * k + 2][2 * k + 2] = 1;
  a.m[0][2 * k + 2] = (1 + pw2[k + 1]) % mod;
}
int main() {
  init();
  long long n;
  int k;
  while (~scanf("%I64d%d", &n, &k)) {
    if (n == 1)
      printf("1\n");
    else {
      Work(k);
      n -= 2;
      b = pow_Mat(b, n, 2 * k + 2);
      a = Mul_Mat(a, b, 0, 2 * k + 2);
      printf("%I64d\n", a.m[0][2 * k + 2]);
    }
  }
  return 0;
}