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 N = 45;
const int mod = 1000000007;
long long n;
int k;
int w[N], C[N][N];
int fpow(int a, int b) {
  int r(1);
  while (b) {
    if (b & 1) r = (long long)r * a % mod;
    a = (long long)a * a % mod;
    b >>= 1;
  }
  return r;
}
struct mat {
  int a[2][2];
  mat(int o = 0) {
    a[0][0] = a[1][1] = o;
    a[0][1] = a[1][0] = 0;
  }
  void operator*=(const mat &y) {
    static long long Tmp[N][N];
    int i, j, k;
    for (i = 0; i < 2; i++)
      for (j = 0; j < 2; j++)
        for (Tmp[i][j] = k = 0; k < 2; k++)
          Tmp[i][j] += (long long)a[i][k] * y.a[k][j];
    for (i = 0; i < 2; i++)
      for (j = 0; j < 2; j++) a[i][j] = Tmp[i][j] % mod;
  }
  void operator+=(const mat &y) {
    int i, j;
    for (i = 0; i < 2; i++)
      for (j = 0; j < 2; j++) a[i][j] = (a[i][j] + y.a[i][j]) % mod;
  }
  void operator*=(const int y) {
    int i, j;
    for (i = 0; i < 2; i++)
      for (j = 0; j < 2; j++) a[i][j] = (long long)a[i][j] * y % mod;
  }
} a, b[N], t[N], tmp;
mat fpow(const mat &a, long long n) {
  mat x = mat(1);
  mat y = a;
  while (n) {
    if (n & 1) x *= y;
    y *= y;
    n >>= 1;
  }
  return x;
}
void init() {
  C[0][0] = 1;
  for (int i = 1; i <= k; 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;
  }
}
void solve(long long n) {
  if (n == 1) {
    for (int i = 0; i <= k; i++) b[i] = a;
    tmp = a;
    return;
  }
  long long mid = n >> 1;
  solve(mid);
  for (int i = 0; i <= k; i++) {
    t[i] = b[i];
    b[i] = mat();
  }
  w[0] = 1;
  for (int i = 1, o = mid % mod; i <= k; i++)
    w[i] = (long long)w[i - 1] * o % mod;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) {
      mat now = t[j];
      now *= ((long long)C[i][j] * w[i - j] % mod);
      b[i] += now;
    }
    b[i] *= tmp;
  }
  for (int i = 0; i <= k; i++) b[i] += t[i];
  tmp *= tmp;
  if (n & 1) {
    tmp *= a;
    w[0] = 1;
    for (int i = 0, o = n % mod; i <= k; i++) {
      t[i] = tmp;
      t[i] *= w[0];
      b[i] += t[i];
      w[0] = (long long)w[0] * o % mod;
    }
  }
}
int main() {
  scanf("%lld %d", &n, &k);
  a.a[0][0] = a.a[0][1] = a.a[1][0] = 1;
  a.a[1][1] = 0;
  init();
  solve(n);
  printf("%d", b[k].a[0][0]);
  return 0;
}