stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

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

        return 0 ;

    if(dp[i][j]!=-1)

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


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

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define eb emplace_back

#define fi first

#define se second

#define lb lower_bound

#define ub upper_bound

const int mod = 1e9+7;

const int mx = INT_MAX;

const long double pi = 4*atan((long double)1);

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vii;

int dp[1005][1005];

int n,m;

char mat[1005][1005];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

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

		{

			cin>>mat[i][j];

		}

	}

	dp[0][0] = 1;

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

	{

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

		{

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

				continue;

			if(i>0)

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

			if(j>0)

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

		}

	}

	cout<<dp[n-1][m-1]%mod;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

#include<unordered_set>	

using namespace std;

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

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

#define clr(v, d)		memset(v, d, sizeof(v))

#define rep(i, v)		for(int i=0;i<sz(v);++i)

#define lp(i, n)		for(int i=0;i<(int)(n);++i)

typedef long long         ll;

const double EPS = (1e-7);

int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

#define pb					push_back

#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

clock_t T;

#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl

void GOAT()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

	//freopen("output.txt", "w	", stdout);

#else

#endif



}

int r, c;

char grid[1007][1007];

int mem[1007][1007];

bool valid(int i, int j)

{

	return (i < r && j < c);

}

const int m = 1e9 + 7;

int solve(int i, int j)

{

	if (i == r - 1 && j == c - 1)return 1;

	int& ret = mem[i][j];

	if (~ret)return ret;

	ret = 0;

	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;

	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;

	return ret%m;

}

int main() {

	//GOAT();

	

		clr(mem, -1);

		cin >> r >> c;

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

		{

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

			{

				cin>>grid[i][j];

			}

		}

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

}

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

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define eb emplace_back

#define fi first

#define se second

#define lb lower_bound

#define ub upper_bound

const int mod = 1e9+7;

const int mx = INT_MAX;

const long double pi = 4*atan((long double)1);

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vii;

int dp[1005][1005];

int n,m;

char mat[1005][1005];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

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

		{

			cin>>mat[i][j];

		}

	}

	dp[0][0] = 1;

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

	{

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

		{

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

				continue;

			if(i>0)

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

			if(j>0)

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

		}

	}

	cout<<dp[n-1][m-1]%mod;

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



using namespace std;

typedef long long ll;



const int N = 1007, M = 1e9 + 7;



char mat[N][N];





int memo[N][N];

int n, m;



int solve(int i, int j) {

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

    if(i >= n or j >= m) return 0;



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

    

    int & st = memo[i][j];

    if(st == -1) {

        st = solve(i+1, j) + solve(i, j+1);

        st %= M;

    }

    return st;

}



int main() {

    memset(memo, -1, sizeof memo);

    cin >> n >> m;



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

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

            cin >> mat[i][j];

        }

    }



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

}

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

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define eb emplace_back

#define fi first

#define se second

#define lb lower_bound

#define ub upper_bound

const int mod = 1e9+7;

const int mx = INT_MAX;

const long double pi = 4*atan((long double)1);

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vii;

int dp[1005][1005];

int n,m;

char mat[1005][1005];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

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

		{

			cin>>mat[i][j];

		}

	}

	dp[0][0] = 1;

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

	{

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

		{

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

				continue;

			if(i>0)

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

			if(j>0)

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

		}

	}

	cout<<dp[n-1][m-1]%mod;

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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

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

        return 0 ;

    if(dp[i][j]!=-1)

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


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

using namespace std;

typedef long long ll;

char dp[1001][1001]; ll dpt[1001][1001];



ll solve(ll s,ll e,ll n,ll m)

{

    if(s==n || e==m)

        return 0;

    if(s==n-1 && e==m-1)

        return 1;

    if(dpt[s][e]!=-1)

        return dpt[s][e];

    if(dp[s][e]=='#')

        return 0;

    ll a=0;

    a=(solve(s+1,e,n,m)%1000000007+solve(s,e+1,n,m)%1000000007)%1000000007;

    dpt[s][e]=a;

    return a;

}



int main()

{

    ll n,m,i,j,k;

    cin>>n>>m;

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

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

            cin>>dp[i][j];

        }

    }

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

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

            dpt[i][j]=-1;

        }

    }

    ll s=solve(0,0,n,m);

    cout<<s<<endl;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

#include<unordered_set>	

using namespace std;

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

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

#define clr(v, d)		memset(v, d, sizeof(v))

#define rep(i, v)		for(int i=0;i<sz(v);++i)

#define lp(i, n)		for(int i=0;i<(int)(n);++i)

typedef long long         ll;

const double EPS = (1e-7);

int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

#define pb					push_back

#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

clock_t T;

#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl

void GOAT()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

	//freopen("output.txt", "w	", stdout);

#else

#endif



}

int r, c;

char grid[1007][1007];

int mem[1007][1007];

bool valid(int i, int j)

{

	return (i < r && j < c);

}

const int m = 1e9 + 7;

int solve(int i, int j)

