private static int run_left(char[][] grid, int[][] from, int[][] to, int N, int M, int max) {
        for (int i = 1; i < N; i++) {
            for (int jhigh = M-1; jhigh > 0; jhigh--) {
                if (grid[i][jhigh] == '#' || from[i-1][jhigh] < 0) continue;
                int up = from[i-1][jhigh];
                
                for (int jlow = jhigh-1; jlow >= 0; jlow--) {
                    if (grid[i][jlow] == '#') break;
                    
                    int straight = jhigh - jlow + 1;
                    int down = i >= N-1 || to[i+1][jlow] < 0 ? 0 : to[i+1][jlow];
                    
                    max = Math.max(max, up + straight + down);
                }
            }
        }
        
        return max;
    }