eolymp
bolt
Try our new interface for solving problems
Problems

Бермудский треугольник

Бермудский треугольник

БBermuda Triangle area in the Atlantic Ocean, which allegedly occurred the mysterious disappearance of ships and aircraft. Area bounded by lines from Florida to Bermuda, then to Puerto Rico and back to Florida through the Bahamas. Put forward different hypotheses to explain these disappearances, unusual weather patterns to alien abductions. One of the latest versions associated with the presence of a complex system of currents in the vicinity of Bermuda. The researchers had compiled a detailed map of the most dangerous part of the Bermuda Triangle. Image of a rectangle shape. Map rascherchena grid of square plots, each of which indicates the direction of flow: \textbf{east}, \textbf{north-east}, \textbf{north}, \textbf{north-west}, \textbf{west}, \textbf{south-west}, \textbf{south}, \textbf{south-east} or \textbf{whirlpool}. If the boat enters the station with a given direction of flow, the per unit time is under the influence of this flow moves to the plot, which is in the direction of the current situation. If the boat gets in a cage with a whirlpool, it instantly goes to the bottom. As part of ongoing studies you asked to identify where and how long will make a boat belonging to a given station. \InputFile In the first line of the input file contains integers \textbf{N} and \textbf{M} (\textbf{1} ≤ \textbf{N}, \textbf{M} ≤ \textbf{200}), specifying the size of the area depicted. The following table size \textbf{N} × \textbf{M}, in each cell of which is recorded information about the direction of flow in the relevant sections of the investigated area. Each cell contains one of values: \textbf{east}, \textbf{north-east}, \textbf{north}, \textbf{north-west}, \textbf{west}, \textbf{south-west}, \textbf{south}, \textbf{south-east} or \textbf{whirlpool}. Then on a separate line given integers x and y, giving the coordinates of the site (row and column, respectively), which was originally located the boat. \OutputFile If the boat leaves for the final time, the image area on the map, display "\textbf{Boat has been carried out in K move(s).}", where \textbf{K} - the time elapsed until the exit outside the image area. If the boat will sink Bring "\textbf{Whirlpool in K move(s)!}", where \textbf{K} - the time elapsed until falling into the whirlpool. If the boat never leaves the Image of Bring "\textbf{The Bermuda Triangle...}" .
Time limit 1 second
Memory limit 64 MiB
Input example #1
4 3
south south west
south whirlpool north-west
south-east south north
west north-east east
1 1
Output example #1
Whirlpool in 7 move(s)!

Example description: east - восток, north - север, west - запад, south - юг, whirlpool - водоворот