Distanced Round Table
Alice runs a small tea house whose round tables have their chairs bolted to the floor. A table
with n chairs has them numbered 1, 2, …, n clockwise. Chair i is next to chairs i − 1 and
i + 1, and because the table is round, chair n is also next to chair 1. No other pairs of
chairs are next to each other.
Guests have recently insisted on keeping their distance: a group of k guests will only sit down
if no two of them end up in chairs that are next to each other. Each guest takes exactly one chair,
and the remaining chairs stay empty.
Alice does not care who sits where, only which chairs are taken. Two seatings are therefore different exactly when the sets of occupied chairs are different. Since the chairs are numbered, two seatings that are rotations of each other still count as different (on a table with 4 chairs, taking chairs {1, 3} and taking chairs {2, 4} are two different seatings).
Alice asks you about several tables. For each one, count the seatings of k guests at a table of
n chairs in which no two guests are next to each other. The numbers can be huge, so print them
modulo 1 000 000 007.
Input
The first line contains q (1 ≤ q ≤ 10^5), the number of questions.
Each of the next q lines contains two integers n and k (2 ≤ n ≤ 10^6, 0 ≤ k ≤ n): the number
of chairs at the table and the number of guests.
Output
For each question, print on its own line the number of valid seatings modulo 1 000 000 007. If
the guests cannot be seated at all, print 0. Seating zero guests counts as exactly one seating
(every chair empty).
Notes
In the first example, a table of 5 chairs can host 2 guests in 5 ways: {1, 3}, {1, 4}, {2, 4}, {2, 5}, {3, 5}. The pair {1, 5} is not allowed because chairs 5 and 1 are next to each other. With 6 chairs and 3 guests only {1, 3, 5} and {2, 4, 6} work, and 4 guests never fit around 7 chairs.
With n = 2, the two chairs are next to each other, so one guest has 2 seatings and two guests
have none.