| Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Kamila Hasanbega.
 
 
 Dwarfs Maze  In Dwarfs land in order for someone to pass the test to go 
to the Dwarf-Academy (which is one of the most competitive 
ones in those regions), someone has to pass a special kind 
of maze. This maze is 3D and can have 1 ≤ N ≤ 30
floors. Each floor is made of blocks marked by '#' or empty 
spaces marked by '.' from which you can move, ascend or
descend to other floors. Given the plane of each of the 
maze’s floors the Dwarfs bear the burden of finding the 
shortest path from the entering portal marked with “B”, 
to the leaving portal marked with 'F'. Now Tom is not such
a witty dwarf, but he heard you are good at algorithms, 
so he is wondering if you can help him out. 
Question:
Given the plane of the floors of the maze find the shortest 
path from the entering to the leaving portal.
 
Input specification  In the first line will be 1 ≤ a ≤ 5,
1 ≤ b ≤30, 1 ≤ c≤ 30 where 'a' is the
number of floors, while b and c are the lengths of width
and height of each floor.
 Output specification  If there is a way output the number of steps to reach the
destination, otherwise output "Impossible".
 
 
| Sample Input I 
 
2 4 5B....
 .###.
 .##..
 ###.#
 
 #####
 #####
 ##.##
 ##..F
 
 | Sample Input II 
 
1 3 3B##
 ###
 ##F
 
 |  
| Sample Output II 
 
10 
 | Sample Output II 
 
Impossible
 |  
 
 Для отправки решений необходимо выполнить вход.
 
 
 |