{

	if (i == r - 1 && j == c - 1)return 1;

	int& ret = mem[i][j];

	if (~ret)return ret;

	ret = 0;

	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;

	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;

	return ret%m;

}

int main() {

	//GOAT();

	

		clr(mem, -1);

		cin >> r >> c;

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

		{

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

			{

				cin>>grid[i][j];

			}

		}

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

}

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

using namespace std;

typedef long long ll;

char dp[1001][1001]; ll dpt[1001][1001];



ll solve(ll s,ll e,ll n,ll m)

{

    if(s==n || e==m)

        return 0;

    if(s==n-1 && e==m-1)

        return 1;

    if(dpt[s][e]!=-1)

        return dpt[s][e];

    if(dp[s][e]=='#')

        return 0;

    ll a=0;

    a=(solve(s+1,e,n,m)%1000000007+solve(s,e+1,n,m)%1000000007)%1000000007;

    dpt[s][e]=a;

    return a;

}



int main()

{

    ll n,m,i,j,k;

    cin>>n>>m;

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

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

            cin>>dp[i][j];

        }

    }

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

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

            dpt[i][j]=-1;

        }

    }

    ll s=solve(0,0,n,m);

    cout<<s<<endl;

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



using namespace std;

typedef long long ll;



const int N = 1007, M = 1e9 + 7;



char mat[N][N];





int memo[N][N];

int n, m;



int solve(int i, int j) {

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

    if(i >= n or j >= m) return 0;



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

    

    int & st = memo[i][j];

    if(st == -1) {

        st = solve(i+1, j) + solve(i, j+1);

        st %= M;

    }

    return st;

}



int main() {

    memset(memo, -1, sizeof memo);

    cin >> n >> m;



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

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

            cin >> mat[i][j];

        }

    }



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

}

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

using namespace std;

typedef long long ll;

char dp[1001][1001]; ll dpt[1001][1001];



ll solve(ll s,ll e,ll n,ll m)

{

    if(s==n || e==m)

        return 0;

    if(s==n-1 && e==m-1)

        return 1;

    if(dpt[s][e]!=-1)

        return dpt[s][e];

    if(dp[s][e]=='#')

        return 0;

    ll a=0;

    a=(solve(s+1,e,n,m)%1000000007+solve(s,e+1,n,m)%1000000007)%1000000007;

    dpt[s][e]=a;

    return a;

}



int main()

{

    ll n,m,i,j,k;

    cin>>n>>m;

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

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

            cin>>dp[i][j];

        }

    }

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

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

            dpt[i][j]=-1;

        }

    }

    ll s=solve(0,0,n,m);

    cout<<s<<endl;

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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

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

        return 0 ;

    if(dp[i][j]!=-1)

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


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

using namespace std;

int main()

{

    int n,m;

    cin>>n>>m;

    int ar[n+3][m+5];

    char ch;

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

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

              if(ch=='#')ar[i][j]=0;

              else ar[i][j]=1;

        }



    long long int dp[n+4][m+4];

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n and ar[i][0]!=0;i++)dp[i][0]=1;

    for(int i=0;i<m and ar[0][i]!=0;i++)dp[0][i]=1;



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

    {

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

        {

            if(ar[i][j]==0){

                dp[i][j]=0;

                continue;

            }

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

            dp[i][j]%=1000000007;

        }



    }





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

    return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

#include<unordered_set>	

using namespace std;

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

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

#define clr(v, d)		memset(v, d, sizeof(v))

#define rep(i, v)		for(int i=0;i<sz(v);++i)

#define lp(i, n)		for(int i=0;i<(int)(n);++i)

typedef long long         ll;

const double EPS = (1e-7);

int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

#define pb					push_back

#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

clock_t T;

#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl

void GOAT()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

	//freopen("output.txt", "w	", stdout);

#else

#endif



}

int r, c;

char grid[1007][1007];

int mem[1007][1007];

bool valid(int i, int j)

{

	return (i < r && j < c);

}

const int m = 1e9 + 7;

int solve(int i, int j)

{

	if (i == r - 1 && j == c - 1)return 1;

	int& ret = mem[i][j];

	if (~ret)return ret;

	ret = 0;

	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;

	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;

	return ret%m;

}

int main() {

	//GOAT();

	

		clr(mem, -1);

		cin >> r >> c;

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

		{

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

			{

				cin>>grid[i][j];

			}

		}

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

}

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

using namespace std;

int main()

{

    int n,m;

    cin>>n>>m;

    int ar[n+3][m+5];

    char ch;

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

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

              if(ch=='#')ar[i][j]=0;

              else ar[i][j]=1;

        }



    long long int dp[n+4][m+4];

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n and ar[i][0]!=0;i++)dp[i][0]=1;

    for(int i=0;i<m and ar[0][i]!=0;i++)dp[0][i]=1;



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

    {

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

        {

            if(ar[i][j]==0){

                dp[i][j]=0;

                continue;

            }

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

            dp[i][j]%=1000000007;

        }



    }





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

    return 0;

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



using namespace std;

