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

using namespace std;

#define ll long long

#define ull unsigned long long

#define INF 1e18

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

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

typedef vector<int> vi;

typedef vector<ll> vll;

typedef pair<int,int> pi;



#define M_PI 3.14159265358979323846



char a[1020][1020];

const int oo = 1e9+10;

const int mod = 1e9+7;

ll memo[1020][1020];



ll gcd(ll a, ll b){return a==0 ? b : gcd(b%a, a);}



int add(int a, int b){

	return ((a+b) < mod ? a+b : a+b - mod);

}



int h,w;

ll dp(int i, int j){

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

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

	ll ans = 0;

	if(i+1 < h && a[i+1][j] != '#'){

		ans = dp(i+1,j);

	}

	if(j+1 < w &&  a[i][j+1] != '#'){

		ans = add(ans, dp(i,j+1));

	}

	return memo[i][j] = ans;

}



void solve(){

	cin>>h>>w;

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

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

			cin >> a[i][j];

		}

	}	

	memset(memo, -1, sizeof memo);

	cout << dp(0,0) << '\n';

}

int main(){   

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

	int t=1;

	while(t--){

		solve();

	}

}  
















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



using namespace std;

#define el '\n'

#define ll long long

typedef vector<int> vi;

const int N = 1007;

char arr[N][N];

int dp[N][N];



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int r, c;

    cin >> r >> c;

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

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

            cin >> arr[i][j];

        }

    }

    bool flag = 1;

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

        if(arr[i][0] == '#')

            flag = 0;

        if(flag)

            dp[i][0] = 1;

        else

            dp[i][0] = 0;

    }

    flag = 1;

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

        if(arr[0][j] == '#')

            flag = 0;

        if(flag)

            dp[0][j] = 1;

        else

            dp[0][j] = 0;

    }

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

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

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

                dp[i][j] = 0;

            else {

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

            }

        }

    }

    cout<<dp[ r - 1][c - 1]<<el;

    return 0;

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

#include <ext/pb_ds/assoc_container.hpp> // Common file

#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;

using namespace __gnu_pbds;

using ll = long long;

using _TYPE = int;

typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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



int h, w;

const int MAX = 1002;

const int MOD = (int) 1e9 + 7;

char grid[MAX][MAX];

int memo[MAX][MAX];



int dp(int r, int c) {

	if((r >= h) || (c >= w) || (grid[r][c] == '#'))

		return 0;

	if(r == h - 1 && c == w - 1)

		return 1;

	int &rt = memo[r][c];

	if(rt != -1)

		return (rt % MOD);

	rt = dp(r + 1, c) % MOD;

	rt += dp(r, c + 1) % MOD;

	return (rt % MOD);

}



int main() {

    IO;

    cin >> h >> w;

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

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

    		cin >> grid[i][j];

    }

    memset(memo, -1, sizeof memo);

    cout << dp(0, 0) % MOD;

    return 0;

}


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



using namespace std;

#define el '\n'

#define ll long long

typedef vector<int> vi;

const int N = 1007;

char arr[N][N];

int dp[N][N];



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int r, c;

    cin >> r >> c;

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

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

            cin >> arr[i][j];

        }

    }

    bool flag = 1;

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

        if(arr[i][0] == '#')

            flag = 0;

        if(flag)

            dp[i][0] = 1;

        else

            dp[i][0] = 0;

    }

    flag = 1;

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

        if(arr[0][j] == '#')

            flag = 0;

        if(flag)

            dp[0][j] = 1;

        else

            dp[0][j] = 0;

    }

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

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

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

                dp[i][j] = 0;

            else {

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

            }

        }

    }

    cout<<dp[ r - 1][c - 1]<<el;

    return 0;

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

using namespace std;

#define oo (long long)1e9

#define ll long long

#define setdp memset(dp,-1,sizeof(dp))

const ll mod = 1e9+7;

void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}

#define PI 3.14159265359

vector<pair<int,int>>v;

ll m,n;

char a[1009][1009];

ll dp[1009][1009];

ll solve(int i,int j)

