Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. 

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 -----
Subtask 1 : [10 points]  
1 ≤ Q ≤ 50 
1 ≤  X  ≤ 10^{9}  
1 ≤  K  ≤  4  

Subtask 2 : [20 points]  
1 ≤ Q ≤ 100 
1 ≤  X  ≤ 10^{9}  
1 ≤  K  ≤  5  

Subtask 3 : [20 points]
1 ≤ Q ≤ 100 
1 ≤  X  ≤ 10^{2}  
1 ≤  K  ≤  10  

Subtask 4 : [50 points]
1 ≤ Q ≤ 100 
1 ≤  X  ≤ 10^{9} 
1 ≤  K  ≤  10  

----- Sample Input 1 ------ 
5

12 1

13 1

13 2

13 3

13 4
----- Sample Output 1 ------ 
0

1

1

2

4
----- explanation 1 ------ 

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

Difficulty: HARD

Solutions:
from collections import Counter
dp = [0] * 44
dp[0] = 1
dp[1] = 2
for i in range(2, 44):
	dp[i] = dp[i - 1] + dp[i - 2]

def solve(x, k, n):
	if k == 0:
		if x == 0:
			return 1
		else:
			return 0
	elif x == 0 or n == 0:
		return 0
	elif x >= 0 and x <= k * dp[n - 1]:
		return solve(x, k, n - 1) + solve(x - dp[n - 1], k - 1, n)
	return 0
T = int(input())
while T:
	T -= 1
	(x, k) = map(int, input().split())
	print(solve(x, k, 43))


chefonacci = [0] * 44
chefonacci[0] = 1
chefonacci[1] = 2
for i in range(2, 44):
	chefonacci[i] = chefonacci[i - 1] + chefonacci[i - 2]

def no_of_ways(x, k, index):
	if k == 0:
		if x == 0:
			return 1
		else:
			return 0
	elif x == 0 or index == 0:
		return 0
	elif x >= 0 and x <= k * chefonacci[index]:
		return no_of_ways(x, k, index - 1) + no_of_ways(x - chefonacci[index - 1], k - 1, index)
	return 0
for i in range(int(input())):
	(x, k) = map(int, input().split())
	global index_1
	for i in chefonacci:
		if i > x:
			index_1 = chefonacci.index(i)
	print(no_of_ways(x, k, index_1))


f = [1, 2]
f1 = 1
f2 = 2
while True:
	f3 = f2 + f1
	if f3 > 10 ** 9:
		break
	f.append(f3)
	f1 = f2
	f2 = f3

def F(x, k, n):
	if x < 0:
		return 0
	if k == 0:
		if x == 0:
			return 1
		else:
			return 0
	if x == 0 or n == 0:
		return 0
	total = F(x, k, n - 1)
	if x >= f[n - 1] and x <= k * f[n - 1]:
		total += F(x - f[n - 1], k - 1, n)
	return total
Q = int(input())
for q in range(Q):
	(X, K) = list(map(int, input().split()))
	print(F(X, K, len(f)))


def chefonacci(n):
	f = []
	for val in range(n):
		if val == 0:
			f.append(1)
		if val == 1:
			f.append(2)
		if val > 1:
			f.append(f[val - 1] + f[val - 2])
	return f

def F(x, k, n):
	if k > 0 and x < k * f[0] and (x >= 0):
		return 0
	if x < 0:
		return 0
	if K == 1:
		for val in f:
			if val == X:
				return 1
		return 0
	if k == 0:
		if x == 0:
			return 1
		else:
			return 0
	elif x == 0 or n == 0:
		return 0
	else:
		total = F(x, k, n - 1)
		if x >= f[n - 1] and x <= k * f[n - 1]:
			total += F(x - f[n - 1], k - 1, n)
		return total

def compute_answer(X, K):
	return F(X, K, 43)
f = chefonacci(44)
Q = int(input())
for case in range(Q):
	(X, K) = list(map(int, input().split()))
	number = compute_answer(X, K)
	print(number)


from functools import *

@lru_cache(maxsize=None)
def change(X, k, i):
	if chefo[i] * k < X:
		return 0
	if k == 0 and X == 0:
		return 1
	if k == 0 and X != 0:
		return 0
	if X < 0:
		return 0
	if X == 0 and k != 0:
		return 0
	if k == 1:
		if chefo[i] == X:
			return 1
	if i < 0:
		return 0
	return change(X - chefo[i], k - 1, i) + change(X, k, i - 1)
