问题描述 |
---|
Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now.
|
输入描述 |
The input consists of several test cases. The first line of each test case contains two integers M and N (2 <= M, N <= 300). Each of the following M lines contains N uppercase letters, each of which is one of 'Y' (you), 'T' (target), 'S' (steel wall), 'B' (brick wall), 'R' (river) and 'E' (empty space). Both 'Y' and 'T' appear only once. A test case of M = N = 0 indicates the end of input, and should not be processed. |
输出描述 |
For each test case, please output the turns you take at least in a separate line. If you can't arrive at the target, output "-1" instead. |
样例输入复制样例 |
3 4 YBEB EERE SSTE 0 0 |
样例输出 |
8 |
相关 |