eolymp
bolt
Try our new interface for solving problems

Maze

Opening his eyes, the Prince of Persia discovered that he was on the upper level of the underground labyrinth of Jaffar. The labyrinth consists of h levels located strictly under each other. Each level is a rectangular area, divided into m * n sections. In some sections there are columns supporting the ceiling; the Prince cannot enter such sections.

Prince can move from one section to another section of the same level if these sections have a common side and none of these sections contains a column. This move takes the Prince 5 seconds.

The floors in the Jaffar maze are extremely thin, and it is not difficult for the Prince to break the floor under him with a strong kick, unless there is a column in the corresponding section of the lower level. When the floor breaks, the Prince falls down one level, while not moving in the horizontal plane. This action also takes Prince 5 seconds. Of course, if the Prince is already at the lowest level, then the floor under him will not break.

In one of the sections of the lower level the Princess (who refused to marry the evil Jaffar) is waiting for the Prince. Help the Prince to find the Princess by spending as little time as possible.

Input

The first line contains positive integers h, m and n (2h, m, n50) - the height and horizontal dimensions of the maze. The following h blocks describe the levels of the maze in order from top to bottom.

Each block contains m lines of n characters in each: "." (dot) denotes a free section, "o" (lowercase Latin letter "o") indicates the section with the column, "1" indicates the free section where the Prince found himself at the beginning of his journey, "2" indicates the free section in which the Princess languishes.

The symbols "1" and "2" occur exactly once: the symbol "1" in the description of the highest level, and the symbol "2" in the description of the lowest.

Neighbouring blocks are separated by one blank line.

Output

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.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 3 3
1..
oo.
...

ooo
..o
.oo

ooo
o..
o.2
Output example #1
60
Source 2006, XIV St. Petersburg School Programming Team Championship, November 6, Problem G