题目描述
You have N numbers from 1 to N. Now Permutations of N numbers of having length N means Reorder all numbers in all possible orders. Like for N=3 ,
6 Permutations are possible.
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
In General for N numbers you can represent Permutations as P1 , P2 , P3 .... PN
Now You need to find number of permutations of length N such that
| 3P(i)-2P(i+1) | ≤ k for 1 ≤ i ≤ n-1
considering P1,P2,P3….,Pn to be number in respective Permutations.
Input :
First line contains T- No of test cases.
Next T lines contains two space separated integers - N and K.
Output:
Print the no of permutations satisfying the conditions given in problem sratement in separate lines.
Constraints :
1 ≤ T ≤ 10
1 ≤ N ≤ 16
0 ≤ K ≤ 60
SAMPLE INPUT
3
2 3
2 4
5 6
SAMPLE OUTPUT
1
2
7
Explanation
Test Case #1: N=2 and K=3
now all possible Permutation of Lengh 2 are
1) 1 2
2) 2 1
For (1) : | 3(1) - 2(2) | = 1 ≤3 . Hence valid.
For (2 ): | 3(2) - 2(1) | = 4 ≰ 3 . Hence not valid.
So answer is 1.
输入格式
见题面
输出格式
见题面