eolymp
bolt
Try our new interface for solving problems
Problems

Hazhir, The King of SBU Jungles!

Hazhir, The King of SBU Jungles!

\textit{"A chess game is divided into three stages: The first, when you hope you have the advantage, the second, when you believe you have an advantage, and the third… when you know you’re going to lose!"} \textit{Savielly Tartakower} King Hazhir is the king of SBU Jungles. His daughter is at SBG Jungles. King Hazhir received a letter telling that her daughter gave birth to a child. King is incredibly curious to see his grandchild! Unfortunately that's not so easy. SBU and SBG are separated by a forest. There are lots of enemies in the forest, and King Hazhir is not that curious to see them. If they attack king on his way to SBG, then he will never ever see his grandchild and his daughter again because of lethal consequences. King Hazhir has a security team: Amir, Amir Hossein, Navid and Koosha. If King Hazhir could not see his daughter and his grandchild, he will kill all members of his security team. Please help us, all of you dear newbie contestants! The security team disposes information about location of the enemies, which makes the things easier for king Hazhir. For some unknown reason a forest is \textbf{M}×\textbf{N} chessboard. (\textbf{M} is the number of rows, and \textbf{N} is the number of columns). Enemies of the King can ride horses as showed in the picture. Usually horses ride (or jump) that way in Chess. The king moves the same way as chess-king does. \includegraphics{https://static.e-olymp.com/content/f3/f30e892d190a9b36a8fe88c78e92c605c3c9dcff.jpg} The enemies are fixed and can't move. King can't move to a square \textbf{X}, if a horse of the enemy is on that square or threat it, except for the case when square \textbf{X} is either kingdom SBU or SBG. You're asked by the security team to find the length of the shortest route \textbf{L} from kingdom SBU to SBG, as dear king Hazhir can't wait any longer. \InputFile The first line of input contains the number of tests \textbf{T} ≤ \textbf{100}. The first line of each test contains \textbf{2} numbers \textbf{M} and \textbf{N} where \textbf{N}, \textbf{M} ≤ \textbf{100}. Then \textbf{M} lines follow each containing \textbf{N} symbols from the set \textbf{S} = \{'\textbf{.}', '\textbf{Z}', '\textbf{U}', '\textbf{G}'\}. '\textbf{.}' means that square is not occupied. '\textbf{Z}' means a horse occupies that square. '\textbf{U}' means kingdom SBU and '\textbf{G}' means kingdom SBG. Each test contains exactly one kingdom SBU and SBG. \OutputFile Find number \textbf{L} for each test and print line "\textbf{Minimal possible length of a trip is L.}" if King Hazhir can reach to the SBG. Replace "\textbf{L}" with corresponding number. If King Hazhir can't safely reach to the SBG print line "\textbf{No King Hazhir, you can't go now! Don't kill us!}"
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
5 5
.Z..G
..Z..
Z...Z
.Z...
U....
3 2
ZG
.Z
UZ
6 5
....G
.....
.....
..Z..
.....
U..Z.
3 3
ZZ.
...
UG.
Output example #1
No King Hazhir, you can't go now! Don't kill us!
Minimal possible length of a trip is 2.
No King Hazhir, you can't go now! Don't kill us!
Minimal possible length of a trip is 1.