Fire Maze Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 53(19 users) Total Accepted: 26(17 users) Rating: Special Judge: No Description After escaping from Figo’s chase, Severus falls into a N * M maze designed by Figo. At first, Severus is located on the grid S. Every second he can only move to the four grids that adjacent to the grid he is
located on. The moment he move to any side of the maze, he will get rid of Figo.
After T seconds, Figo will reach the maze. Because Figo is the designer of the maze, when Figo arrive, he can reach any
grid if he want. If Severus can’t leave the maze at that moment, there is no doubt that he will be caught by Figo.
Figo is very cunning. In the maze he set not only walls, but also fire! After every second, the fire will spread to the four
grid that adjacent to it. When a grid is on fire, certainly, Severus can not be on the grid. Can Severus escape from the
maze?
Input The first line will be a integer CS, indicating the number of test cases. In every case, there will be three integer N, M, T. After that there will be N * M characters, decribe the maze. The “.” is a empty grid, “#” is wall, “F” is the fire, “S” is the initial grid that Severus stands on.
10 <= n , m <= 100 10 <= T <=10000
Output There is only one line, if Severus can get out, output the mininum time he need to escape from the maze. If he can’t,
output “Poor Severus must be caught by strong Figo!!!”