typedef long long ll;



const int N = 1007, M = 1e9 + 7;



char mat[N][N];





int memo[N][N];

int n, m;



int solve(int i, int j) {

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

    if(i >= n or j >= m) return 0;



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

    

    int & st = memo[i][j];

    if(st == -1) {

        st = solve(i+1, j) + solve(i, j+1);

        st %= M;

    }

    return st;

}



int main() {

    memset(memo, -1, sizeof memo);

    cin >> n >> m;



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

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

            cin >> mat[i][j];

        }

    }



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

}

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

using namespace std;

int main()

{

    int n,m;

    cin>>n>>m;

    int ar[n+3][m+5];

    char ch;

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

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

              if(ch=='#')ar[i][j]=0;

              else ar[i][j]=1;

        }



    long long int dp[n+4][m+4];

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n and ar[i][0]!=0;i++)dp[i][0]=1;

    for(int i=0;i<m and ar[0][i]!=0;i++)dp[0][i]=1;



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

    {

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

        {

            if(ar[i][j]==0){

                dp[i][j]=0;

                continue;

            }

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

            dp[i][j]%=1000000007;

        }



    }





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

    return 0;

}
// Slower C++ solution:
/* Ajay Jadhav */

#include <bits/stdc++.h>

 

#define ll          long long

#define pb          push_back

#define pii         pair<int,int>

#define vi          vector<int>

#define vii         vector<pii>

#define mi          map<int,int>

#define mii         map<pii,int>

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

#define x           first

#define y           second

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

#define endl        '\n'

#define hell        1000000007

#define rep(i,a,b)  for(int i=a;i<b;i++)

using namespace std;

const int N=1001;

int h,w;

char g[N][N];

long long dp[N][N];

long long f(int i,int j)

{

    if(i==h-1 and j==w-1)

        return 1;

    if(i>=h or j>=w or g[i][j]=='#')

        return 0;

    if(dp[i][j]!=-1)

        return dp[i][j];

    long long fi=f(i+1,j)%hell;

    long long se=f(i,j+1)%hell;

    dp[i][j]=(fi+se)%hell;

    return dp[i][j];

}



void solve()

{

    cin>>h>>w;

    rep(i,0,h) rep(j,0,w) cin>>g[i][j];

    memset(dp,-1,sizeof dp);

    cout<<f(0,0);

}

 

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t=1;

    // cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}

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

using namespace std;

int main()

{

    int n,m;

    cin>>n>>m;

    int ar[n+3][m+5];

    char ch;

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

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

              if(ch=='#')ar[i][j]=0;

              else ar[i][j]=1;

        }



    long long int dp[n+4][m+4];

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n and ar[i][0]!=0;i++)dp[i][0]=1;

    for(int i=0;i<m and ar[0][i]!=0;i++)dp[0][i]=1;



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

    {

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

        {

            if(ar[i][j]==0){

                dp[i][j]=0;

                continue;

            }

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

            dp[i][j]%=1000000007;

        }



    }





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

    return 0;

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

using namespace std;

#define ll long long

#define ull unsigned long long

#define mst(a, b) memset((a), (b), sizeof(a))

#define mp(a, b) make_pair(a, b)

#define pi acos(-1)

#define pii pair<int, int>

#define pb push_back

const int INF = 0x3f3f3f3f;

const double eps = 1e-10;

const int maxn = 1e3 + 7;

const int maxm = 5e5 + 10;

const int mod = 1e9 + 7;

char s[maxn][maxn];

ll dp[maxn][maxn];

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int n, m;

    cin >> n >> m;

    mst(dp, 0);

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

    {

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

        {

            cin >> s[i][j];

            if (s[i][j] == '.')

                dp[i][j] = 1;

        }

    }

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

    {

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

        {

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

                continue;

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

                continue;

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

        }

    }

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

    return 0;

}

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

#define int long long

#define ll long long

#define ld long double

#define mod ((ll)1e9+7)

#define maxx ((ll)1e6+5)

#define pb push_back

#define ins insert

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

#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define test ll t; cin>>t; while(t--)

ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}

ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}

/*int sv[1000000]={0};

ll fact[1000007]={0};

void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}

void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<=maxx;i++){if(!sv[i]){for(int j=2*i;j<=maxx;j+=i)sv[j]=1;}}}//0 hai to prime

ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}

ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}*/

int d[1003][1003];

using namespace std;

signed main()

{

    int r,c,i,j;

    cin >> r >> c;

    char a[r][c];

    for(i=0 ; i<r ; i++)

    	for(j=0 ; j<c ; j++)

    		cin >> a[i][j];

    d[0][0] = 1;

    for(i=0 ; i<r ; i++)

    	for(j=0 ; j<c ; j++)

    	{

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

    			continue;

    		if(j>0) d[i][j] = (d[i][j] + d[i][j-1])%mod;

    		if(i>0) d[i][j] = (d[i][j] + d[i-1][j])%mod;

    	}

    cout << d[r-1][c-1] <<"\n";

    return 0;

}