QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#16457. Little Z's Room

Estadísticas

You have suddenly acquired a large house with several rooms. In fact, your house can be viewed as a grid of $n \times m$ cells, where each cell is either a room or a pillar. Initially, there is a wall between every pair of adjacent cells.

You want to break down some walls between adjacent rooms so that all rooms are reachable from one another. During this process, you cannot break through the exterior of the house, nor can you break through any pillars (or the walls adjacent to pillars). Additionally, you do not want it to be difficult to catch a thief in the house, so you want there to be exactly one path between any two rooms. Now, you want to calculate the total number of feasible schemes.

Input

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

The next $n$ lines each contain $m$ characters, where each character is either '.' or '', with '.' representing a room and '' representing a pillar.

Output

Output a single integer representing the number of valid schemes.

Constraints

  • For the first 20% of the data, $n, m \le 3$.
  • For the first 50% of the data, $n, m \le 5$.
  • For 100% of the data, $n, m \le 9$.
  • 40% of the data guarantees $\min(n, m) \le 3$.
  • 30% of the data guarantees there are no pillars.
  • Note: The answer should be taken modulo $1\,000\,000\,000$.

Examples

Input 1

2 2
..
..

Output 1

4

Input 2

2 2
*.
.*

Output 2

0

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.