Sacred Scarecrows

Count subsets of empty cells in an R x C grid, modulo 1e9+7, such that every row has a scarecrow and every pair of consecutive columns has one.

Hard8Dynamic programmingBit manipulationCombinatoricsMatrixNo attempts yetTime limit2sMemory limit512 MB

Problem

Nerissa owns a rectangular paddy field of size R×CR \times C. The field is divided into RR rows and CC columns of equal square cells. Each cell is either empty soil that can hold a scarecrow or soil already planted with rice.

To keep birds such as crows and sparrows away from the crops, Nerissa wants to place scarecrows on the field. A scarecrow can stand only on an empty cell. To keep other people from stealing the crops, the placement must be sacred. A placement is sacred when it satisfies both conditions below:

  • Every row contains at least one scarecrow.
  • Every pair of consecutive columns contains at least one scarecrow.

Two placements differ when some cell holds a scarecrow in exactly one of them. Count the distinct sacred placements.

Input

The first line contains two integers RR and CC (1R141 \le R \le 14, 1C10001 \le C \le 1000), the number of rows and the number of columns. The next RR lines describe the field. Each line contains a string of length CC. Each cell is written as . for empty soil or v for soil planted with rice.

Output

Print the number of distinct sacred placements on one line. The number can be very large, so print it modulo 1,000,000,0071,000,000,007.

Hint

In the second sample case, 5 placements satisfy both conditions. With one row of three empty cells, 5 nonempty subsets cover both adjacent column pairs.

In the third sample case, the first row has no cell that can hold a scarecrow. Since every row needs at least one scarecrow, no sacred placement exists.

In the fifth sample case, 5 placements satisfy both conditions. The empty cells of the two rows are offset, so the row requirement and the column pair requirement together leave 5 possibilities.