{

   if(i<0||i>=n||j<0||j>=m||a[i][j]=='#')

        return 0;

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

        return 1;

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

        return dp[i][j];

    ll ans=0;

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

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

    return dp[i][j]=ans%mod;

}

int main()

{

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

    _IOS();

    memset(dp,-1,sizeof(dp));

    cin>>n>>m;

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

    {

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

        {

            cin>>a[i][j];

        }

    }

    cout<<solve(0,0);

}



//


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



using namespace std;

#define el '\n'

#define ll long long

typedef vector<int> vi;

const int N = 1007;

char arr[N][N];

int dp[N][N];



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int r, c;

    cin >> r >> c;

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

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

            cin >> arr[i][j];

        }

    }

    bool flag = 1;

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

        if(arr[i][0] == '#')

            flag = 0;

        if(flag)

            dp[i][0] = 1;

        else

            dp[i][0] = 0;

    }

    flag = 1;

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

        if(arr[0][j] == '#')

            flag = 0;

        if(flag)

            dp[0][j] = 1;

        else

            dp[0][j] = 0;

    }

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

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

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

                dp[i][j] = 0;

            else {

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

            }

        }

    }

    cout<<dp[ r - 1][c - 1]<<el;

    return 0;

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

 

using namespace std;

 

#define sf(n) scanf("%d", &n)

#define pd(n) printf("%.12lf", n)

#define pf(n) printf("%d", n)

#define p() printf("\n")

#define ps() printf(" ")

#define ll long long

#define ull unsigned long long

#define MAX 1e9

const int mod = 1000 * 1000 * 1000 + 7;

#define ex 1e18

#define dbl 2e09

#define qu(q) queue<int> q

#define pqu(q) priority_queue<int> q

#define len(s) s.length()

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

#define pb(x) push_back(x)

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

#define rall(x) x.rbegin(), x.rend()

#define F first

#define S second

#define clr(x) x.clear()

#define LOG(x) std::cout << x << std::endl;

 

const int INF = 0x3f3f3f3f;

const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

const double PI = 3.14159265359;

 

int dx[6] = {-1,-1,0,0,1,1};

int dy[6] = {-1,0,-1,1,0,1};



int w,h;

char a[1005][1005];

int dp[1005][1005];



int solve(int i,int j){

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

        return 1;

    if(i>=h or j>=w)

        return 0;

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

    if(~ret)return ret;

    ret=0;

    if((i+1)<h and a[i+1][j]!='#'){

        ret+=solve(i+1,j)%mod;

    }

    if((j+1)<w and a[i][j+1]!='#'){

        ret+=solve(i,j+1)%mod;

    }

    return ret%mod;

}





int main(){

    cin>>h>>w;

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

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

            cin>>a[i][j];

        }

    }

    memset(dp,-1,sizeof dp);

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



    return 0;

}

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

using namespace std;

#define ll long long int

ll mod  = 1000000000+7;

char g[1000+5][1005];

ll dp[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 >> g[i][j];



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

      if (g[i][0]=='#') break;

    dp[i][0] = 1;

}

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

    if(g[0][j]=='#') break;

     dp[0][j] = 1;

}



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

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

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

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

        //cout << i<<" "<<j <<" "<< dp[i][j] <<" ";

    }

    //cout << endl;

}

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

return 0;

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

#include<bits/stdc++.h>

#include<iostream>

#include<algorithm>

#include<iomanip>

#include<string>

#include<cmath>

#include<vector>

#include<set>

#include<queue>

#include<stack>

#include<fstream>

#include<map>

#include<bitset>

#include<unordered_map>

#include<cstring>

#include<cctype>

using namespace std;

#define  ll long long

#define  ull unsigned long long

#define  ul unsigned long

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

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

#define pb(s) push_back(s);

#define format(n) fixed<<setprecision(n)

#define finl "\n"

#define Mohammed_Atef_Hassan fast();

#define mod 1000000007

#define INF LLONG_MAX

#define PI acos(-1)

#define clr(dp,n) memset(dp,n,sizeof dp)

#define ex(n) return cout<<n<<finl,0;

int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };

ll fix_mod(ll x, ll y)

{

	return (y + x % y) % y;

}

