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;
struct node {
  long long a[83][83];
};
long long b[51], c[51][51];
node mult(node &x, node &y) {
  int i, j, k;
  long long s;
  node q;
  for (i = 0; i <= 82; i++) {
    for (j = 0; j <= 82; j++) {
      s = 0;
      for (k = 0; k <= 82; k++) s = (s + x.a[i][k] * y.a[k][j]) % 1000000007LL;
      ;
      q.a[i][j] = s;
    }
  }
  return q;
}
node mypow(node &x, long long n) {
  int i, j;
  node ans;
  for (i = 0; i <= 82; i++) {
    for (j = 0; j <= 82; j++) {
      if (i == j)
        ans.a[i][j] = 1;
      else
        ans.a[i][j] = 0;
    }
  }
  for (i = 62; i >= 0; i--) {
    if (n & (1LL << i)) break;
  }
  for (; i >= 0; i--) {
    ans = mult(ans, ans);
    if (n & (1LL << i)) ans = mult(ans, x);
  }
  return ans;
}
int main() {
  long long n, k, s = 0;
  int i, j;
  scanf("%I64d%I64d", &n, &k);
  node x, y;
  b[0] = 1;
  for (i = 0; i <= 48; i++) b[i + 1] = 2 * b[i] % 1000000007LL;
  ;
  for (i = 0; i <= 49; i++) {
    for (j = 0; j <= i; j++) {
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007LL;
      ;
    }
  }
  memset(x.a, 0, sizeof(x.a));
  x.a[82][82] = 1;
  for (i = 0; i <= 40; i++) x.a[i + 41][i] = 1;
  for (i = 0; i <= 40; i++) {
    for (j = 0; j <= 40; j++) {
      if (i <= j) {
        x.a[i][j + 41] = c[j][i] * b[j - i] % 1000000007LL;
        ;
        x.a[i + 41][j + 41] = c[j][i];
      }
    }
  }
  for (i = 0; i <= 40; i++) x.a[82][i + 41] = (b[i] + 1) % 1000000007LL;
  ;
  y = mypow(x, n);
  for (i = 41; i <= 82; i++) s = (s + y.a[i][k]) % 1000000007LL;
  ;
  printf("%I64d\n", s);
  return 0;
}