D :: Towers Permutations
Time Limit: 1 Second Memory Limit: 65536 KB
A massively tower builder company want to build n towers all in a straight line; each tower has a distinct (integer) height between 1 and n, inclusive. The tower at index i is considered visible from the left if there is no taller tower with a smaller index (formally, heightj < heighti for all j < i ). Similarly, a tower is visible from the right if there is no taller tower with a higher index (heightj < heighti for all j > i ). For example, if the height of the towers in order from the left are 1, 3, 5, 2, and 4, then three towers are visible from the left (1, 3 and 5), but only two are visible from the right (4 and 5).
You will be given the total number of towers, the number of towers visible from the left, and the number of towers visible from the right. You should find the number of permutations of the towers that are consistent with these values; as this can be a large number, you should return it modulo 1000000007.
Input
The first line of the input contains a single integer t, followed by t test cases. Each test case comes in a single line containing the total number of towers, the number of towers visible from the left, and the number of towers visible from the right. The total number of towers is non-negative number less than 101.
Output
You should print the total number of permutations modulo 1000000007 in the format that is shown in the Sample Output.
Sample Input
5 2 2 2 3 2 1 12 1 1 4 4 5 4 2 2
Sample Output
Case 1: 0 Case 2: 1 Case 3: 0 Case 4: 0 Case 5: 6Submit
Source: 9th Iran Nationwide Internet Contest