atcoder#KEYENCE2020F. Monochromization

Monochromization

Score : 11001100 points

Problem Statement

We have an H×WH \times W grid, where each square is painted white or black in the initial state. Given are strings A1,A2,...,AHA_1, A_2, ..., A_H representing the colors of the squares in the initial state. For each pair (i,j)(i, j) (1iH1 \leq i \leq H, 1jW1 \leq j \leq W), if the jj-th character of AiA_i is ., the square at the ii-th row and jj-th column is painted white; if that character is #, that square is painted black.

Among the 2HW2^{HW} 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 998,244,353998,244,353.

  • 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

  • 1H,W101 \leq H, W \leq 10
  • Ai=W|A_i| = W (1iH1 \leq i \leq H)
  • All strings AiA_i consist of . and #.
  • HH and WW are integers.

Input

Input is given from Standard Input in the following format:

HH WW

A1A_1

A2A_2

\vdots

AHA_H

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