G. Grids of Grids
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Little Bobby Tables loves playing with tables. More specifically, he has a collection of $$$m$$$-by-$$$m$$$ tables, where each cell is either empty or colored in.

For two tables $$$T_1$$$ and $$$T_2$$$, Bobby defines the composition of $$$T_1$$$ and $$$T_2$$$ (denoted $$$T_1 \circ T_2$$$) to be the grid obtained by replacing each colored-in cell in $$$T_1$$$ with a copy of $$$T_2$$$, and each blank cell with a $$$m$$$-by-$$$m$$$ blank grid.

Examples of grid composition.

Two tables $$$T_1$$$ and $$$T_2$$$ are called commutative if $$$T_1 \circ T_2 = T_2 \circ T_1$$$. For example, the two tables in the picture above are not commutative, but two empty tables would be commutative.

You are given Bobby's collection of $$$n$$$ tables $$$T_1, T_2, \ldots, T_n$$$. Count the number of pairs $$$1 \leq i \lt j \leq n$$$ where $$$T_i$$$ and $$$T_j$$$ are commutative.

Input

The first line contains $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 5$$$).

The descriptions of Bobby's $$$n$$$ tables follow. Each table is described by $$$m$$$ lines of $$$m$$$ characters each. Each character is either . (denoting an empty cell), or X (denoting a colored-in cell).

Output

Print the number of commutative pairs.

Examples
Input
3 3
X.X
.X.
X.X
X.X
X.X
X..
X.X
.X.
X.X
Output
1
Input
4 5
XXXX.
X...X
XXXX.
X...X
XXXX.
XXXXX
X...X
XXXXX
X...X
X...X
XXXXX
X...X
XXXXX
X....
X....
XXXXX
X....
X....
X....
XXXXX
Output
0
Input
4 1
.
X
X
.
Output
6
Note

The first test corresponds to the pictures in the statement. Tables $$$T_1$$$ and $$$T_2$$$ are not commutative as shown above, and neither are $$$T_2$$$ and $$$T_3$$$. But $$$T_1$$$ and $$$T_3$$$ are equal, so $$$T_1 \circ T_3 = T_3 \circ T_1$$$. In total we have one commutative pair.