No. The table cannot be typed, but only the rule is known.
| |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
| 1 |
1 |
|
|
|
|
|
|
|
| 2 |
2 |
2 |
|
|
|
|
|
|
| 3 |
3 |
5 |
5 |
|
|
|
|
|
| 4 |
4 |
9 |
14 |
14 |
|
|
|
|
| 5 |
5 |
14 |
28 |
42 |
42 |
|
|
|
| 6 |
6 |
20 |
48 |
90 |
132 |
132 |
|
|
| 7 |
7 |
27 |
75 |
165 |
297 |
429 |
429 |
|
Rule:
A [I] [1] = I;
A [I] [I] = A [I] [I-1];
A [I] [J] = A [I-1] [J] + A [I] [J-1];
Problem description
Recently, lxhgww assigned ed a task: to generate strings contain '0's and '1' s only, in which '0' appears exactly m times, '1' appears exactly n times. also, any prefix string of it must satisfy the situation that the number of 1's can not be smaller than the number of 0's. but he can't calculate the number of satisfied strings. can you help him?
Input
T (t <= 100) in the first line is the case number.
Each case contains two numbers N and M (1 <= m <= n <= 1000000 ).
Output
Output The number of satisfied strings % 20100501. sample input
12 2 sample output
2
HDU 3398 string