private int minPathSumMN(int m, int n, int[][] s, int[][]grid){
    	if(m == 0 && n == 0 ){
    		return grid[0][0];
    	}
    	else if(m == 0){
            if(s[m][n-1] != -1){
                s[m][n] = s[m][n-1] + grid[m][n];
            }
            else{
                s[m][n] = minPathSumMN(m, n-1, s, grid) + grid[m][n];
            }
    	}
    	else if(n == 0){
            if(s[m-1][n] != -1){
                s[m][n] = s[m-1][n] + grid[m][n];
            }
            else{
                s[m][n] = minPathSumMN(m-1, n, s, grid) + grid[m][n];
            }
    	}
    	else{
            if(s[m][n-1] == -1){
                 s[m][n-1] = minPathSumMN(m, n-1, s, grid);
            }
            if(s[m-1][n] == -1){
                s[m-1][n] = minPathSumMN(m-1, n, s, grid);
            }
    		int min = s[m][n-1] <= s[m-1][n] ? s[m][n-1] : s[m-1][n];
    		s[m][n] = min + grid[m][n];
    	}
        return s[m][n];
    }