시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 8 7 7 87.500%

문제

There is certain number of goats in Mickey's backyard. While he was firmly sleeping, hungry wolves came in the yard and attacked the goats.

Yard is of rectangular shape and consists of fields arranged in rows and columns. Character '.' (dot) denotes an empty field, character '#' denotes a fence, character 'k' denotes a goat and character 'v' denotes a wolf.

We consider that two fields are in the same region if we can move from one field to the other by a path consisting of horizontal and vertical moves only and not containing any fences. Fields from which we can "escape" from the yard are not considered to be a part of any region.

Fortunately, our goats know karate – they can fight the wolves within a region and win (i.e. kill wolves) if their number in that region is greater than number of wolves in the same region. Otherwise, wolves eat all the goats inside that region.

In the beginning, all the goats and wolves are situated inside regions in the yard.

Write a program that will calculate the number of goats and the number of wolves still alive in the morning.

입력

First line of input contains two integers, R i C, 3 ≤ R, C ≤ 250, the number of rows and the number of columns of Mickey's yard.

Each of the following R lines contains C characters. All of them together represent the layout of the yard i.e. positions of the fences, goats and wolves in the yard.

출력

First and only line of output should contain two numbers, number of goats and number of wolves still alive in the morning. 

예제 입력

6 6
...#..
.##v#.
#v.#.#
#.k#.#
.###.#
...###

예제 출력

0 2

예제 입력 2

8 8
.######.
#..k...#
#.####.#
#.#v.#.#
#.#.k#k#
#k.##..#
#.v..v.#
.######.

예제 출력 2

3 1

예제 입력 3

9 12
.###.#####..
#.kk#...#v#.
#..k#.#.#.#.
#..##k#...#.
#.#v#k###.#.
#..#v#....#.
#...v#v####.
.####.#vv.k#
.......####.

예제 출력 3

3 5

힌트