#C1343. Unique Robot Paths

    ID: 42967 Type: Default 1000ms 256MiB

Unique Robot Paths

Unique Robot Paths

You are given a grid with N rows and M columns. A robot is initially placed at the top-left cell (1, 1) and wants to reach the bottom-right cell (N, M). The robot can only move either right or down at any step.

The task is to calculate the number of unique paths the robot can take to reach its destination. Mathematically, the number of unique paths is given by the binomial coefficient:

\( \binom{N+M-2}{N-1} \)

For example, for a 2×3 grid, the answer is 3.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
N1 M1
N2 M2
... 
NT MT

Where the first line contains an integer T denoting the number of test cases. Each of the following T lines contains two space-separated integers N and M representing the dimensions of the grid.

outputFormat

For each test case, print one line in the format Case #i: x where i is the test case number (starting from 1) and x is the number of unique paths from (1,1) to (N, M), computed by the formula:

\( \binom{N+M-2}{N-1} \)

Output the result to standard output (stdout).

## sample
3
2 3
3 3
4 5
Case #1: 3

Case #2: 6 Case #3: 35

</p>