Kinds of figures
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.
Input
Your program should read numbers of rows N (1 ≤ N ≤ 1234), number of columns M (1 ≤ M ≤ 1234), and N lines consisting of exactly M characters '*' and/or '.' each.
Output
Your program should write two space-separated integers in one row — the total number of figures and number of different kinds of figures.