Tower Defence is a popular classic game. During the game, there will appear some monsters at the entry and each will find a shortest path to the exit. Your task is puting some warriors on the map to kill the monsters before they reach exit.
You could put warrior(infinite) on the map to change the pathes of monsters. Of course, the longer the path is, the more advantageous to you.
Now, giving you the information of the map, how do you put the warriors to make the monsters move on the longest path?
The meaning of each character in the map:
'S' represents the entry of the map, one and only one;
'T' represents the exit of the map, one and only one;
'.' represents the grid that monster could move on;
'B' represents the barrier that monster couldn't move on;
'W' represents the warrior that you put.(could only put on '.')