#include <stdio.h>
#include <stdlib.h>
#include <string.h>



int shortest_path(char **grid, int rows, int cols) {
    // TODO: locate S and E, then run a breadth-first search from S using your
    //       own queue and a distance array. Return the distance to E, or -1.
    (void)grid; (void)rows; (void)cols;
    return -1;
}


int main(void) {
    int rows, cols;
    if (scanf("%d %d", &rows, &cols) != 2) return 0;
    char **grid = malloc(sizeof(char *) * rows);
    char buf[1024];
    for (int r = 0; r < rows; r++) {
        if (scanf("%1023s", buf) != 1) return 0;
        grid[r] = malloc(cols + 1);
        for (int c = 0; c < cols; c++) grid[r][c] = (c < (int)strlen(buf)) ? buf[c] : '.';
        grid[r][cols] = '\0';
    }
    int d = shortest_path(grid, rows, cols);
    if (d < 0) printf("no path\n");
    else printf("shortest path: %d steps\n", d);
    for (int r = 0; r < rows; r++) free(grid[r]);
    free(grid);
    return 0;
}
