Maze Again
The maze is the same as problem D, and I strongly recommend you solve the previous one first because it's easier than this.
This time, we want you design the command for our poor robot to move from where it is to its destination. The command sequence's length should be the shortest. If several solutions exist, find the lexicographically minimum one. Lexicographical sequence is the order in one dictionary. For example, "cat" is less than "do", and "do" is less than "dog".
Input
The first line contains a single integer T, indicating the number of test cases.
Each test case begins with one integer N (1 ≤ N ≤ 50), indicating the size of the maze. The followed N lines are Nstrings whose length is also N, indicating the maze.
Output
For each case, output a command string if there is a solution, otherwise output -1.