stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.312525575559917x):
#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

const ll N=1005,M=1000000007;

ll i,j,n,m,dp[N][N];

char a[N][N];

int play(int x,int y){

	if(a[x][y]=='#') return 0;

	if(x==n-1) if(y==m-1) return 1;

	if(dp[x][y]!=-1) return dp[x][y];

	dp[x][y]=0;

	if(x+1<n) dp[x][y]=(dp[x][y]+play(x+1,y))%M;

	if(y+1<m) dp[x][y]=(dp[x][y]+play(x,y+1))%M;

	return dp[x][y];

}

int main(){

	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

	cin>>n>>m;

	for(i=0;i<n;++i){

		for(j=0;j<m;++j){

			dp[i][j]=-1;

			cin>>a[i][j];

		}

	}

	cout<<play(0,0);

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.450784990452462x):
#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

const ll N=1005,M=1000000007;

ll i,j,n,m,dp[N][N];

char a[N][N];

int play(int x,int y){

	if(a[x][y]=='#') return 0;

	if(x==n-1) if(y==m-1) return 1;

	if(dp[x][y]!=-1) return dp[x][y];

	dp[x][y]=0;

	if(x+1<n) dp[x][y]=(dp[x][y]+play(x+1,y))%M;

	if(y+1<m) dp[x][y]=(dp[x][y]+play(x,y+1))%M;

	return dp[x][y];

}

int main(){

	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

	cin>>n>>m;

	for(i=0;i<n;++i){

		for(j=0;j<m;++j){

			dp[i][j]=-1;

			cin>>a[i][j];

		}

	}

	cout<<play(0,0);

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.315637470956798x):
#include <bits/stdc++.h>

/**

*   author: j o s e m a g o

*   date:

**/

using namespace std;

#pragma GCC optimize ("Ofast")

#define f first

#define s second

#define mp make_pair

#define lb lower_bound

#define ub upper_bound

#define all(v) (v).begin(),(v).end()

#define mset(a,v) memset(a,v,sizeof(a))

#define pb push_back

#define sz(x) ((int)(x).size())

#define rsz resize

#define ln "\n"



typedef double db;

typedef unsigned long long ull;

typedef long long ll;

typedef long double ld;

const ld PI = 2*acos(0.0);

const int MOD = 1000000007;

const int JJJ = 1009;



char matrix[JJJ][JJJ];

int dp[JJJ][JJJ],f,c;









int main(){



  //freopen("input.in","r",stdin);

  //freopen("input.out","w",stdout);



    ios_base::sync_with_stdio(0); cin.tie(0);



    cin >> f >> c;

    for(int i = 1;i <= f;i++){

        for(int j = 1;j <= c;j++){

            cin >> matrix[i][j];

        }

    }

    dp[1][1] = 1;

    for(int i = 1;i <= f;i++){

        for(int j = 1;j <= c;j++){

            if(i == 1 && j == 1) continue;

            if(matrix[i][j] != '#'){

                if(matrix[i-1][j] != '#'){

                    dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;

                }

                if(matrix[i][j-1] != '#'){

                    dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;

                }

            }

        }

    }



    cout<<dp[f][c];

















    return 0;

}

/*

3 4

...#

.#..

....



5 2

..

#.

..

.#

..



5 5

..#..

.....

#...#

.....

..#..





20 20

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................



*/
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.453943086939832x):
#include <bits/stdc++.h>

/**

*   author: j o s e m a g o

*   date:

**/

using namespace std;

#pragma GCC optimize ("Ofast")

#define f first

#define s second

#define mp make_pair

#define lb lower_bound

#define ub upper_bound

#define all(v) (v).begin(),(v).end()

#define mset(a,v) memset(a,v,sizeof(a))

#define pb push_back

#define sz(x) ((int)(x).size())

#define rsz resize

#define ln "\n"



typedef double db;

typedef unsigned long long ull;

typedef long long ll;

typedef long double ld;

const ld PI = 2*acos(0.0);

const int MOD = 1000000007;

const int JJJ = 1009;



char matrix[JJJ][JJJ];

int dp[JJJ][JJJ],f,c;









int main(){



  //freopen("input.in","r",stdin);

  //freopen("input.out","w",stdout);



    ios_base::sync_with_stdio(0); cin.tie(0);



    cin >> f >> c;

    for(int i = 1;i <= f;i++){

        for(int j = 1;j <= c;j++){

            cin >> matrix[i][j];

        }

    }

    dp[1][1] = 1;

    for(int i = 1;i <= f;i++){

        for(int j = 1;j <= c;j++){

            if(i == 1 && j == 1) continue;

            if(matrix[i][j] != '#'){

                if(matrix[i-1][j] != '#'){

                    dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;

                }

                if(matrix[i][j-1] != '#'){

                    dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;

                }

            }

        }

    }



    cout<<dp[f][c];

















    return 0;

}

