Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

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.

No tag edit access

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

×
D. Turtles

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou've got a table of size *n* × *m*. We'll consider the table rows numbered from top to bottom 1 through *n*, and the columns numbered from left to right 1 through *m*. Then we'll denote the cell in row *x* and column *y* as (*x*, *y*).

Initially cell (1, 1) contains two similar turtles. Both turtles want to get to cell (*n*, *m*). Some cells of the table have obstacles but it is guaranteed that there aren't any obstacles in the upper left and lower right corner. A turtle (one or the other) can go from cell (*x*, *y*) to one of two cells (*x* + 1, *y*) and (*x*, *y* + 1), as long as the required cell doesn't contain an obstacle. The turtles have had an argument so they don't want to have any chance of meeting each other along the way. Help them find the number of ways in which they can go from cell (1, 1) to cell (*n*, *m*).

More formally, find the number of pairs of non-intersecting ways from cell (1, 1) to cell (*n*, *m*) modulo 1000000007 (10^{9} + 7). Two ways are called non-intersecting if they have exactly two common points — the starting point and the final point.

Input

The first line contains two integers *n*, *m* (2 ≤ *n*, *m* ≤ 3000). Each of the following *n* lines contains *m* characters describing the table. The empty cells are marked by characters ".", the cells with obstacles are marked by "#".

It is guaranteed that the upper left and the lower right cells are empty.

Output

In a single line print a single integer — the number of pairs of non-intersecting paths from cell (1, 1) to cell (*n*, *m*) modulo 1000000007 (10^{9} + 7).

Examples

Input

4 5

.....

.###.

.###.

.....

Output

1

Input

2 3

...

...

Output

1

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/15/2021 20:44:33 (j2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|