QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#13622. 小Z的礼物

Statistics

Little Z has a magical vending machine containing $n \times m$ items, arranged in a grid with $n$ rows and $m$ columns. Every time Little Z inserts a coin into the vending machine, he receives a pair of items from adjacent cells (items already obtained can be obtained again). The probability of obtaining any specific pair of adjacent items is equal. Among these $n \times m$ items, some are liked by Little Z (items liked by Little Z are marked with * [asterisk], and others are marked with . [period]). He wants to package these items into a gift. Little Z wants to know the expected number of coins he needs to insert to obtain all the items he likes.

Input

The first line contains two integers $n$ and $m$.

The next $n$ lines each contain a string of length $m$, consisting only of the characters * and ..

Output

An integer representing the answer modulo $998244353$.

Examples

Input 1

1 3
***

Output 1

3

Input 2

3 3
..*
*.*
.*.

Output 2

404051295

Constraints

For all data, it is guaranteed that $1 \leq n \leq 6$ and $2 \leq m \leq 100$.

This problem uses bundled testing. Each subtask contains several test cases and is divided into 5 subtasks. You must pass all test cases in a subtask to receive the points for that subtask.

For convenience, let $cnt$ be the number of * in the input, and $s$ be the size of the largest connected component (4-connectivity) consisting of *.

SubtaskScoreConstraints
110$cnt \leq 6$
220$cnt \leq 20$
320$s \leq 1$
420$s \leq 16$
530No special constraints

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.