Problem p02800 - Generation 1

Orig Description

Score : 1100 points
Problem StatementWe have an H \times W grid, where each square is painted white or black in the initial state.
Given are strings A_1, A_2, ..., A_H representing the colors of the squares in the initial state.
For each pair (i, j) (1 \leq i \leq H, 1 \leq j \leq W), if the j-th character of A_i is ., the square at the i-th row and j-th column is painted white; if that character is #, that square is painted black.
Among the 2^{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,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
1 \leq H, W \leq 10
|A_i| = W (1 \leq i \leq H)
All strings A_i consist of . and #.
H and W are integers.
InputInput is given from Standard Input in the following format:
H W
A_1
A_2
\vdots
A_H
OutputPrint the answer.
Sample Input 12 2
#.
.#
Sample Output 115
For example, if we paint the second row black, the grid becomes:
#.
##
Sample Input 23 3
...
...
...
Sample Output 2230
Sample Input 32 4
#...
...#
Sample Output 3150
Sample Input 46 7
.......
.......
.#.....
..#....
.#.#...
.......
Sample Output 4203949910

Extracted Specification

Canonicalized Input Description:

An integer H (1 ≤ H ≤ 10), representing some quantity or size.
An integer W (1 ≤ W ≤ 10), representing some quantity or size.
A list of H strings, each of length W, consisting of characters '.' and '#'.

### Example Input:

```
2
2
#.
.#
```

### Function Signature:
Write a function f(H, W, A) that takes in the input.
```python
def f(H: int, W: int, A: List[str]):
    '''
    H: an integer
    W: an integer
    A: a list of strings
    '''
```

Test Case Generator

Sure, let's write a test case generator for the given problem statement. This generator will create random test cases within the specified constraints.

Here's the Python code for the test case generator:

```python
import random

def tcgen():
    # Randomly generate the dimensions of the grid H and W
    H = random.randint(1, 10)
    W = random.randint(1, 10)
    
    # Randomly generate the grid with 'H' rows and 'W' columns consisting of '.' and '#'
    grid = []
    for _ in range(H):
        row = ''.join(random.choice(['.', '#']) for _ in range(W))
        grid.append(row)
    
    return H, W, grid

# Generate a test case and print it
H, W, grid = tcgen()
print(H, W)
for row in grid:
    print(row)
```

This generator will produce random grids within the constraints, ensuring that each grid is between 1 and 10 rows and columns, and each cell in the grid is either a '.' (white) or '#' (black).

Let's walk through the generated test case output:

```text
H W
A_1
A_2
...
A_H
```

For example, if the generated grid has dimensions 3x4, the output might look like this:

```text
3 4
.#..
##.#
...#
```

This output is ready to be used as an input for the problem statement. You can run the `tcgen` function multiple times to generate different test cases for extensive testing.

Extract Arguments

def extract_arguments(fh):
    H, W = map(int, fh.readline().strip().split())
    A = [fh.readline().strip() for _ in range(H)]
    return H, W, A

# if __name__ == "__main__":
#     input_path = sys.argv[1]
#     with open(input_path, 'r') as fh:
#         H, W, A = extract_arguments(fh)
#     f(H, W, A)