INS14F - Save CodeVillage
In another test the terrorists have occupied CodeVillage. The village consists of N buildings. Each building is connected to every other building with a road. Each terrorist has been told to cover a single strip of K buildings along any path. A path is a set of roads connecting a particular set of buildings in which the buildings will not be repeated and every adjacent pair of roads share a common building.
Each terrorist will be given a distinct path. Two paths are different if at least one building is different or the order of visiting the buildings is different. For example a path from building numbers 1 → 2 → 3 is different from a path from building numbers 1 → 3 → 2.
Now so as to improve coordination between the terrorists, they had decided that every terrorist should meet all other terrorists along the path. Thus there should be at least one common building in every pair of paths.
Digo must take enough artillery to kill all the terrorists but not much more due to the ongoing recession problems. So help him calculate the maximum number of terrorists that may be present in the village. Give your answer modulo 10^9 + 7.
Input
The first line contains a single integer T denoting the number of test cases. T lines follow each containing two space separated integers N and K.
Output
For each test case output the maximum possible number of terrorists modulo 10^9 + 7.
Constraints
1 <= T <= 100000
1 <= K <= N <= 1000000
Sample
Input 2 3 2 5 3 Output 6 60
hide comments
Min_25:
2014-04-13 20:45:33
@Surya kiran, @Andy William
|
|
Surya kiran:
2014-04-13 19:43:26
@Min_25 : What is the problem you are facing? Can you make it more clear?
|
|
Andy:
2014-03-27 19:07:24
@Min_25
|
Added by: | Surya Kiran |
Date: | 2014-03-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Insomnia 2014 |