You are in charge of a large scientific project studying an unusual function. To carry it out, you hired $$$10^{10^{100}}$$$ students and numbered them with natural numbers from $$$1$$$ to $$$10^{10^{100}}$$$. The students form a hierarchy:
There are $$$n$$$ days left until the project is completed. Each day consists of two stages:
Additional restriction: Each student may be fired (directly or indirectly) at most once. If a previously fired student is hired again, it is forbidden to perform a firing that would cause this student to be fired again.
Below (showing only the first $$$15$$$ students) are examples of how to choose students for direct firing on each day so that after $$$2$$$ days exactly $$$5$$$ students remain. The number at the top corresponds to the student number, edges show subordination.
Students who are working and have not been fired are marked green, students who have been fired are marked white, and students who were previously fired but have been rehired are marked red.
Day $$$1$$$, before firing. All students are hired.
Day $$$1$$$, after firing. Students $$$2$$$, $$$6$$$, $$$7$$$ are fired.
Day $$$2$$$, before firing. Students $$$2$$$, $$$6$$$, $$$7$$$ are hired. Note that during the firing stage, student $$$3$$$ cannot be directly fired, as this would lead to firing students $$$6$$$ and $$$7$$$, who have already been fired before this moment. Your goal is to make it so that exactly $$$n$$$ days later there are exactly $$$k$$$ working students left in the project. At the same time, you need to minimize the total number of direct firings over the whole period.
Find the number of ways to choose the students for direct firing on each day so that the final number of working students is $$$k$$$, and the total number of direct firings is minimal possible. Output the answer modulo $$$10^9 + 7$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^5$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^9$$$, $$$1 \le k \le 2 \cdot 10^5$$$) — the number of days and the required final number of active students.
For each test case, output one integer — the number of possible ways to choose firings on each day so that after $$$n$$$ days exactly $$$k$$$ students remain, under the condition that the total number of firings is minimal possible.
61 12 53 41 520 141000000000 20
1224212012
In the first test case, there is $$$1$$$ way: on the first day, directly fire students numbered $$$2$$$ and $$$3$$$. Exactly one student, number $$$1$$$, remains.
In the second test case, there are $$$2$$$ possible ways:
In the third test case, there are $$$2$$$ possible ways: