#P6493. [COCI 2010/2011 #6] VODA

[COCI 2010/2011 #6] VODA

Description

In an r×sr \times s grid city, you are responsible for designing the water transportation system.

More specifically, you need to transport water from above the top-left corner (1,1)(1,1) to below the bottom-right corner (r,s)(r,s) by laying pipes.

Some cells are #, meaning there are obstacles and pipes cannot be placed there. The other cells are ., meaning pipes can be placed. Each . cell can contain one of the following six types of pipes (or you may place no pipe at all):

You need to find the total number of possible designs (mod 10007\bmod\ 10007), such that during transportation the water does not leak out of the pipes, and every pipe placed in the city is used.

Input Format

The first line contains two integers r,sr, s, representing the number of rows and columns of the city.

The next rr lines each contain ss characters: # means a pipe cannot be placed, and . means a pipe can be placed.

Output Format

Output one integer, the total number of designs (mod 10007\bmod\ 10007).

2 3
...
.#.
1
3 3
...
...
...
12

Hint

Sample 1 Explanation

For the first sample, there is only one valid layout as shown below:

Constraints

For 100%100\% of the testdata, it is guaranteed that 2r,s102 \le r, s \le 10.

Notes

Translated from COCI2010-2011 CONTEST #6 T6 VODA

Translated by ChatGPT 5