Problem:
Score : 100 points

Problem Statement

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

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

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

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

Constraints

H and W are integers.

2 \leq H, W \leq 1000

a_{i, j} is . or #.

Squares (1, 1) and (H, W) are empty squares.

Input

Input is given from Standard Input in the following format:

H W
a_{1, 1}\ldotsa_{1, W}
:
a_{H, 1}\ldotsa_{H, W}

Output

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

Sample Input 1

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

Sample Output 1

3

There are three paths as follows:

Sample Input 2

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

Sample Output 2

0

There may be no paths.

Sample Input 3

5 5
..#..
.....
#...#
.....
..#..

Sample Output 3

24

Sample Input 4

20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................

Sample Output 4

345263555

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

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 27
#endif

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)(v.size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ar array
#define forn(i, n) for(int i = 0; i < n ; ++i)
#define for1(i, n) for(int i = 1; i <=n ; ++i)
#define ford(i, n) for(int i = n-1; i>= 0;--i)
#define UNQ(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mem(X,val) memset(X, val, sizeof((X)))

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>>  vvi ;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi ;

const db PI = acos(-1);
const ll mod = 1e9+7;
template <class T>void smax(T& x,T y){ if(x<y)x=y;}
template <class T>void smin(T& x,T y){ if(x>y)x=y;}
template<typename T1, typename T2> T1 powz(T1 A, T2 B);
/***************************************************main code**************************************************************/
const int MXN=1e6+5;
const ll INF = 9e18+200;
const int inf = 1e9+100;
const int mxn = 2e5+20;


void test_case()
{		
	int h,w; cin >> h >> w;
	char grid[h][w];
	forn(i, h) forn(j, w) cin >> grid[i][j];
//	forn(i, h) forn(j, w) cout<< grid[i][j]<<" \n"[j==w-1];
//	exit(0);
	vector<vi> dp(h+1, vi(w+1,0));
	dp[0][0] = 1;
	forn(i, h+1)
		forn(j, w+1) {
			if(i> 0 && grid[i][j] == '.' && grid[i-1][j]=='.')
				(dp[i][j] += dp[i-1][j]) %= mod;
			if(j> 0 && grid[i][j] == '.' && grid[i][j-1]=='.')
				(dp[i][j] += dp[i][j-1]) %= mod;
		}
	//forn(i, h)
	//	forn(j, w)
	//		cout<<dp[i][j]<<" \n"[j==w-1];
		
	cout << dp[h-1][w-1];
						     
}
/*************----------------------------******************/
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef VIJY_DEFINE
    freopen("input.txt","r",stdin);
#endif
//  freopen("output.txt","w",stdout);
    int Tests = 1;
//  cin >> Tests;
    
    for(int tc = 1; tc <= Tests; ++tc){
        //cout <<"Case #"<<tc<<": ";
        test_case();
        cout<<'\n';
    }
#ifdef VIJY_DEFINE
    cerr << "Time elapsed: "<< 1.0*clock() / CLOCKS_PER_SEC <<"s.\n";
#endif   
}
template<typename T1, typename T2>
T1 powz(T1 X,T2 B)
{
    ll A = X;
    ll res=1;
        A%=mod; 
        assert(B>=0); 
    for( ; B ; B>>=1){
        if(B&1)res=res*A%mod;
        A= A*A%mod;
    }
    return res;
}