atcoder#DPH. Grid 1

Grid 1

Score : 100100 points

Problem Statement

There is a grid with HH horizontal rows and WW vertical columns. Let (i,j)(i, j) denote the square at the ii-th row from the top and the jj-th column from the left.

For each ii and jj (1iH1 \leq i \leq H, 1jW1 \leq j \leq W), Square (i,j)(i, j) is described by a character ai,ja_{i, j}. If ai,ja_{i, j} is ., Square (i,j)(i, j) is an empty square; if ai,ja_{i, j} is #, Square (i,j)(i, j) is a wall square. It is guaranteed that Squares (1,1)(1, 1) and (H,W)(H, W) are empty squares.

Taro will start from Square (1,1)(1, 1) and reach (H,W)(H, W) by repeatedly moving right or down to an adjacent empty square.

Find the number of Taro's paths from Square (1,1)(1, 1) to (H,W)(H, W). As the answer can be extremely large, find the count modulo 109+710^9 + 7.

Constraints

  • HH and WW are integers.
  • 2H,W10002 \leq H, W \leq 1000
  • ai,ja_{i, j} is . or #.
  • Squares (1,1)(1, 1) and (H,W)(H, W) are empty squares.

Input

Input is given from Standard Input in the following format:

HH WW

a1,1a_{1, 1}\ldotsa1,Wa_{1, W}

::

aH,1a_{H, 1}\ldotsaH,Wa_{H, W}

Output

Print the number of Taro's paths from Square (1,1)(1, 1) to (H,W)(H, W), modulo 109+710^9 + 7.

3 4
...#
.#..
....
3

There are three paths as follows:

5 2
..
#.
..
.#
..
0

There may be no paths.

5 5
..#..
.....
#...#
.....
..#..
24
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
345263555

Be sure to print the count modulo 109+710^9 + 7.