eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Kinds of figures

Kinds of figures

Ліміт часу 1 секунда
Ліміт використання пам'яті 256 MiB

Consider a rectangular table with N rows, M columns. Each cell of the table is either free (marked as '.') or filled (marked as '*'). Neighboring filled cells form figures. More formally:

  • cells are considered neighboring if and only if they have common edge;

  • filled cells belong to the same figure if and only if there is a sequence of filled cells which starts at oneof the given cells and finishes at another given, and each next cell is a neighbor of the previous.

Figures A and B are called figures of the same kind, if and only if one of them can be obtained from another by shifting (without rotation).

Your task is to write a program, which determines the total number of figures and number of different kinds of figures.

Вхідні дані

Your program should read numbers of rows N (1N1234), number of columns M (1M1234), and N lines consisting of exactly M characters '*' and/or '.' each.

Вихідні дані

Your program should write two space-separated integers in one row — the total number of figures and number of different kinds of figures.

Приклад

Вхідні дані #1
7 8
****.**.
****.**.
.....**.
.*.*.**.
.*.*...*
*.*.****
*.*.*.*.
Вихідні дані #1
7 4
Джерело ACM-ICPC Ukraine 2012, 2nd Stage Ukraine, September 6, 2012