Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official.
×

Educational Codeforces Round 27 |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

bitmasks

dp

*2500

No tag edit access

The problem statement has recently been changed. View the changes.

×
F. Guards In The Storehouse

time limit per test

1.5 secondsmemory limit per test

512 megabytesinput

standard inputoutput

standard outputPolycarp owns a shop in the capital of Berland. Recently the criminal activity in the capital increased, so Polycarp is thinking about establishing some better security in the storehouse of his shop.

The storehouse can be represented as a matrix with *n* rows and *m* columns. Each element of the matrix is either . (an empty space) or x (a wall).

Polycarp wants to hire some guards (possibly zero) to watch for the storehouse. Each guard will be in some cell of matrix and will protect every cell to the right of his own cell and every cell to the bottom of his own cell, until the nearest wall. More formally, if the guard is standing in the cell (*x*_{0}, *y*_{0}), then he protects cell (*x*_{1}, *y*_{1}) if all these conditions are met:

- (
*x*_{1},*y*_{1}) is an empty cell; - either
*x*_{0}=*x*_{1}and*y*_{0}≤*y*_{1}, or*x*_{0}≤*x*_{1}and*y*_{0}=*y*_{1}; - there are no walls between cells (
*x*_{0},*y*_{0}) and (*x*_{1},*y*_{1}). There can be a guard between these cells, guards can look through each other.

Guards can be placed only in empty cells (and can protect only empty cells). The plan of placing the guards is some set of cells where guards will be placed (of course, two plans are different if there exists at least one cell that is included in the first plan, but not included in the second plan, or vice versa). Polycarp calls a plan suitable if there is not more than one empty cell that is not protected.

Polycarp wants to know the number of suitable plans. Since it can be very large, you have to output it modulo 10^{9} + 7.

Input

The first line contains two numbers *n* and *m* — the length and the width of the storehouse (1 ≤ *n*, *m* ≤ 250, 1 ≤ *nm* ≤ 250).

Then *n* lines follow, *i*th line contains a string consisting of *m* characters — *i*th row of the matrix representing the storehouse. Each character is either . or x.

Output

Output the number of suitable plans modulo 10^{9} + 7.

Examples

Input

1 3

.x.

Output

3

Input

2 2

xx

xx

Output

1

Input

2 2

..

..

Output

10

Input

3 1

x

.

x

Output

2

Note

In the first example you have to put at least one guard, so there are three possible arrangements: one guard in the cell (1, 1), one guard in the cell (1, 3), and two guards in both these cells.

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/01/2023 12:23:09 (l1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|