499. The Maze III

There is a ball in a maze with empty spaces (0), walls (1), and a hole (2). The ball can roll through empty spaces until it hits a wall, at which point it stops. If the ball rolls over the hole, it falls in and the journey ends.

Find the shortest path for the ball to reach the hole. If several shortest paths exist, return the lexicographically smallest one among them, using the instructions 'l', 'r', 'u', and 'd'. If the hole cannot be reached, return "impossible".

Examples
Input: [[[0,0,0,0,0],[1,1,0,0,1],[0,0,0,0,0],[0,1,0,0,1],[0,1,0,0,0]],[4,3],[0,1]]
Output: "lul"
Hints
Related Problems

499. The Maze III

There is a ball in a maze with empty spaces (0), walls (1), and a hole (2). The ball can roll through empty spaces until it hits a wall, at which point it stops. If the ball rolls over the hole, it falls in and the journey ends.