P26394 [AtCoder] Reverse Grid
NOI
题目描述

Problem Description

There is a grid with $ H $ rows and $ W $ columns, and the cell at the $ i $-th row and $ j $-th column contains the character $ S_{i,j} $.

Snuke can perform the following two types of operations on this grid:

  • Row Reverse: Choose one row and reverse it.
  • Column Reverse: Choose one column and reverse it.

For example, if the 2nd row is reversed followed by reversing the 4th column, it changes as follows:

How many different configurations of characters can be created by performing these operations in any order and any number of times?

Input Format

The input is given from the 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 Format

Output the answer modulo $1000000007\ (=10^9+7)$.

Sample Input and Output

Sample Input #1

2 2
cf
cf

Sample Output #1

6

Sample Input #2

1 12
codefestival

Sample Output #2

2

Notes/Hints

Constraints

  • $ 1≦H,W≦200 $
  • $ S_{i,j} $ is a lowercase alphabet (a-z).

Sample Explanation 1

The following 6 configurations are possible:

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 2 cf cf
样例输出
6