Test
In a kindergarten, a test is conducted where children are shown white rectangular sheets of paper divided into equal squares by horizontal and vertical lines. Some of these squares are painted black, while others remain white.
A "figure" in this context is defined as a group of black squares. For any two squares in this group, their centers can be connected by a path that stays entirely within the black squares and does not pass through any square's vertex.
Two figures are considered different if they cannot be made identical through a series of parallel translations, 90-degree rotations, or reflections across a vertical or horizontal line.
The task for the children is to determine how many figures are present in the drawing and how many of these figures are distinct.
Create a program that provides the correct answers to these questions.
Input
The first line contains the number of squares, n, which are arranged in a grid both vertically and horizontally.
The following n lines each contain n characters representing the drawing. A space (' ') indicates a white square, while any other character represents a black square.
In 20% of the tests, n ≤ 30; in 40% of the tests, n ≤ 90; in 60% of the tests, n ≤ 180; in 80% of the tests, n ≤ 360; and in all tests, n ≤ 528.
The number of cells in a single figure does not exceed: 50 in 20% of the tests, 500 in 36% of the tests, 2000 in 52% of the tests, 8000 in 68% of the tests, 15000 in 84% of the tests, and 125000 in 100% of the tests.
Output
Output a single line containing two natural numbers: the total number of figures and the number of distinct figures. It is guaranteed that both numbers do not exceed 248.