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 K = 47;
const int MOD = 1e9 + 7;
long long n, ans;
int k;
long long dwumian[K][K];
vector<int> vec;
struct mat {
  long long m[2 * K][2 * K];
  mat() {
    for (int i = 0; i < 2 * K; ++i) memset(m[i], 0, sizeof m[i]);
  }
};
mat operator*(mat &a, mat &b) {
  mat res;
  for (int i = 0; i <= 2 * k + 2; ++i) {
    for (int j = 0; j <= 2 * k + 2; ++j) {
      for (int l = 0; l <= 2 * k + 2; ++l) {
        res.m[i][j] += (a.m[i][l] * b.m[l][j]) % MOD;
      }
      res.m[i][j] %= MOD;
    }
  }
  return res;
}
mat pot(mat a, long long p) {
  mat res;
  for (int i = 0; i <= 2 * k + 2; ++i) {
    res.m[i][i] = 1;
  }
  for (int i = 0; i < 60; ++i) {
    if (p & (1ll << i)) res = res * a;
    a = a * a;
  }
  return res;
}
long long fpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a % MOD;
  if (b % 2)
    return a * fpow(a, b - 1) % MOD;
  else {
    long long q = fpow(a, b / 2);
    return q * q % MOD;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> k;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  for (int i = 0; i <= k; ++i) {
    dwumian[i][0] = 1;
  }
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      dwumian[i][j] = (dwumian[i - 1][j - 1] + dwumian[i - 1][j]) % MOD;
    }
  }
  mat f;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= i; ++j) {
      f.m[i][j] = dwumian[i][j];
      f.m[i][k + 1 + j] = (1ll << (i - j)) % MOD * dwumian[i][j] % MOD;
      f.m[k + 1 + i][i] = 1;
    }
  }
  for (int i = 0; i <= 2 * k + 2; ++i) {
    f.m[2 * k + 2][i] = f.m[k][i];
  }
  f.m[2 * k + 2][2 * k + 2] = 1;
  n -= 2;
  f = pot(f, n);
  for (int i = 0; i <= k; ++i) {
    vec.push_back(2 * fpow(2, i));
  }
  for (int i = 0; i <= k; ++i) {
    vec.push_back(1 * fpow(1, i));
  }
  vec.push_back(vec[k] + vec[2 * k + 1]);
  for (int i = 0; i <= 2 * k + 2; ++i) {
    ans += f.m[2 * k + 2][i] * vec[i];
    ans %= MOD;
  }
  cout << ans;
}