You are at the top left corner [position ] of a grid. Your destination is bottom right corner of the the grid[position ].
A grid. Yellow is the starting position. Green is the ending position. Red line shows a valid path.
If your current position is , you can move to or [if it is a valid position]. How many valid unique paths are there from your initial position to destination.
Input starts with an integer (), denoting the number of test cases.
Each case starts with a line containing two integers (), where denotes the number of rows and denotes the number of columns of the grid.
For each test case output number of unique path modulo .
Input | Output |
---|---|
1 2 2 | 2 |