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;
int k, A[50], C[50][50], fn1, fn2, exp_2[50], exp_n1[50], exp_n2[50];
long long n;
pair<int, int> f(long long m) {
  if (m == -1) return make_pair(0, 1);
  if (m == 0) return make_pair(1, 1);
  if (m == 1 || m == 2) return make_pair(m, m + 1);
  if (m == 3) return make_pair(3, 5);
  long long n = m / 2;
  pair<int, int> p = f(n - 1);
  if (m % 2 == 0)
    return make_pair(
        ((1ll * p.first * p.first) % 1000000007 +
         (1ll * p.second * p.second) % 1000000007) %
            1000000007,
        (1ll * p.second * (p.second + 2ll * p.first)) % 1000000007);
  return make_pair(((1ll * p.second * (p.second + 2ll * p.first))) % 1000000007,
                   ((1ll * p.second * (p.second + 2ll * p.first)) % 1000000007 +
                    ((1ll * p.first * p.first) % 1000000007 +
                     (1ll * p.second * p.second) % 1000000007) %
                        1000000007) %
                       1000000007);
}
void calc() {
  for (int j = 1; j < 50; j++)
    for (int i = 0; i <= j; i++) {
      if (j == 1)
        C[i][1] = 1;
      else if (i == 0 || i == j)
        C[i][j] = 1;
      else
        C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % 1000000007;
    }
  for (int i = 0; i < 50; i++) {
    if (i == 0)
      exp_2[0] = 1, exp_n1[0] = 1, exp_n2[0] = 1;
    else
      exp_2[i] = (2ll * exp_2[i - 1]) % 1000000007,
      exp_n1[i] = (1ll * exp_n1[i - 1] * (n % 1000000007 + 1)) % 1000000007,
      exp_n2[i] = (1ll * exp_n2[i - 1] * (n % 1000000007 + 2)) % 1000000007;
  }
  fn1 = f(n + 1).first, fn2 = f(n + 1).second;
  for (int i = 0; i <= k; i++) {
    if (i == 0)
      A[0] = (fn2 - 2) % 1000000007;
    else {
      A[i] = (exp_2[i + 1] - (1ll * exp_n2[i] * fn2) % 1000000007) % 1000000007;
      for (int j = 1; j <= i; j++) {
        A[i] += (1ll * C[j][i] *
                 ((1ll * A[i - j] * (exp_2[j] + 1)) % 1000000007 +
                  (1ll * exp_n1[i - j] * fn1) % 1000000007 - 1)) %
                1000000007;
        A[i] %= 1000000007;
      }
      A[i] = (-A[i]) % 1000000007;
    }
  }
  A[k] = (A[k] + 1000000007) % 1000000007;
  printf("%d", A[k]);
}
int main() {
  scanf("%I64d %d", &n, &k);
  calc();
}