/*

3 4

...#

.#..

....



5 2

..

#.

..

.#

..



5 5

..#..

.....

#...#

.....

..#..





20 20

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................

....................



*/
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.317090941062007x):
#include <bits/stdc++.h>



using namespace std;



#define F first

#define S second

#define modulo ll (1e9 + 7)



typedef long long ll;

typedef pair<int,int> pii;



void init(){

    cin.tie(0);

    cin.sync_with_stdio(0);

}



const int N = 1e3 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;

const ll llOO = 0x3f3f3f3f3f3f3f3f;



int h, w;

char grid[N][N];



int dp[N][N];



void go(int tc){

    cin >> h >> w;

    for(int i = 0;i < h;i++)

        for(int j = 0;j < w;j++)

            cin >> grid[i][j];





    dp[0][0] = 1;

    for(int i = 0;i < h;i++){

        for(int j = 0;j < w;j++){

            if(grid[i][j] == '#')   continue;

            if(i)   dp[i][j] += dp[i - 1][j];

            if(j)   dp[i][j] += dp[i][j - 1];



            dp[i][j] %= modulo;

        }

    }



    cout << dp[h - 1][w - 1];

}



int main(){

    init();



    int t, tc = 1;  t = 1;//cin >> t;

    while(t--)  go(tc++);



}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.45541813614565x):
#include <bits/stdc++.h>



using namespace std;



#define F first

#define S second

#define modulo ll (1e9 + 7)



typedef long long ll;

typedef pair<int,int> pii;



void init(){

    cin.tie(0);

    cin.sync_with_stdio(0);

}



const int N = 1e3 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;

const ll llOO = 0x3f3f3f3f3f3f3f3f;



int h, w;

char grid[N][N];



int dp[N][N];



void go(int tc){

    cin >> h >> w;

    for(int i = 0;i < h;i++)

        for(int j = 0;j < w;j++)

            cin >> grid[i][j];





    dp[0][0] = 1;

    for(int i = 0;i < h;i++){

        for(int j = 0;j < w;j++){

            if(grid[i][j] == '#')   continue;

            if(i)   dp[i][j] += dp[i - 1][j];

            if(j)   dp[i][j] += dp[i][j - 1];



            dp[i][j] %= modulo;

        }

    }



    cout << dp[h - 1][w - 1];

}



int main(){

    init();



    int t, tc = 1;  t = 1;//cin >> t;

    while(t--)  go(tc++);



}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.302181715405201x):
#include <bits/stdc++.h>

#define inf INFINITY

#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ;

#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define _3102_ main()

#define endl '\n'

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

using namespace std;

const int N = 2e5 + 100;

const ll MX = 1e9;

const ll mod = 1e9 + 7;

const double eps = 1e-9 ;



char grid[1100][1100] ;

int n, m, dp[1100][1100] = { } ;



int _3102_{

	Gamed

	cin >> n >> m ;

	for ( int i = 0 ; i < n ; i ++){

		for ( int j = 0 ; j < m ; j ++){

			cin >> grid[i][j] ;

		}

	}

	dp[0][0] = 1 ;

	for ( int i = 1 ; i < n ; i ++){

		dp[i][0] = (grid[i][0] == '#' ? 0 : dp[i-1][0])  ;

	}

	for ( int i = 1 ; i < m ; i ++){

		dp[0][i] = (grid[0][i] == '#' ? 0 : dp[0][i-1] ) ;

	}

	for ( int i = 1 ; i < n ; i ++){

		for ( int j = 1 ; j < m ; j ++){

			if ( grid[i][j] == '#'){

				dp[i][j] = 0 ;

				continue ;

			}

			dp[i][j] = ((dp[i-1][j]%mod) + (dp[i][j-1]%mod))%mod ;

		}

	}

	cout << dp[n-1][m-1] << endl ;

	return 0;

}



/*

3 4

...#

.#..

....

*/
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.440287559062842x):
#include <bits/stdc++.h>

#define inf INFINITY

#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ;

#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define _3102_ main()

#define endl '\n'

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

using namespace std;

const int N = 2e5 + 100;

const ll MX = 1e9;

const ll mod = 1e9 + 7;

const double eps = 1e-9 ;



char grid[1100][1100] ;

int n, m, dp[1100][1100] = { } ;



