Given two number N and M as input find numbers such as:
The number should contain all the digits from 0 to N-1
The length of number can be atmost M i.e. it can have atmost M digits.
The difference between each adjacent digits should be one.
calculate the number of all such numbers.
First line T : no. of test cases
For each test case: N M (space separated)
For each test case no. of such numbers that can be formed using all 0-(N-1) digits and which have atmost M digits in single line.
Output should be in Modulo 1000000007
0 ≤ t ≤ 100
2 ≤ N ≤ 10
0 ≤ M ≤ 500
(This Question was asked in Bytecode 2013 on Codechef. My head says Dynamic Programming, but I can’t think how to start about it.)