Seven Seas

Seven Seas is a nice game where you are the captain of a battle ship. You are in the middle of the ocean and there are some enemy ships trying to catch you. Your mission is to run away from them. Destroy the enemies if you can! The game is played on a 9 × 8 board and you can move in all the 8 directions, one step each time. You move first, then the enemy ships move. The enemy ships are pretty dumb, so that they will always move to the closest position they can get to you, even if that position will destroy their ship. A ship is destroyed if it moves to a cell that contais a rock. If two enemy ships move to the same cell they are also destroyed and their remains will stay in that cell so that if another ship try to move there it will be destroyed too. If an enemy ship reaches your ship, you are dead and the game is over. Input The first line of the input contains the number of scenarios. Each scenarion consists of a 9 × 8 board of charachters. Your ship is represented by a ‘S’ on the board and the enemy ships are represented by a ‘E’. The rocks are represented by a ‘#’ and the ‘.’ represents the sea. See the sample input to see the specific input format. There will be at least one and at most nine enemy ships. There will be an empty line between two scenarios. Output For each scenario you must find out if it is possible to destroy all the enemy ships in less than 10 steps. If that is the case, you must print one line containing the string: ‘I'm the king of the Seven Seas!’. Otherwise, you must print one line with the string: ‘Oh no! I'm a dead man!’. Sample Input 3 ........ .E.#.... ...E.... ..#..... ........ ........ ..S..... ........ ........ ........ .E.E.... ...S.... .E..E... ........ ........ ........

2/2 ........ ........ E......# ........ ........ ........ ........ ........ ........ .......S #....... Sample Output I'm the king of the Seven Seas! Oh no! I'm a dead man! Oh no! I'm a dead man!