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

#define maxn 103

int w, h, sx, sy, ex, ey;
char s[maxn][maxn];
int dir[maxn][maxn];

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

void dfs( int x, int y, int d )
{
  int i;

  if (s[y][x] == '#' || dir[y][x] != -1)
    return;
  dir[y][x] = d;
  for (i = 0; i < 4; i++)
    dfs(x + dx[i], y + dy[i], i);
}

int main( void )
{
  int x, y, i;

  freopen("input.txt", "r", stdin);

  scanf("%d%d", &w, &h);
  for (y = 1; y <= h; y++)
    scanf("%s", s[y] + 1);
  for (y = 0; y <= h + 1; y++)
    for (x = 0; x <= w + 1; x++)
      if (y == 0 || y == h + 1 || x == 0 || x == w + 1)
        s[y][x] = '#';
  for (y = 1; y <= h; y++)
    for (x = 1; x <= w; x++)
      if (s[y][x] == 'S' || s[y][x] == 's')
        sx = x, sy = y, s[y][x] = '.';
      else if (s[y][x] == 'E' || s[y][x] == 'e')
        ex = x, ey = y, s[y][x] = '.';
  
  memset(dir, -1, sizeof(dir));
  dfs(sx, sy, 0);
  
  if (dir[ey][ex] == -1)
  {
    printf("There is no path!\n");
    return 0;
  }
  while (ex != sx || ey != sy)
  {
    s[ey][ex] = '*';
    i = dir[ey][ex];
    ex -= dx[i], ey -= dy[i];
  }
  s[ey][ex] = '*';

  for (y = 0; y <= h + 1; y++)
    puts(s[y]);
  return 0;
}