d = {1: 0, 2: 1}
chefo = [1, 2]
i = 2
while chefo[-1] < 10 ** 9:
	chefo.append(chefo[-1] + chefo[-2])
	d[chefo[-1]] = i
	i += 1
q = int(input())
for i in range(q):
	s = input().split()
	X = int(s[0])
	k = int(s[1])
	for j in range(len(chefo)):
		if chefo[j] > X:
			break
	print(change(int(s[0]), int(s[1]), j - 1) % 1000000007)


def solve(x, k, n):
	if k == 0:
		if x == 0:
			return 1
		else:
			return 0
	elif x == 0 or n == 0:
		return 0
	else:
		total = solve(x, k, n - 1)
		if x >= chef[n - 1] and x <= k * chef[n - 1]:
			total += solve(x - chef[n - 1], k - 1, n)
		return total
chef = [0] * 50
(chef[0], chef[1]) = (1, 2)
for i in range(2, 50):
	chef[i] = chef[i - 1] + chef[i - 2]
for _ in range(int(input())):
	(x, k) = map(int, input().split())
	print(solve(x, k, 43))


def solve(x, k, n):
	if k == 0:
		if x == 0:
			return 1
		else:
			return 0
	elif x == 0 or n == 0:
		return 0
	else:
		total = solve(x, k, n - 1)
		if x >= chef[n - 1] and x <= k * chef[n - 1]:
			total += solve(x - chef[n - 1], k - 1, n)
		return total
mod = int(1000000000.0 + 7)
chef = [0] * 45
(chef[0], chef[1]) = (1, 2)
for i in range(2, 45):
	chef[i] = chef[i - 1] + chef[i - 2]
for _ in range(int(input())):
	(x, k) = map(int, input().split())
	print(solve(x, k, 43) % mod)


import sys
sys.setrecursionlimit(10000000)
N = 1000000000
fib = [1, 2]
while True:
	val = fib[-1] + fib[-2]
	if val > N:
		break
	fib.append(val)

def getans(i, x, k):
	if x < 0 or (k == 0 and x > 0) or i < 0 or (k * fib[i] < x):
		return 0
	if x == 0 and k == 0:
		return 1
	ans = getans(i, x - fib[i], k - 1) + getans(i - 1, x, k)
	return ans
for _ in range(int(input())):
	(x, k) = list(map(int, input().split()))
	print(getans(len(fib) - 1, x, k))


mod = 10 ** 9 + 7
fib = [1, 2]
while fib[-1] < 10 ** 9:
	fib.append(fib[-1] + fib[-2])
fibs = set(fib)
cache = {}

def ways(num, parts, maxused):
	if num == 0 and parts == 0:
		return 1
	if parts == 0 or maxused == 1:
		return 0
	if parts * maxused < num:
		return 0
	if parts == 1:
		return 1 if num < maxused and num in fibs else 0
	if maxused > num and (num, parts) in cache:
		return cache[num, parts]
	res = 0
	i = 0
	while fib[i] <= num and fib[i] < maxused:
		k = 1
		while k * fib[i] <= num and k <= parts:
			res = res + ways(num - k * fib[i], parts - k, fib[i])
			k += 1
		i += 1
		res %= mod
	if maxused > num:
		cache[num, parts] = res
	return res
for _ in range(int(input())):
	(x, k) = map(int, input().split())
	print(ways(x, k, x + 1))


cn = [0] * 44
(cn[1], cn[0]) = (2, 1)
for i in range(2, 44):
	cn[i] = cn[i - 1] + cn[i - 2]

def findWays(x, k, ind):
	if k == 0:
		return 1 if x == 0 else 0
	elif x == 0 or ind == 0:
		return 0
	else:
		if x >= 0 and k * cn[ind] >= x:
			return findWays(x - cn[ind - 1], k - 1, ind) + findWays(x, k, ind - 1)
		return 0
q = int(input())
for _ in range(q):
	(x, k) = map(int, input().split())
	for i in cn:
		if i > x:
			ind = cn.index(i)
	print(findWays(x, k, ind))


MOD = 1000000007
fib = [1, 2]
for i in range(2, 50):
	fib.append(fib[i - 1] + fib[i - 2])

def solve(x, k, n):
	if k == 0:
		return int(x == 0)
	ans = 0
	for i in range(n, -1, -1):
		if fib[i] * k < x:
			return ans
		if fib[i] <= x:
			ans = (ans + solve(x - fib[i], k - 1, i)) % MOD
	return ans
for i in range(int(input().strip())):
	(x, k) = map(int, input().split())
	print(solve(x, k, 43))