484. Kola

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



One day Vasya decided to buy a bottle of his favourite Kola in the old vending machine. But he forgot that there was a Halloween that day, so evil forces had made an inner structure of the vending machine quite complicated. Inside the machine is represented by a table of size n × m. Some of the cells are empty, and some contains obstacles of two types: '/' and '\'. One of the cell initially contains a bottle of Kola. After the purchasing it starts to fall vertically down by the following rules:

Help Vasya to find out whether the bottle will reach the tray. In case of a positive answer, determine the number of column where it will happen.

Input
The first line of the input contains two integer numbers n and m (1 ≤ n, m ≤ 100). Then the description of the vending machine follows. It consists of n lines of m characters each: '.' means empty cell, 'P' means initial position of the bottle, '/' and '\' — mean obstacles of the corresponding type. It is guaranteed that the 'P' character appears exactly once.

Output
Print to the output -1 if the bottle doesn't reach the tray. Otherwise print the number of the column where the bottle will leave the vending machine. Columns are numbered starting from 1 from the leftmost one.

Example(s)
sample input
sample output
2 3
./P
../
2

sample input
sample output
2 2
.P
\/
-1

sample input
sample output
5 4
.P..
.\..
.//.
./..
/...
-1




Online Contester Team © 2002 - 2010. All rights reserved.