QOJ.ac

QOJ

時間限制: 10 s 記憶體限制: 512 MB 總分: 10

#5243. Bacteria [A]

统计

Professor Albert Bajtsztajn is currently studying a newly discovered strain of bacteria, which he has tentatively named Algorithmic Proeliis. For his next experiment, he has prepared a large, rectangular table, which he has divided into $n \cdot m$ fields arranged in $n$ rows of $m$ fields each.

Next, for each field, the professor has chosen one of three options: he will either definitely place a Petri dish on it, definitely not do so, or flip a fair coin to decide. After placing the dishes, the only thing left to do to start the experiment is to choose a positive integer $k$ and place exactly $k$ bacteria in each dish.

Algorithmic Proeliis are characterized by a very hostile attitude toward other colonies, so the experiment will proceed as follows: as long as there exists a pair of adjacent, non-empty dishes, one such pair will be chosen (with uniform probability), and one bacterium will die in each of the two dishes. We assume that two dishes are adjacent if and only if the fields they stand on share a common side.

Given the randomness of the coin flips for the decision to place a dish in certain fields and the randomness in choosing pairs of adjacent dishes in which bacteria will die, let $f(k)$ denote the expected number of bacteria that will survive the entire experiment. The experiment naturally ends when there is no longer any pair of adjacent dishes containing at least one bacterium.

It would be difficult to place a few bacteria in the dishes. It is much easier to place many of them at once. For this reason, the professor pondered and then wrote the following expression on the board:

$$\lim_{k \to \infty} \frac{f(k)}{k}$$

Your task, as his assistant, is to calculate the value of the above limit. It can be proven that this value is always a rational number; therefore, present it as an irreducible fraction.

Input

The first line of standard input contains two integers $n$ and $m$ ($1 \le n, m \le 200$), representing the dimensions of the table.

The next $n$ lines contain the description of the table prepared by the professor. The $i$-th of these lines contains $m$ characters, where the $j$-th character is $a_{i,j}$.

  • If $a_{i,j}$ is '.', the field in the $i$-th row and $j$-th column will definitely remain empty.
  • If $a_{i,j}$ is 'O' (uppercase 'o'), a Petri dish will definitely be placed in the field in the $i$-th row and $j$-th column.
  • If $a_{i,j}$ is '?', the professor will flip a coin to decide whether a dish will be placed in the field in the $i$-th row and $j$-th column.

Output

The only line of output should contain the answer to the professor's question, written in the form 'a/b', where $b \ge 1$ and $\gcd(a, b) = 1$.

Examples

Input 1

4 5
O...O
?OO.?
.OOO.
?..O.

Output 1

5/2

Subtasks

  • In some test groups, the table description does not contain any '?' characters.
  • In some test groups, the table description contains at most 5 '?' characters.
  • In some test groups, the condition $n \le 1$ holds.
  • In some test groups, the condition $n \le 2$ holds.
  • In some test groups, the condition $n, m \le 25$ holds.
  • In some test groups, if $(i \cdot j)$ is divisible by 5, then $a_{i,j}$ is '.'.

For each of the cases mentioned above, there is at least one group that satisfies it. These groups for different conditions may or may not be disjoint.

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.