atcoder#KEYENCE2020F. Monochromization
Monochromization
Score : points
Problem Statement
We have an grid, where each square is painted white or black in the initial state.
Given are strings representing the colors of the squares in the initial state.
For each pair (, ), if the -th character of is .
, the square at the -th row and -th column is painted white; if that character is #
, that square is painted black.
Among the ways for each square in the grid to be painted white or black, how many can be obtained from the initial state by performing the operations below any number of times (possibly zero) in any order? Find this count modulo .
- Choose one row, then paint all the squares in that row white.
- Choose one row, then paint all the squares in that row black.
- Choose one column, then paint all the squares in that column white.
- Choose one column, then paint all the squares in that column black.
Constraints
- ()
- All strings consist of
.
and#
. - and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 2
#.
.#
15
For example, if we paint the second row black, the grid becomes:
#.
##
3 3
...
...
...
230
2 4
#...
...#
150
6 7
.......
.......
.#.....
..#....
.#.#...
.......
203949910