#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
using namespace std;
const int N=110;
//typedef pair<int,int>PII;
char g[N][N][N];//存储地图
int path[N][N][N];//存储答案
bool visted[N][N][N];//
int l,r,c;
int dx[]={0,-1,0,1,0,0},dy[]={-1,0,1,0,0,0},dz[]={0,0,0,0,-1,1};
int st_x,st_y,st_z,end_x,end_y,end_z;
struct location{
int x,y,z;
};
queue<location> q;
void bfs(int x,int y,int z){
//queue<location> q;
q.push({x,y,z});
while(!q.empty()){
auto now=q.front();
q.pop();
for(int i=0;i<6;i++){
int xx=now.x+dx[i];
int yy=now.y+dy[i];
int zz=now.z+dz[i];
if(g[xx][yy][zz]!='#'&&!visted[xx][yy][zz]){
visted[xx][yy][zz]=true;
path[xx][yy][zz]=path[now.x][now.y][now.z]+1;
q.push({xx,yy,zz});
}
}
}
}
int main(){
while(cin>>l>>r>>c){
if(l==0&&r==0&&c==0) break;
memset(g,'#',sizeof g);
memset(path,0,sizeof path);
memset(visted,0,sizeof visted);
for(int i=1;i<=l;i++){
for(int j=1;j<=r;j++){
for(int k=1;k<=c;k++){
cin>>g[i][j][k];
if(g[i][j][k]=='S') st_x=i,st_y=j,st_z=k;
if(g[i][j][k]=='E') end_x=i,end_y=j,end_z=k;
}
}
}
visted[st_x][st_y][st_z]=true;
bfs(st_x,st_y,st_z);
if(path[end_x][end_y][end_z]>0) cout<<"Escaped in "<<path[end_x][end_y][end_z]<<" minute(s)."<<endl;
else cout<<"Trapped!"<<endl;
}
return 0;
}