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;
long long n;
int k, C[50][50], pw[50], p1[50], p2[50];
pair<int, int> fib(long long x) {
  if (!x) return make_pair(1, 1);
  pair<int, int> ff;
  if (x % 2) {
    ff = fib((x - 1) / 2);
    return make_pair(
        (int)(1LL * ff.first * (2ll * ff.second - ff.first) % 1000000007),
        (int)(1LL * ff.first * ff.first % 1000000007 +
              1ll * ff.second * ff.second % 1000000007) %
            1000000007);
  } else {
    ff = fib((x - 2) / 2);
    return make_pair(
        (int)(1LL * ff.first * ff.first % 1000000007 +
              1ll * ff.second * ff.second % 1000000007) %
            1000000007,
        (int)(1LL * ff.second * (ff.second + 2ll * ff.first) % 1000000007));
  }
}
int calc(long long n, int k) {
  int ans[50], f2 = fib(n + 2).first, f1 = fib(n + 1).first;
  ans[0] = (f2 - 2) % 1000000007;
  for (int i = 1; i <= k; i++) {
    ans[i] = (pw[i + 1] - (1ll * p2[i] * f2) % 1000000007) % 1000000007;
    for (int j = 1; j <= i; j++) {
      ans[i] += (1ll * C[i][j] *
                 ((1ll * ans[i - j] * (pw[j] + 1)) % 1000000007 +
                  (1ll * p1[i - j] * f1) % 1000000007 - 1)) %
                1000000007;
      ans[i] %= 1000000007;
    }
    ans[i] = (-ans[i]) % 1000000007;
  }
  return (ans[k] + 1000000007) % 1000000007;
}
int main() {
  scanf("%I64d %d", &n, &k);
  for (int i = 0; i < 50; i++) C[i][0] = 1, C[i][i] = 1;
  for (int i = 1; i < 50; i++) {
    for (int j = 1; j < i; j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
      C[i][j] %= 1000000007;
    }
  }
  for (int i = 0; i < 50; i++) {
    if (i == 0)
      pw[0] = 1, p1[0] = 1, p2[0] = 1;
    else
      pw[i] = (2ll * pw[i - 1]) % 1000000007,
      p1[i] = (1ll * p1[i - 1] * (n % 1000000007 + 1)) % 1000000007,
      p2[i] = (1ll * p2[i - 1] * (n % 1000000007 + 2)) % 1000000007;
  }
  printf("%d\n", calc(n, k));
}