Reverse Grid

AtCoder
IDcodefestival_2016_final_i
Time2000ms
Memory256MB
Difficulty
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: ![image](https://atcoder.jp/img/code-festival-2016-final/31458935865e5db21bfbcd2eab9511da.png) 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}$ [samples]
Samples
Input #1
2 2
cf
cf
Output #1
6

The following $6$ placements of characters can be obtained:
![image](https://atcoder.jp/img/code-festival-2016-final/ddf2925467af2c9734194a886f819a2b.png)
Input #2
1 12
codefestival
Output #2
2
API Response (JSON)
{
  "problem": {
    "name": "Reverse Grid",
    "description": {
      "content": "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: *   R",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "codefestival_2016_final_i"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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}$.\nHe can perform the following two kinds of operation on the grid:\n\n*   R...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments