import java.util.*;


public class Solution {
    /**
     * 
     * @param m int整型 
     * @param n int整型 
     * @return int整型
     */
    public int uniquePaths (int m, int n) {
        int[][] dp = new int[m + 1][n + 1];
        return process(m, n, dp);
    }
    public static int process(int m, int n, int[][] dp){
        if (m == 1 || n == 1){
            dp[m][n] = 1;
            return dp[m][n];
        }

        if (dp[m][n] != 0){
            return dp[m][n];
        }

        dp[m][n] = process(m - 1, n, dp) + process(m, n - 1, dp);
        return dp[m][n];
    }
}