Mino - MarisaOJ: Marisa Online Judge

Mino

Time limit: 1000 ms
Memory limit: 256 MB
After buying a obscure box from a yard sale, Marisa found a letter inside it. The letter was written using a weird language, so Marisa asked Kosuzu, who can read anything, for help. The letter can be represented as a matrix of $n \times n$ consisting of these characters: - `x` : ink. - `.` : nothing. Two cells are considered adjacent if they share an edge. A letter is a connected component of adjacent cells with ink. In other words, all the cells in a letter must be reachable from each other by moving through adjacent cells with ink. Before reading, Kosuzu wants to know how many different letters are there. Two letters are similar if you can apply 90-degree rotation or reflection to turn a letter into the other. 90-degree rotation: ``` xx .x --> x.x xx xxx ``` Reflection: ``` xx xx .x --> x. xx xx ``` ### Input - The first line contains an integer $n$. - The next $n$ lines is the letter, each line contains $n$ characters. ### Output - Print the number of different characters. ### Constraints - $1 \le n \le 1000$. ### Example Input: ``` 5 xxx.. x..x. .x..x .x..x x..xx ``` Output: ``` 3 ``` #### Note: There are 3 different letters: ``` x. x. xx xx x ```