DWITE Contest

Test Case for Question #5 in DWITE 2008-2009 High School Round 2

Contest: DWITE 2008-2009 High School Round 2
Question: #5
Input File: DATA5.txt
Output File: OUT5.txt


Input

6
5
5
AAAAA
#AAAA
##AAA
###AA
####A

7
10
3
..........
#.#.#.#.#.
#A#A#A#A#A

5
10
3
..........
..........
AAAAA.....

8
6
4
......
.....A
....##
...#AA

12
10
4
.AA.......
###...AAAA
......AAAA
AA####AAAA




Output

6
4
0
1
9