P13377 [CodeChef] chefmath
普及
题目描述

Chef's team is going to participate at the legendary math battles. One of the main task in the competition is to calculate the number of ways to create a number by adding some Chefonacci numbers. A number is called a Chefonacci number if it is an element of Chefonacci sequence defined as follows.

f(0) = 1;
f(1) = 2;
For i > 1 : f(i) = f(i - 1) + f(i - 2)

Chef asked you to help him with this task. There will be Q question of form X, K : How many different ways are there to create X by adding K Chefonacci numbers. Note that the order of numbers in the addition does not matter, i.e. (f(i) + f(j) + f(k)) and (f(j) + f(i) + f(k)) will not be counted as distinct ways. Also note that you are allowed to use a Chefonacci number any number of times (zero or more).

As the answer could be large, print your answer modulo 10^9 + 7 (1000000007).

Input

First line of the input contains an integer Q denoting number of questions Chef was asked.

In the next Q lines follow the questions, i-th of the line will denote the i-th question represented by two space separated integer X, K respectively.

Output

For each question, output a separate line containing the answer of the question.

Constraints and Example

Input:
5
12 1
13 1
13 2
13 3
13 4

Output:
0
1
1
2
4

Explanation

Example case 1.
There is no way to create 12 by adding one Chefonacci number, as 12 is not a Chefonacci number.

Example case 2.
There is only one way to create 13 by adding one Chefonacci number, i.e. 13.

Example case 3.
There is one way to create 13 by adding two Chefonacci numbers, i.e. 5 + 8.

Example case 4.
There are two ways to create 13 by adding three Chefonacci numbers: 2 + 3 + 8, 3 + 5 + 5.

Example case 5.
There are four ways to create 13 by adding four Chefonacci numbers: 1 + 1 + 3 + 8, 1 + 2 + 2 + 8, 1 + 2 + 5 + 5, 2 + 3 + 3 + 5

输入格式

见题面

输出格式

见题面

样例输入
5 12 1 13 1 13 2 13 3 13 4
样例输出
0 1 1 2 4