12081 - CS_2018_MID2-2   

Description

Compute the numbers of islands on the map.
The character '~' means water. There are two types of islands, denoted as '#' and '@'.
Take the following map for example:

The number of #-typed islands is 3, and the number of @-typed islands is 2.

Note that two '#'s are considered connected only if they are horizontal or vertical neighbors. Diagonal neighbors are not considered connected. The rule is the same for '@'.

Input

The first line contains two integers m, n, representing the height and width of the map.

The next m lines contain n characters for the mth row of the map.

It is guaranteed that 1 ≤ m, n ≤ 1000

Output

Print the number of islands for '#' and the number of islands for '@'.

The two numbers are separated by a whitespace. Please include a newline character '\n' at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss