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 = (2 * 40) + 4, mod = 1e9 + 7, LOG = 60;
int k, poww[maxn], intk[maxn][maxn];
long long n;
struct matrix {
  int mat[maxn][maxn];
  int n;
  int m;
  matrix(int a, int b) {
    n = a;
    m = b;
    for (int i = 0; i < maxn; i++) {
      for (int j = 0; j < maxn; j++) {
        mat[i][j] = 0;
      }
    }
  }
  int* operator[](int x) { return mat[x]; }
};
matrix operator*(matrix a, matrix b) {
  matrix res(a.n, b.m);
  for (int i = 0; i < res.n; i++) {
    for (int k = 0; k < a.m; k++) {
      for (int j = 0; j < res.m; j++) {
        res[i][j] = (res[i][j] + (1ll * a[i][k] * b[k][j])) % mod;
      }
    }
  }
  return res;
}
matrix Identity(int x) {
  matrix res(x, x);
  for (int i = 0; i < x; i++) {
    res[i][i] = 1;
  }
  return res;
}
matrix operator^(matrix a, long long b) {
  matrix res = Identity(a.n);
  matrix tmp = a;
  for (int i = 0; i <= LOG; i++) {
    if ((1ll << i) & b) {
      res = res * tmp;
    }
    if ((1ll << i) >= b) {
      break;
    }
    tmp = tmp * tmp;
  }
  return res;
}
void prepare() {
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i) {
        intk[i][j] = 1;
        continue;
      }
      intk[i][j] = (intk[i - 1][j - 1] + intk[i - 1][j]) % mod;
    }
  }
  return;
}
void chap(matrix t) {
  for (int i = 0; i < t.n; i++) {
    for (int j = 0; j < t.m; j++) {
      cout << t[i][j] << " ";
    }
    cout << endl;
  }
}
int main() {
  cin >> n >> k;
  prepare();
  matrix p(2 * k + 3, 2 * k + 3);
  matrix ans(1, 2 * k + 3);
  poww[0] = 1;
  for (int i = 1; i <= k + 1; i++) {
    poww[i] = (poww[i - 1] * 2) % mod;
  }
  for (int i = 0; i <= k; i++) {
    ans[0][i] = poww[k - i + 1];
  }
  for (int i = k + 1; i <= 2 * k + 1; i++) {
    ans[0][i] = 1;
  }
  ans[0][2 * k + 2] = 1;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) {
      p[i][j] = intk[k - j][k - i];
    }
  }
  for (int i = k + 1; i <= 2 * k + 1; i++) {
    for (int j = 0; j <= (i - k - 1); j++) {
      p[i][j] = (1ll * intk[k - j][k - (i - k - 1)] *
                 poww[k - j - (k - (i - k - 1))]) %
                mod;
    }
  }
  for (int i = k + 1; i <= 2 * k + 1; i++) {
    p[i - k - 1][i] = 1;
  }
  p[0][2 * k + 2] = 1;
  p[2 * k + 2][2 * k + 2] = 1;
  p = p ^ (n - 1);
  ans = ans * p;
  cout << ans[0][2 * k + 2] << endl;
  return 0;
}