void fast() {

	std::ios_base::sync_with_stdio(false);

	cin.tie(nullptr); cout.tie(nullptr);

}

char g[1001][1001]; int n, m;

ll mem[1001][1001];

ll solve(int x, int y)

{

	if (x == n || y == m||g[x][y]=='#')return 0;

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

	ll& ret = mem[x][y];

	if(~ret)return ret;

	 ret = solve(x + 1, y) + solve(x, y + 1);

	 return ret %= 1000000007;

}

int main()

{

	Mohammed_Atef_Hassan

		clr(mem, -1);

		cin >> n >> m;

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

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

			cin >> g[i][j];

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

}

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

using namespace std;

#define ll long long int

ll mod  = 1000000000+7;

char g[1000+5][1005];

ll dp[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 >> g[i][j];



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

      if (g[i][0]=='#') break;

    dp[i][0] = 1;

}

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

    if(g[0][j]=='#') break;

     dp[0][j] = 1;

}



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

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

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

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

        //cout << i<<" "<<j <<" "<< dp[i][j] <<" ";

    }

    //cout << endl;

}

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

return 0;

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

using namespace std;

#define ll long long

#define ull unsigned long long

#define INF 1e18

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

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

typedef vector<int> vi;

typedef vector<ll> vll;

typedef pair<int,int> pi;



#define M_PI 3.14159265358979323846



char a[1020][1020];

const int oo = 1e9+10;

const int mod = 1e9+7;

ll memo[1020][1020];



ll gcd(ll a, ll b){return a==0 ? b : gcd(b%a, a);}



int add(int a, int b){

	return ((a+b) < mod ? a+b : a+b - mod);

}



int h,w;

ll dp(int i, int j){

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

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

	ll ans = 0;

	if(i+1 < h && a[i+1][j] != '#'){

		ans = dp(i+1,j);

	}

	if(j+1 < w &&  a[i][j+1] != '#'){

		ans = add(ans, dp(i,j+1));

	}

	return memo[i][j] = ans;

}



void solve(){

	cin>>h>>w;

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

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

			cin >> a[i][j];

		}

	}	

	memset(memo, -1, sizeof memo);

	cout << dp(0,0) << '\n';

}

int main(){   

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

	int t=1;

	while(t--){

		solve();

	}

}  
















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

using namespace std;

#define ll long long int

ll mod  = 1000000000+7;

char g[1000+5][1005];

ll dp[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 >> g[i][j];



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

      if (g[i][0]=='#') break;

    dp[i][0] = 1;

}

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

    if(g[0][j]=='#') break;

     dp[0][j] = 1;

}



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

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

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

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

        //cout << i<<" "<<j <<" "<< dp[i][j] <<" ";

    }

    //cout << endl;

}

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

return 0;

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

#include <ext/pb_ds/assoc_container.hpp> // Common file

#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;

using namespace __gnu_pbds;

using ll = long long;

using _TYPE = int;

typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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



int h, w;

const int MAX = 1002;

const int MOD = (int) 1e9 + 7;

char grid[MAX][MAX];

int memo[MAX][MAX];



int dp(int r, int c) {

	if((r >= h) || (c >= w) || (grid[r][c] == '#'))

		return 0;

	if(r == h - 1 && c == w - 1)

		return 1;

	int &rt = memo[r][c];

	if(rt != -1)

		return (rt % MOD);

	rt = dp(r + 1, c) % MOD;

	rt += dp(r, c + 1) % MOD;

	return (rt % MOD);

}



int main() {

    IO;

    cin >> h >> w;

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

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

    		cin >> grid[i][j];

    }

    memset(memo, -1, sizeof memo);

    cout << dp(0, 0) % MOD;

    return 0;

}


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

using namespace std;

#define ll long long int

ll mod  = 1000000000+7;

char g[1000+5][1005];

ll dp[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 >> g[i][j];



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

      if (g[i][0]=='#') break;

    dp[i][0] = 1;

}

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

    if(g[0][j]=='#') break;

     dp[0][j] = 1;

}



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

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

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

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

        //cout << i<<" "<<j <<" "<< dp[i][j] <<" ";

    }

    //cout << endl;

}

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

