

Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 1900 点
問題文
縦 H 行、横 W 列のマス目があり、i 行目の j 列目のマスには文字 S_{i,j} が書かれています。
すぬけくんはこのマス目に対して以下の 2 種類の操作を行うことが出来ます。
- 行リバース:行を 1 つ選び、その行をリバースする。
- 列リバース:列を 1 つ選び、その列をリバースする。
例えば、2 行目をリバースした後に 4 列目をリバースすると以下のように変化します。
上記の操作を好きな順番で何回か行うことによって作ることの出来る文字の配置は何通り考えられるでしょうか?
制約
- 1≦H,W≦200
- S_{i,j} は小文字アルファベット(
a
-z
)である。
入力
入力は以下の形式で標準入力から与えられる。
H W S_{1,1}S_{1,2}...S_{1,W} S_{2,1}S_{2,2}...S_{2,W} : S_{H,1}S_{H,2}...S_{H,W}
出力
答えを 1000000007 (=10^9+7) で割ったあまりを出力せよ。
入力例 1
2 2 cf cf
出力例 1
6
以下の 6 通りの配置が考えられます。
入力例 2
1 12 codefestival
出力例 2
2
Score : 1900 points
Problem Statement
Snuke has a grid with H rows and W columns. The square at the i-th row and j-th column contains a character S_{i,j}.
He can perform the following two kinds of operation on the grid:
- Row-reverse: Reverse the order of the squares in a selected row.
- Column-reverse: Reverse the order of the squares in a selected column.
For example, reversing the 2-nd row followed by reversing the 4-th column will result as follows:
By performing these operations any number of times in any order, how many placements of characters on the grid can be obtained?
Constraints
- 1≦H,W≦200
- S_{i,j} is a lowercase English letter (
a
-z
).
Input
The input is given from Standard Input in the following format:
H W S_{1,1}S_{1,2}...S_{1,W} S_{2,1}S_{2,2}...S_{2,W} : S_{H,1}S_{H,2}...S_{H,W}
Output
Print the number of placements of characters on the grid that can be obtained, modulo 1000000007 (=10^9+7).
Sample Input 1
2 2 cf cf
Sample Output 1
6
The following 6 placements of characters can be obtained:
Sample Input 2
1 12 codefestival
Sample Output 2
2