Find all the paths that a tortoise can travel from an initial position to a final position. The ground has paving stones, each one with a letter painted on it. The tortoise can only make horizontal and vertical movements, and it cannot pass by the same position twice.
Input begins with and , followed by lines with letters each. Follow a pair of natural numbers indicating the initial row and column, and a pair of naturals numbers indicating the final row and column. The upper-left corner corresponds to the position .
Print all the paths from the initial position to the final position.
You can print the solutions to this exercise in any order.
Input
2 2 IG BA 1 0 0 1
Output
BIG BAG
Input
3 2 ab de ab 0 0 2 1
Output
adab adeb abeb abedab
Input
1 1 A 0 0 0 0
Output
A