#P7392. 「TOCO Round 1」奇怪的排序

「TOCO Round 1」奇怪的排序

Description

On Valentine’s Day, Biadocy\color{orange}\texttt{Biadocy} was treated very badly, especially when an upper-class duke and a child said something like “Every day with you is Valentine’s Day.” So he found a chance to take revenge.

Now there are nn couples numbered 1n1 \sim n standing in a line in an arbitrary order. Biadocy\color{orange}\texttt{Biadocy} runs the following sorting pseudocode on them.

Biadocy\color{orange}\texttt{Biadocy} wants to know how many initial permutations will result in the couples’ numbers being in increasing order after being processed by this pseudocode. Maybe this will make him feel a bit better.

Input Format

The first line contains an integer TT, the number of test cases.

The next TT lines each contain two integers n,kn, k, representing the number of couples and the parameter passed in the first call to the pseudocode.

Output Format

Output TT lines. Each line contains one integer: the answer modulo 109+710^9+7.

3
3 1
10 2
1 0
3
25200
1
5
502520 0
502520 1
502520 2
502520 3
502520 4
1
218102685
429650441
770595802
584122358

Hint

For the first 10%10\% of the testdata, T=0T=0.
For the first 30%30\% of the testdata, T10T\leq 10, n7n\leq 7.
For another 10%10\% of the testdata, k=0k=0.
For another 10%10\% of the testdata, k=100k=100.
For 100%100\% of the testdata, 0T1050\leq T\leq 10^5, 1n1061\leq n\leq 10^6, 0k1000\leq k\leq 100.

Translated by ChatGPT 5