Opening his eyes, the Prince of Persia discovered that he was on the upper level of Jaffar's underground labyrinth. The labyrinth consists of levels located directly one under another. Each level is a rectangular area divided into m \times n sections. In some sections, there are columns supporting the ceiling, and the Prince cannot enter such sections.
The Prince can move from one section to another section of the same level if these sections have a common side and neither contains a column. This move takes the Prince seconds.
The floors in the labyrinth are extremely thin, and the Prince can easily break the floor under himself with a strong kick, unless there is a column in the corresponding section of the lower level. When the floor is broken, the Prince falls down one level, remaining in the same horizontal position. This action also takes seconds. Of course, if the Prince is already at the lowest level, the floor under him cannot be broken.
In one of the sections of the lowest level, the Princess (who refused to marry the evil Jaffar) is waiting for the Prince. Help the Prince to find the Princess in as little time as possible.
The first line contains the positive integers , , and (2 \leq h, m, n \leq 50) — the height and horizontal dimensions of the labyrinth. The next blocks describe the levels of the labyrinth in order from top to bottom.
Each block contains lines of characters: "." (dot) denotes a free section, "o" (lowercase Latin letter "o") indicates a section with a column, "1" indicates the free section where the Prince starts his journey, and "2" indicates the free section where the Princess waits.
Characters "1" and "2" each appear exactly once: "1" is in the top level's description and "2" in the bottom level's description.
Neighboring blocks are separated by one blank line.
Print the minimum time in seconds that the Prince needs to find the Princess. Since Good always conquers Evil, it is guaranteed that the Prince can do this.
Example 1