The travelling tortoise

Find all the paths that a tortoise can travel from an initial position to a final position. The ground has n×mn \times m 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

Input begins with nn and mm, followed by nn lines with mm 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 (0,0)(0, 0).

Output

Print all the paths from the initial position to the final position.

Information about the checker

You can print the solutions to this exercise in any order.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:14:03.713Z

© Jutge.org, 2006–2026.
https://jutge.org