#P8432. 「WHOI-2」ぽかぽかの星

「WHOI-2」ぽかぽかの星

Background

You are drinking hot cocoa in a snow cave while counting stars. But this time, the stars are replaced by sequences. Clever as you are, you can surely count the sequences clearly.

Problem Description

How many non-decreasing positive integer sequences aia_i of length nn satisfy:

  • 0<a1a2a3ank0 < a_1 \le a_2 \le a_3 \dots \le a_n \le k.
  • ij,ai+ajk+1\forall i \ne j, a_i + a_j \ne k + 1.

Output the answer modulo 109+710^9 + 7.

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT.

The next TT lines each contain two positive integers n,kn, k.

Output Format

Output TT lines, each containing one positive integer, the answer.

3
2 2
1145 1419
19198 12321
2
66937457
949924930

Hint

This problem uses bundled testdata.

  • subtask1(20pts):T=5,1n,k5\text{subtask1(20pts)}: T = 5, 1 \le n, k \le 5.
  • subtask2(80pts):\text{subtask2(80pts)}: No special constraints.

For 100%100\% of the testdata, T100T \le 100, 1n,k5×1061 \le n, k \le 5 \times 10^6, and 1n,k6×1071 \le \sum n, \sum k \le 6 \times 10^7.

Translated by ChatGPT 5