Hamid wrote $$$3014$$$ lines of code for the a+b problem and gave $$$10$$$ lines of it to Hamed; then the following problem came to Hamed's mind.
You are given two integers $$$n$$$ and $$$m$$$.
An array $$$a_1,a_2,\ldots,a_n$$$ is called snake if and only if all of the following conditions hold:
We define $$$f(a)$$$ as in the following pseudocode:
function f(array a):
pos := 1
res := 0
let nxt[x] be an array such that nxt[x] is the smallest index y such that
y > x and a[y] > a[x],
or undefined if no such y exists
while pos < n:
if a[pos] < a[n]:
res += a[nxt[pos]] - a[pos]
pos := nxt[pos]
else:
pos += 1
return res
Find the sum of $$$f(a)$$$ over all snake arrays $$$a_1,a_2,\ldots,a_n$$$, 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^4$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$, $$$0 \leq m \leq 2 \cdot 10^5$$$) — the length of a snake array and the sum of all elements in a snake array.
It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output a single integer — the sum of $$$f(a)$$$ over all snake arrays $$$a_1,a_2,\ldots,a_n$$$, modulo $$$10^9+7$$$.
82 53 44 65 106 23100 100142857 33333200000 0
9 14 76 985 142112 771227753 865580631 0
In the first test case, there are three snake arrays:
Thus, the answer is $$$5+3+1=9$$$.
In the second test case, there are six snake arrays:
Thus, the answer is $$$4+3+2+1+2+2=14$$$.
In the fifth test case, a possible snake array is:
| Name |
|---|


