Distinct Paths in Grid

Languages

A robot is situated on an m x n grid, starting at the top-left corner (grid[0][0]) with the goal of reaching the bottom-right corner (grid[m - 1][n - 1]). In one step, the robot can only either move down or right by a single cell.

Given the integers m and n, determine the number of distinct paths the robot can take to reach the bottom-right corner.

Input

  • m: number: An integer
  • n: number: An integer

Examples

Input: m = 3, n = 2
Output: 3
Explanation: The robot has 3 unique paths to reach the target point in a 3x2 grid: Right-Down-Down, Down-Down-Right, Down-Right-Down.
Input: m = 5, n = 7
Output: 210
Explanation: The robot can navigate a 5x7 grid using 210 unique paths to reach the target point.
Input: m = 10, n = 4
Output: 220
Explanation: The robot can navigate a 10x4 grid using 220 unique paths to reach the target point.

Constraints

  • The result will not exceed 2^31
  • 1 <= m, n <= 100