#C10324. Unique Paths in a Grid
Unique Paths in a Grid
Unique Paths in a Grid
Given a grid of dimensions N × M, you are required to determine the number of unique paths from the top-left corner to the bottom-right corner. You may only move either right or down at any step. The answer can be computed using the formula:
$$ \binom{N+M-2}{N-1} $$
If either N or M is 0, then there are 0 unique paths.
inputFormat
The input begins with an integer T (T ≥ 1), representing the number of test cases. Each of the following T lines contains two integers N and M (0 ≤ N, M ≤ 100) separated by a space, which represent the dimensions of the grid.
outputFormat
For each test case, output a single line that contains the number of unique paths in the corresponding grid.
## sample1
3 3
6
</p>