int _3102_{

	Gamed

	cin >> n >> m ;

	for ( int i = 0 ; i < n ; i ++){

		for ( int j = 0 ; j < m ; j ++){

			cin >> grid[i][j] ;

		}

	}

	dp[0][0] = 1 ;

	for ( int i = 1 ; i < n ; i ++){

		dp[i][0] = (grid[i][0] == '#' ? 0 : dp[i-1][0])  ;

	}

	for ( int i = 1 ; i < m ; i ++){

		dp[0][i] = (grid[0][i] == '#' ? 0 : dp[0][i-1] ) ;

	}

	for ( int i = 1 ; i < n ; i ++){

		for ( int j = 1 ; j < m ; j ++){

			if ( grid[i][j] == '#'){

				dp[i][j] = 0 ;

				continue ;

			}

			dp[i][j] = ((dp[i-1][j]%mod) + (dp[i][j-1]%mod))%mod ;

		}

	}

	cout << dp[n-1][m-1] << endl ;

	return 0;

}



/*

3 4

...#

.#..

....

*/
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.416662109374403x):
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define ll long long

#define mod 1000000007

using namespace std;

const int N = 1010;

int dp[N][N];

char str[N][N];

int main(){

	int n, m;

	cin >> n >> m;

	for(int i = 0; i < n; i++)

		for(int j = 0; j < m; j++)

			cin >> str[i][j];

	for(int i = 0; i < n; i++){

		for(int j = 0; j < m; j++){

			if(str[i][j] == '#')

				dp[i][j] = 0;

			else if(i == 0 && j == 0)

				dp[i][j] = 1;

			else if(j == 0)

				dp[i][j] = dp[i - 1][j];

			else if(i == 0)

				dp[i][j] = dp[i][j - 1];

			else

				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;

		}

	}

	cout << dp[n - 1][m - 1] << "\n";

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef double dd;

#define all(v) v.begin(),v.end()

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



const ll mod = 1e9 + 7;

ll n, m, dp[1000 + 9][1000 + 9];

char arr[1000][1000];



ll ans(ll i, ll j) {

    ll &ret=dp[i][j];

    if(~ret)return ret;

    if (i == n || j == m||arr[i][j]=='#')return 0;

    if (i == n - 1 && j == m - 1)return 1;

    ll path1 = ans(i + 1, j) % mod;

    ll path2 = ans(i, j + 1) % mod;

    return ret=(path1+path2)%mod;

}



int main() {

    fast();

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {

        for (int j = 0; j < m; ++j) {

            cin >> arr[i][j];

        }

    }

    clr(dp,-1);

    cout << ans(0, 0);

}

// Faster C++ solution for the same problem (measured speedup: 9.556467598542644x):
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define ll long long

#define mod 1000000007

using namespace std;

const int N = 1010;

int dp[N][N];

char str[N][N];

int main(){

	int n, m;

	cin >> n >> m;

	for(int i = 0; i < n; i++)

		for(int j = 0; j < m; j++)

			cin >> str[i][j];

	for(int i = 0; i < n; i++){

		for(int j = 0; j < m; j++){

			if(str[i][j] == '#')

				dp[i][j] = 0;

			else if(i == 0 && j == 0)

				dp[i][j] = 1;

			else if(j == 0)

				dp[i][j] = dp[i - 1][j];

			else if(i == 0)

				dp[i][j] = dp[i][j - 1];

			else

				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;

		}

	}

	cout << dp[n - 1][m - 1] << "\n";

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

	else if (i == h-1 && j == w-1) return 1;

	else if (path[i][j] == '#') return 0; 

	else

	{

		if (memo[i][j] != -1) return memo[i][j];

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

	for (int i = 0; i < h; i += 1)

		for (int j = 0; j < w; j++)

			cin >> path[i][j];



	cout << numberofpath(0,0) << endl;

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.287028661255189x):
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#include<bits/stdc++.h>  

#define endl "\n"

using namespace std;

	typedef long long ll;

	const int maxn=1050;

	const int inf=0x3f3f3f3f;

	const int mod=1e9+7;

	int ans;

	char _map[maxn][maxn];

	int dp[maxn][maxn];

	ll n,m;

	int main(){

		IOS

		cin>>n>>m;

		for(int i=1;i<=n;i++)

			for(int j=1;j<=m;j++)

				cin>>_map[i][j];

		dp[1][1]=1;

		for(int i=1;i<=n;i++)

			for(int j=1;j<=m;j++){

				if(_map[i][j-1]!='#'){

					dp[i][j]+=dp[i][j-1];

					dp[i][j]%=mod;

				}

				if(_map[i-1][j]!='#'){

					dp[i][j]+=dp[i-1][j];

					dp[i][j]%=mod;

				}

			}

		ans=dp[n][m];

		cout<<ans<<endl;

	}