You are dropped in a maze which has only one exit point. Given the configuration of the maze and your starting point in the maze print the directions that you will take to reach the exit point. Note that the walkable are of the maze is indiacted by ‘.’, blocked area by ‘X’, your initial point by ‘I’ (Capital i), exit point by ‘E’.
First line contains M and N indicating the size of the maze.
Next M lines (each of them) contain N space seperated characters indicating the configuration of the maze.
Print space seperated characters indicating the directions to reach exit point. Note that there will be only one way possible to reach the exit point and you must print minimum required directions. Note that you can move in any of the 4 directions freely (if allowed) at any point.
U, D, L, R (Up, Down, Left, Right respectively)
E . I
. X .
Initaially you are at (0,2), assuming the top left corner is (0,0). You can take LEFT or go DOWN, but going DOWN wil not help you. So ou take LEFT and one more LEFT to reach the exit point.
Note that your output must only contain the minimum required directions. For the above example you must not print “D U L L L” even though it takes you to the exit correctly