Speleologist's Path#1068

Speleologist's Path

1 second
64 megabytes
Very easy

The cave is represented by a cube, divided into parts along each dimension (that is, into N^3 cubic cells). Each cell can be either empty or completely filled with stone. Starting from the speleologist's location in the cave, you need to determine the minimum number of moves required to reach the surface. Movement between cells is allowed only if both cells are empty and share a common face.

Input

The first line contains the number (1 \leq N \leq 30). This is followed by blocks. Each block consists of an empty line, followed by lines of characters: # indicates a cell filled with stone, and a dot indicates an empty cell. The initial position of the speleologist is marked with a capital letter . The first block represents the top level of the cave; reaching any empty cell in this level means reaching the surface. It is always possible to reach the surface.

Output

Print a single number—the length of the path to the surface.

Examples

Example 1

Loading
Loading