atcoder#CODEFESTIVAL2016FINALI. Reverse Grid

Reverse Grid

Score : 19001900 points

Problem Statement

Snuke has a grid with HH rows and WW columns. The square at the ii-th row and jj-th column contains a character Si,jS_{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 22-nd row followed by reversing the 44-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

  • 1H,W2001 \leq H,W \leq 200
  • Si,jS_{i,j} is a lowercase English letter (a-z).

Input

The input is given from Standard Input in the following format:

HH WW

S1,1S_{1,1}S1,2S_{1,2}......S1,WS_{1,W}

S2,1S_{2,1}S2,2S_{2,2}......S2,WS_{2,W}

::

SH,1S_{H,1}SH,2S_{H,2}......SH,WS_{H,W}

Output

Print the number of placements of characters on the grid that can be obtained, modulo 1000000007(=109+7)1000000007 (=10^9+7).

2 2
cf
cf
6

The following 66 placements of characters can be obtained:

1 12
codefestival
2