P29918 [洛谷] [COCI2022-2023#1] Desni klik
普及-
题目描述

Problem Background

NFP is the future! When it comes to financial topics, Noa's friends all want to hear him say this.

Problem Description

NFP is a type of cryptocurrency. The value of one NFP over $s$ days can be represented by a character matrix of $r$ rows and $s$ columns, containing only the characters . and #. A # at the $j$-th row from the bottom in the $i$-th column indicates that the value of the NFP on the $i$-th day is $j$.

The "insecurity level" of NFP is defined as the difference between the maximum and minimum values it reaches within $s$ days.

....##.
#..#...
.##....
......#

As shown above, the values of this NFP over 7 days are: $3, 2, 2, 3, 4, 4, 1$. Its "insecurity level" is 3.

Now, Noa wants you to determine the insecurity level of the $n$ NFPs he has.

Input Format

The first line contains three integers $n, r, s$, representing the number of NFPs, the number of rows, and the number of columns of the matrix, respectively.

The following $n$ blocks of $r$ lines each containing $s$ characters describe the value of each NFP over $s$ days.

It is guaranteed that each column in the value matrix of each NFP contains exactly one #.

Output Format

Output $n$ lines, each representing the insecurity level of each NFP.

Sample Input and Output

Sample Input #1

4 2 2
##
..
..
##
#.
.#
.#
#.

Sample Output #1

0
0
1
1

Sample Input #2

1 5 8
.....#.#
...#..#.
..#.#...
.#......
#.......

Sample Output #2

4

Sample Input #3

2 3 3
...
##.
..#
.#.
#..
..#

Sample Output #3

1
2

Notes

Subtask Score Special Conditions
$1$ $5$ $r = s = 2$
$2$ $15$ $n = 1$
$3$ $30$ No special conditions

For $100\%$ of the data, $1 \leq n \leq 20, 2 \leq r, s \leq 50$.

This problem is worth a total of $50$ points.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 2 2 ## .. .. ## #. .# .# #.
样例输出
0 0 1 1