atcoder#CODEFESTIVAL2016FINALI. Reverse Grid
Reverse Grid
Score : points
Problem Statement
Snuke has a grid with rows and columns. The square at the -th row and -th column contains a character .
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 -nd row followed by reversing the -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
- is a lowercase English letter (
a
-z
).
Input
The input is given from Standard Input in the following format:
Output
Print the number of placements of characters on the grid that can be obtained, modulo .
2 2
cf
cf
6
The following placements of characters can be obtained:
1 12
codefestival
2