F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

The Monkey King

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1485    Accepted Submission(s): 539


Problem Description
As everyone known, The Monkey King is Son Goku. He and his offspring live in Mountain of Flowers and Fruits. One day, his sons get $n$ peaches. And there are $m$ monkeys (including GoKu), they are numbered from $1$ to $m$, GoKu¡¯s number is 1. GoKu wants to distribute these peaches to themselves. Since GoKu is the King, so he must get the most peach. GoKu wants to know how many different ways he can distribute these peaches. For example n=2, m=3, there is only one way to distribute these peach: 2 0 0.

When given $n$ and $m$, you are expected to calculate how many different ways GoKu can distribute these peaches. Answer may be very large, output the answer modular $1000000007$ instead.
 

Input
There are multiple test cases. In the first line of the input file there is an integer $T$ indicates the number of test cases.

In the next $T$ lines, each line contains $n$ and $m$ which is mentioned above.

[Technical Specification]

All input items are integers.

$1 \leq T \leq 25$

$1 \leq n,m \leq 100000$
 

Output
For each case£¬the output should occupies exactly one line.

See the sample for more details.
 

Sample Input
2 2 2 3 5
 

Sample Output
1 5
 

Hint
For the second case, there are five ways. They are
2 1 0 0 0
2 0 1 0 0
2 0 0 1 0
2 0 0 0 1
3 0 0 0 0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 14:25:35, Gzip enabled