return 0;

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

using namespace std;

#define oo (long long)1e9

#define ll long long

#define setdp memset(dp,-1,sizeof(dp))

const ll mod = 1e9+7;

void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}

#define PI 3.14159265359

vector<pair<int,int>>v;

ll m,n;

char a[1009][1009];

ll dp[1009][1009];

ll solve(int i,int j)

{

   if(i<0||i>=n||j<0||j>=m||a[i][j]=='#')

        return 0;

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

        return 1;

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

        return dp[i][j];

    ll ans=0;

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

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

    return dp[i][j]=ans%mod;

}

int main()

{

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

    _IOS();

    memset(dp,-1,sizeof(dp));

    cin>>n>>m;

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

    {

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

        {

            cin>>a[i][j];

        }

    }

    cout<<solve(0,0);

}



//


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

using namespace std;

#define ll long long int

ll mod  = 1000000000+7;

char g[1000+5][1005];

ll dp[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 >> g[i][j];



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

      if (g[i][0]=='#') break;

    dp[i][0] = 1;

}

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

    if(g[0][j]=='#') break;

     dp[0][j] = 1;

}



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

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

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

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

        //cout << i<<" "<<j <<" "<< dp[i][j] <<" ";

    }

    //cout << endl;

}

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

return 0;

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

#include<bits/stdc++.h>

#include<iostream>

#include<algorithm>

#include<iomanip>

#include<string>

#include<cmath>

#include<vector>

#include<set>

#include<queue>

#include<stack>

#include<fstream>

#include<map>

#include<bitset>

#include<unordered_map>

#include<cstring>

#include<cctype>

using namespace std;

#define  ll long long

#define  ull unsigned long long

#define  ul unsigned long

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

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

#define pb(s) push_back(s);

#define format(n) fixed<<setprecision(n)

#define finl "\n"

#define Mohammed_Atef_Hassan fast();

#define mod 1000000007

#define INF LLONG_MAX

#define PI acos(-1)

#define clr(dp,n) memset(dp,n,sizeof dp)

#define ex(n) return cout<<n<<finl,0;

int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };

ll fix_mod(ll x, ll y)

{

	return (y + x % y) % y;

}

void fast() {

	std::ios_base::sync_with_stdio(false);

	cin.tie(nullptr); cout.tie(nullptr);

}

char g[1001][1001]; int n, m;

ll mem[1001][1001];

ll solve(int x, int y)

{

	if (x == n || y == m||g[x][y]=='#')return 0;

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

	ll& ret = mem[x][y];

	if(~ret)return ret;

	 ret = solve(x + 1, y) + solve(x, y + 1);

	 return ret %= 1000000007;

}

int main()

{

	Mohammed_Atef_Hassan

		clr(mem, -1);

		cin >> n >> m;

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

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

			cin >> g[i][j];

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

}

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

#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)

#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)

#define pb push_back

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

#define memset(c, value) memset(c, (int)value, sizeof(c))

using namespace std;

typedef long long ll;

const int oo = 1e9+5;

const ll MOD =1e9+7;

const double pi = acos(-1);

void fast(){

    ios_base :: sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int n, m;

bool valid (int r,int c){

    return (r < n && r >= 0 && c >= 0 && c < m);

}



int row[] = {0 , 1 , 0, -1};

int column[] = {1 , 0, -1, 0};



char a[1001][1001];

int dp[1001][1001];



int path(int r, int c){

    if(!valid(r, c) || a[r][c] == '#')

        return 0;

    if(r == n-1 && c == m-1)

        return 1;



    int &ret = dp[r][c];

    if(ret != -1) return ret;



    ret = 0;



    return ret = (ret + path(r+1, c)%MOD + path(r, c+1)%MOD)%MOD;

}



int main()

{

    fast();



    cin>>n>>m;

    f(i, 0, n)

    f(j, 0, m)

        cin>>a[i][j];

    memset(dp, -1);

    cout<<path(0,0)<<'\n';



    return 0;

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

using namespace std;

#define ll long long

#define ull unsigned long long

#define INF 1e18

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

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

typedef vector<int> vi;

typedef vector<ll> vll;

typedef pair<int,int> pi;



#define M_PI 3.14159265358979323846



char a[1020][1020];

const int oo = 1e9+10;

const int mod = 1e9+7;

ll memo[1020][1020];



ll gcd(ll a, ll b){return a==0 ? b : gcd(b%a, a);}



int add(int a, int b){

	return ((a+b) < mod ? a+b : a+b - mod);

}



int h,w;

ll dp(int i, int j){

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

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

	ll ans = 0;

	if(i+1 < h && a[i+1][j] != '#'){

		ans = dp(i+1,j);

	}

	if(j+1 < w &&  a[i][j+1] != '#'){

		ans = add(ans, dp(i,j+1));

	}

	return memo[i][j] = ans;

}



void solve(){

	cin>>h>>w;

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

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

			cin >> a[i][j];

		}

	}	

	memset(memo, -1, sizeof memo);

	cout << dp(0,0) << '\n';

}

