eolymp
bolt
Try our new interface for solving problems

Maze

The robot is trapped in maze! The maze consists of four kinds of grids: \begin{itemize} \item "\textbf{.}" means blank ground, the robot can get through it \item "\textbf{#}" means block, the robot can't get through it \item "\textbf{S}" indicates where the robot is. \item "\textbf{T}" indicates where the robot aims to. \end{itemize} Now we send some command to the robot, "\textbf{LRUD}" represent that the robot make one move to left, right, up or down respectively. Help us to report the state of the robot. \InputFile The first line contains a single integer \textbf{T}, indicating the number of test cases. Each test case begins with one integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{50}), indicating the size of the maze. The followed \textbf{N} lines are \textbf{N} strings whose length is also \textbf{N}, indicating the maze. The following is an integer \textbf{Q} (\textbf{1} ≤ \textbf{Q} ≤ \textbf{100}), indicating the number of queries. The followed \textbf{Q}lines are \textbf{Q} strings contain only "\textbf{LRUD}", indicating the commands, whose lengths are less than \textbf{1000}. \OutputFile For each query, output a single line: \textbf{I get there!} - if the robot can reach the destination after executing the command, you should notice reaching the destination before the command ends is also included in this situation. \textbf{I have no idea!} - if the robot still couldn‟t reach the destination after executing the command. \textbf{I am dizzy!} - if the robot was knocked by the block while executing the command. \textbf{I am out!} - if the robot was out of the boundary while executing the command.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
2
S.
#T
2
RD
DR
3
S.#
.#.
.T#
3
RL
DDD
DDRR
Output example #1
I get there!
I am dizzy!
I have no idea!
I am out!
I get there!
Source 2010 Wuhan University 4th "Eming" Cup Programming Contest