DZY Loves Partition

Time Limit: 2000ms
Memory Limit: 262144KB
This problem will be judged on HDU. Original ID: 5646
64-bit integer IO format: %I64d      Java class name: Main

Description

DZY loves partitioning numbers. He wants to know whether it is possible to partition $n$ into the sum of exactly $k$ distinct positive integers.

After some thinking he finds this problem is Too Simple. So he decides to maximize the product of these $k$ numbers. Can you help him?

The answer may be large. Please output it modulo $10^9+7$.

Input

First line contains $t$ denoting the number of testcases.

$t$ testcases follow. Each testcase contains two positive integers $n,k$ in a line.

($1\le t\le 50, 2\le n,k \le 10^9$)

Output

For each testcase, if such partition does not exist, please output $-1$. Otherwise output the maximum product mudulo $10^9 + 7$.

Sample Input

4
3 4
3 2
9 3
666666 2

Sample Output

-1
2
24
110888111

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .