The Solution.pas is self-explanatory: everything is in comments. But I must admit that the solution is far from optimal: it checks all possible traversals over a region. We should add some additional checks in the backtracking mechanism.