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 JAVA):

Solution:
import java.util.*;
public class C
{
	public static final int MOD = 1000000007;
	
	public static long[][] matrix;
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		
		long n = in.nextLong();
		int k = in.nextInt();
		
		long[][] combinations = pascal(k + 1);
		
		int[][] init = new int[2 * k + 3][1];
		init[0][0] = 1;
		for(int x = k + 1; x < (k << 1) + 2; x++)
		{
			init[x][0] = 1;
		}
		
		int[][] matrix = new int[2 * k + 3][2 * k + 3];
		
		for(int y = 0; y <= k; y++)
		{
			matrix[y][k + 1 + y] = 1;
			
			for(int z = 0; z <= y; z++)
			{
				matrix[k + 1 + y][z] = (int)((combinations[y][z] * ((1L << (y - z)) % MOD)) % MOD);
				matrix[k + 1 + y][k + 1 + z] = (int)combinations[y][z];
			}
		}
		
		matrix[2 * k + 2][2 * k + 1] = 1;
		matrix[2 * k + 2][2 * k + 2] = 1;
		
		matrix = exp(matrix, n);
		
		System.out.println(mult(matrix, init)[(k << 1) + 2][0]);
	}
	
	public static long[][] pascal(int n)
	{
		long[][] combinations = new long[n][n];
		
		for(int i = 0; i < n; i++)
		{
			combinations[i][0] = 1;
		}
		
		for(int j = 1; j < n; j++)
		{
			for(int k = 1; k < n; k++)
			{
				combinations[j][k] = (combinations[j - 1][k - 1] + combinations[j - 1][k]) % MOD;
			}
		}
		
		return combinations;
	}
	
	public static int[][] exp(int[][] matrix, long pow)
	{
		if(pow == 0)
		{
			int[][] ret = new int[matrix.length][matrix.length];
			
			for(int i = 0; i < ret.length; i++)
			{
				ret[i][i] = 1;
			}
			
			return ret;
		}
		else
		{
			int[][] ret = exp(matrix, pow >> 1);
			ret = mult(ret, ret);
			if((pow & 1) == 1)
			{
				ret = mult(ret, matrix);
			}
			
			return ret;
		}
	}
	
	public static int[][] mult(int[][] a, int[][] b)
	{
		int[][] ret = new int[a.length][b[0].length];
		
		for(int r = 0; r < ret.length; r++)
		{
			for(int c = 0; c < ret[r].length; c++)
			{
				for(int i = 0; i < a[0].length; i++)
				{
					ret[r][c] = (int)((ret[r][c] + (long)a[r][i] * b[i][c]) % MOD);
				}
			}
		}
		
		return ret;
	}
}