Contest 8 May

#### Start

2018-05-08 01:00 UTC

## Contest 8 May

#### End

2018-05-08 06:00 UTC
The end is near!
Contest is over.
Not yet started.
Contest is starting in -380 days 10:26:46

5:00:00

0:00:00

# Problem CLarge Party

Irena and Sirup are organizing their engagement party next weekend. They want to invite almost everyone they know. They also bought a very big round table for this occasion. They are now wondering how they should distribute people around the table. Irena claimed that when there are more than $K$ women next to each other, this group will chat together for the whole night and won’t talk to anybody else.

Sirup had no other choice but to agree with her. However, being a mathematician, he quickly became fascinated by all the possible patterns of men and women around the table.

There will be $N$ people sitting at the round table. Some of them will be men and the rest will be women.

Your task is to count in how many ways it is possible to assign the places to men and women in such a way that there will not be more than $K$ women sitting next to each other.

If one assignment can be made from another one by rotating all the people around the table, we consider them equal (and thus count this assignment only once).

## Input

The first line of the input file contains an integer $T, 1\le T \le 20$ specifying the number of test cases. Each test case is preceded by a blank line.

The input for each test case consists of a single line that contains the two integers $N$ and $K$, where $1 \le N, K \le 1\, 000$.

## Output

For each test case output a single line with one integer – the number of ways to assign places to men and women around the table, modulo $100\, 000\, 007$.

## Explanation of the sample input

1. In the first test case there are two possibilities: MMM or MMW (M is a man, W is a woman).

2. In the second test case there are two more possibilities: MWW and WWW.

3. In the third test case the three possibilities are: MMMM, MMMW, and MWMW.

Sample Input 1 Sample Output 1
3

3 1

3 3

4 1

2
4
3