NFP is the future!, this is something all of Noa's friends can expect him to say when finance topics come up.
NFP is one of the cryptocurrencies. The value of NFP over the course of days
can be represented with a matrix with rows and columns, consisting only
of characters .
and #
. The character #
in the -th column represents the value
of NFP on the -th day, with the value being the number of the row, counted
bottom-up.
....##.
#..#...
.##....
......#
The insecurity of NFP is defined as the difference between the maximum and minimum value it achieves over the course of days.
Noa wants to determine the insecurity for NFPs, whose values are represented by matrices with rows and columns.
Help him determine the insecurity of each of the NFPs.
Input Specification
The first line contains integers , , and , the number of NFPs, and the number of rows and columns of the matrices.
matrices follow, one below another, each with rows and columns, representing NFP values. Each
column consists only of characters .
, except for exactly one character #
.
Output Specification
Print lines. In the -th of , lines print the insecurity of the -th NFP.
Constraints
Subtask | Points | Constraints |
---|---|---|
No additional constraints. |
Sample Input 1
4 2 2
##
..
..
##
#.
.#
.#
#.
Sample Output 1
0
0
1
1
Explanation for Sample Output 1
The values of the first and the second NFP do not change over the days, so their insecurities are equal to . The value of the third NFP decreases by on the second day, so the insecurity is equal to . The value of the fourth NFP increases by on the second day, so the insecurity is equal to .
Sample Input 2
1 5 8
.....#.#
...#..#.
..#.#...
.#......
#.......
Sample Output 2
4
Explanation for Sample Output 2
The maximum value NFP has is (on days and ), and the minimum value is (on day ). Therefore, the insecurity is equal to .
Sample Input 3
2 3 3
...
##.
..#
.#.
#..
..#
Sample Output 3
1
2
Comments