#SL2310C. Many Topological Problems

Many Topological Problems

Many Topological Problems

Once you created the following problem:

Topological Problem

You are given a labeled rooted tree with nn vertices and an integer kk. We call a permutation aa of length nn good if ai>aparia_i > a_{par_i} and aiapari+ka_i \leq a_{par_i} +k for each ii with a parent paripar_i.

Find the number of good permutations.

Now, thinking this problem is too easy, you create the following problem:

Many Topological Problems

You are given two integers n,kn,k. For all different labeled rooted trees TT with nn vertices, find the sum of the answer to the Topological Problem of TT, modulo 109+710^9 + 7.

Please solve Many Topological Problems.

Two labeled rooted trees are considered different, if and only if their roots differ, or one edge exists in one tree but not in the other.

Input

The first line contains a single integer T(1T10)T \: (1 \leq T \leq 10), denoting the number of test cases.

For each test case, the only line contains two integers n,k(1kn106)n,k \: (1 \leq k \leq n \leq 10^6).

Output

For each test case, output one line with an integer denoting the answer.

Example

3
2 2
5 1
114514 1919
2
120
354463397