#Lutece1088. 王之迷宫

王之迷宫

Migrated from Lutece 1088 王之迷宫

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

王被困在了一个33维的迷宫中,他很想逃离这个迷宫回去当学霸,你能帮助他么? 由于王很仁慈,他悄悄地告诉你,本题读入迷宫的每一行时,要用scanf("%s"...) ......

Input

多组测试数据,对于每组测试数据,有三个整数 LL,RR,CC0<l,r,c300 < l , r , c\leq 30)。

LL代表迷宫的高度,RRCC分别代表每一层的行和列。

接下来是LLR×CR\times C的矩阵,矩阵包含44种字符(S,E,.,#),S代表王的初始位置,E代表出口,#代表障碍。.代表能通过的地方。

每一层之后有一个空行。

L=R=C=0L=R=C=0时,输入中断。

Output

如果可以逃离迷宫,按下列格式输出最短时间:

Escaped in x minute(s). (xx表示逃离迷宫的最短时间, 走一步花费一昏钟)

否则,输出:

Trapped!

Samples

3 4 5
S....
.###.
.##..
###.#

#####
#####
##.##
##...

#####
#####
#.###
####E

1 3 3
S##
#E#
###

0 0 0
Escaped in 11 minute(s).
Trapped!

Resources

2015 UESTC Training for Search Algorithm & String