int main(){   

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

	int t=1;

	while(t--){

		solve();

	}

}  
















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

#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)

#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)

#define pb push_back

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

#define memset(c, value) memset(c, (int)value, sizeof(c))

using namespace std;

typedef long long ll;

const int oo = 1e9+5;

const ll MOD =1e9+7;

const double pi = acos(-1);

void fast(){

    ios_base :: sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int n, m;

bool valid (int r,int c){

    return (r < n && r >= 0 && c >= 0 && c < m);

}



int row[] = {0 , 1 , 0, -1};

int column[] = {1 , 0, -1, 0};



char a[1001][1001];

int dp[1001][1001];



int path(int r, int c){

    if(!valid(r, c) || a[r][c] == '#')

        return 0;

    if(r == n-1 && c == m-1)

        return 1;



    int &ret = dp[r][c];

    if(ret != -1) return ret;



    ret = 0;



    return ret = (ret + path(r+1, c)%MOD + path(r, c+1)%MOD)%MOD;

}



int main()

{

    fast();



    cin>>n>>m;

    f(i, 0, n)

    f(j, 0, m)

        cin>>a[i][j];

    memset(dp, -1);

    cout<<path(0,0)<<'\n';



    return 0;

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

using namespace std;

#define oo (long long)1e9

#define ll long long

#define setdp memset(dp,-1,sizeof(dp))

const ll mod = 1e9+7;

void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}

#define PI 3.14159265359

vector<pair<int,int>>v;

ll m,n;

char a[1009][1009];

ll dp[1009][1009];

ll solve(int i,int j)

{

   if(i<0||i>=n||j<0||j>=m||a[i][j]=='#')

        return 0;

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

        return 1;

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

        return dp[i][j];

    ll ans=0;

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

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

    return dp[i][j]=ans%mod;

}

int main()

{

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

    _IOS();

    memset(dp,-1,sizeof(dp));

    cin>>n>>m;

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

    {

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

        {

            cin>>a[i][j];

        }

    }

    cout<<solve(0,0);

}



//


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

#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)

#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)

#define pb push_back

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

#define memset(c, value) memset(c, (int)value, sizeof(c))

using namespace std;

typedef long long ll;

const int oo = 1e9+5;

const ll MOD =1e9+7;

const double pi = acos(-1);

void fast(){

    ios_base :: sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int n, m;

bool valid (int r,int c){

    return (r < n && r >= 0 && c >= 0 && c < m);

}



int row[] = {0 , 1 , 0, -1};

int column[] = {1 , 0, -1, 0};



char a[1001][1001];

int dp[1001][1001];



int path(int r, int c){

    if(!valid(r, c) || a[r][c] == '#')

        return 0;

    if(r == n-1 && c == m-1)

        return 1;



    int &ret = dp[r][c];

    if(ret != -1) return ret;



    ret = 0;



    return ret = (ret + path(r+1, c)%MOD + path(r, c+1)%MOD)%MOD;

}



int main()

{

    fast();



    cin>>n>>m;

    f(i, 0, n)

    f(j, 0, m)

        cin>>a[i][j];

    memset(dp, -1);

    cout<<path(0,0)<<'\n';



    return 0;

}