#include <stdio.h>
#include <string.h>
#define maxn 103
int w, h, sx, sy, ex, ey;
char s[maxn][maxn];
char dir[maxn][maxn];
int qst = 0, qen = 0, qx[maxn * maxn], qy[maxn * maxn];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void AddQ( int x, int y, int i )
{
if (s[y][x] != '#' && dir[y][x] == -1)
{
dir[y][x] = i;
qx[qen] = x, qy[qen++] = y;
}
}
void bfs( int x, int y )
{
int i;
qst = qen = 0;
AddQ(x, y, 0);
while (qst < qen)
{
x = qx[qst], y = qy[qst++];
for (i = 0; i < 4; i++)
AddQ(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));
bfs(sx, sy);
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;
}