stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
/*

** author:mahmoud magdy

*/

#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define endl "\n"



inline int D()

{

    int m ;

    cin>>m;

    return m ;

}

inline ll lD()

{

    ll m ;

    cin>>m;

    return m ;

}

inline double dD()

{

    double m;

    cin>>m;

    return m;

}

void fast()

{

    ios_base :: sync_with_stdio( 0 ) ;

    cin.tie( 0 ) ;

    cout.tie( 0 ) ;

}

int n , m ,Mod=1e9+7;

char s[1005][1005];

ll dp[1005][1005];

ll solve(int i , int j){

if(i>=n||j>=m||s[i][j]=='#')

    return 0;

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

    return 1;

}

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

    return dp[i][j];

return dp[i][j]=((solve(i,j+1)%Mod)+(solve(i+1,j)%Mod))%Mod;



}

int main()

{

    fast();

   n=D(),m=D();

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

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

        cin>>s[i][j];

      }

   }

   memset(dp,-1,sizeof dp);

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



}


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

using namespace std;

#define ll long long

#define endl "\n"

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

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

#define NN 8010000

#define TC int t;cin>>t;for(int T=1;T<=t;T++)

#define mod 1000000007

#define PI acos(-1)

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

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

#define mem(a,n) memset(a,n,sizeof(a))

void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

//cout<<fixed<<setprecision(20);

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

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

bool isprime(ll n) {

	for (ll i = 2; i * i <= n; i++) {

		if (n % i == 0)return 0;

	}

	return (n!=1);

}

ll gcd(ll x, ll y)

{

	return (y == 0 ? x : gcd(y, x % y));

}

ll lcm(ll a, ll b) {

	return a / gcd(a, b) * b;

}

ll rem(int x, int N){

	return (x % N + N) % N;

}

int n,m;

ll dp[1007][1007];

char arr[1007][1007];



int main()

{

	//cout<<fixed<<setprecision(6);

	AIA();

	int n,m;

	cin>>n>>m;

	dp[0][0] = 1;

	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>arr[i][j];

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

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

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

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

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

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

	}	

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

	return 0;

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

#define ll long long

#define Test int t;cin>>t;while(t--)

#define PI acos(-1)

#define endl "\n"

#define fx(x) fixed<<setprecision(x)

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

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

#define allr(v) (v).rbegin(),(v).rend()

#define mem(a,n) memset((a),n,sizeof (a))

const double eps=1e-9;

const int mod=1e9+7;

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

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

ll gcd(ll x,ll y) {return(!y)?x:gcd(y,x%y);}

ll lcm(ll x,ll y) {return((x/gcd(x,y))*y);}

using namespace std;

void fast(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

}

int dp[1001][1001];

int n,m;

char a[1001][1001];

bool valid(int i,int j){

    return (i>=0&&i<n&&j>=0&&j<m&&a[i][j]!='#');

}

int solve(int i,int j){

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

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

    if(~ret)return ret;

    ret=0;

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

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

    return ret%mod;

}

int main()

{

    mem(dp,-1);

    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);

    return 0;

}


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

using namespace std;

#define ll long long

#define endl "\n"

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

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

#define NN 8010000

#define TC int t;cin>>t;for(int T=1;T<=t;T++)

#define mod 1000000007

#define PI acos(-1)

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

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

#define mem(a,n) memset(a,n,sizeof(a))

void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

//cout<<fixed<<setprecision(20);

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

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

bool isprime(ll n) {

	for (ll i = 2; i * i <= n; i++) {

		if (n % i == 0)return 0;

	}

	return (n!=1);

}

ll gcd(ll x, ll y)

{

	return (y == 0 ? x : gcd(y, x % y));

}

ll lcm(ll a, ll b) {

	return a / gcd(a, b) * b;

}

ll rem(int x, int N){

	return (x % N + N) % N;

}

int n,m;

ll dp[1007][1007];

char arr[1007][1007];



int main()

{

	//cout<<fixed<<setprecision(6);

	AIA();

	int n,m;

	cin>>n>>m;

	dp[0][0] = 1;

	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>arr[i][j];

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

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

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

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

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

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

	}	

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

	return 0;

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

#define inf 1000000007

#define N 1007

using namespace std;



int h, w;

char path[N][N];

long long mem[N][N];



long long dp(int i, int j)

{

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

        return 1;

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

        return mem[i][j];

    long long ans = 0;

    if((j + 1) != w && path[i][j + 1] != '#')

        ans = ((ans % inf) + (dp(i, j + 1) % inf)) % inf;

    if((i + 1) != h && path[i + 1][j] != '#')

        ans = ((ans % inf) + (dp(i + 1, j) % inf)) % inf;

    mem[i][j] = ans;

    return ans;

}



int main()

{

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

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

    cin >> h >> w;

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

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

            cin >> path[i][j];

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

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

    return 0;

}

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

using namespace std;

#define ll long long

#define endl "\n"

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

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

#define NN 8010000

#define TC int t;cin>>t;for(int T=1;T<=t;T++)

#define mod 1000000007

#define PI acos(-1)

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

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

#define mem(a,n) memset(a,n,sizeof(a))

void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

//cout<<fixed<<setprecision(20);

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

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

bool isprime(ll n) {

	for (ll i = 2; i * i <= n; i++) {

		if (n % i == 0)return 0;

	}

	return (n!=1);

}

ll gcd(ll x, ll y)

{

	return (y == 0 ? x : gcd(y, x % y));

}

ll lcm(ll a, ll b) {

	return a / gcd(a, b) * b;

}

ll rem(int x, int N){

	return (x % N + N) % N;

}

int n,m;

ll dp[1007][1007];

char arr[1007][1007];



int main()

{

	//cout<<fixed<<setprecision(6);

	AIA();

	int n,m;

	cin>>n>>m;

	dp[0][0] = 1;

	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>arr[i][j];

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

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

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

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

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

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

	}	

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

	return 0;

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

using namespace std;

const int mod = 7 + 1e9;

int h, w, dp[1000][1000]={};

bool grid[1000][1000];

int f(int i = 0 , int j = 0 )

{

    if( i == h || j == w || grid[i][j] )

        return 0;

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

        return 1;

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

    if( d != -1 ) return d;

    return d = (f(i+1,j)%mod + f(i,j+1)%mod)%mod;

}

int main()

{

    memset(dp,-1,sizeof dp);

    cin >> h >> w;

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

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

        {

            char t; cin >> t;

            grid[i][j] = t == '.' ? 0 : 1 ;

        }

    cout << f();

    return 0;

}

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

using namespace std;

typedef long long ll;

const int N = 1e5, m = 1e9 + 7;

int h, w, dg[1000][1000];

char g[1000][1000];

int main()

{

    cin >> h >> w;

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

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

            cin >> g[i][j];

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

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

            break;

        dg[0][i] = 1;

    }

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

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

            break;

        dg[i][0] = 1;

    }

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

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

            dg[i][j] = (dg[i-1][j] + dg[i][j-1])%m;

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

                dg[i][j] = 0;

        }

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

    return 0;

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

using namespace std;

const int mod = 7 + 1e9;

int h, w, dp[1000][1000]={};

bool grid[1000][1000];

int f(int i = 0 , int j = 0 )

{

    if( i == h || j == w || grid[i][j] )

        return 0;

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

        return 1;

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

    if( d != -1 ) return d;

    return d = (f(i+1,j)%mod + f(i,j+1)%mod)%mod;

}

int main()

{

    memset(dp,-1,sizeof dp);

    cin >> h >> w;

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

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

        {

            char t; cin >> t;

            grid[i][j] = t == '.' ? 0 : 1 ;

        }

    cout << f();

    return 0;

}

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

using namespace std;

typedef long long ll;

const int N = 1e5, m = 1e9 + 7;

int h, w, dg[1000][1000];

char g[1000][1000];

int main()

{

    cin >> h >> w;

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

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

            cin >> g[i][j];

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

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

            break;

        dg[0][i] = 1;

    }

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

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

            break;

        dg[i][0] = 1;

    }

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

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

            dg[i][j] = (dg[i-1][j] + dg[i][j-1]) < m ? (dg[i-1][j] + dg[i][j-1]) : (dg[i-1][j] + dg[i][j-1] - m);

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

                dg[i][j] = 0;

        }

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

    return 0;

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

 

using namespace std;

 

#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);

#define sp           <<" "<<

#define ll           long long

#define ld           long double

#define For(i,k,n)   for(ll i=k;i<n;i++)

#define Ford(i,n)    for(ll i=n-1;i>=0;i--)

#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)

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

#define P(x,y)       pair < x,y >

#define V(x)         vector < x >

#define fi           first

#define se           second

#define pb           push_back

#define mp           make_pair

#define PI           3.14159265358979323846264338327950288419716939937510

 

const ll mod=1e9+7,N=1e6+5;



int h,w;

ll dp[1005][1005];

char grid[1005][1005]={};



ll no_of_paths(int r, int c)

{

    if(r>h || c>w)

        return 0;



    if(dp[r][c]!=-1)  return dp[r][c];



    if(grid[r][c]=='#')    return dp[r][c] = 0;



    else return dp[r][c] = ( (no_of_paths(r+1,c)%mod + no_of_paths(r,c+1)%mod) )%mod;

}



int main() 

{ 

    BOOST



    cin>>h>>w;



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



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

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

            cin>>grid[i][j];



    dp[h][w] = 1;



    cout<<no_of_paths(1,1)<<"\n";

    

    return 0; 

} 

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

 

using namespace std;

 

#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);

#define sp           <<" "<<

#define ll           long long

#define ld           long double

#define For(i,k,n)   for(ll i=k;i<n;i++)

#define Ford(i,n)    for(ll i=n-1;i>=0;i--)

#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)

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

#define P(x,y)       pair < x,y >

#define V(x)         vector < x >

#define fi           first

#define se           second

#define pb           push_back

#define mp           make_pair

#define PI           3.14159265358979323846264338327950288419716939937510

 

const ll mod=1e9+7,N=1e6+5;



int h,w;

ll dp[1005][1005]={};

char grid[1005][1005]={};



int main() 

{ 

    BOOST



    cin>>h>>w;



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



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

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

            cin>>grid[i][j];



    dp[h][w] = 1;



    for(int i=h; i>0; i--)

    {

        for(int j=w; j>0; j--)

        {

            if(i==h && j==w)

                continue;



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

                dp[i][j] = 0;



            else

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

        }

    }

    

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

    

    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.108584142518677x):
#include <bits/stdc++.h>

using namespace std;

const int mod=1e9+7;

char grid[1001][1001];

map < int , map < int , int > > dp;

int main() {

	int n,m;

	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=0;i<n;i++) {

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

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

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

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

		}

	}

	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.382772158011852x):
#include <bits/stdc++.h>

using namespace std;

const int mod=1e9+7;

char grid[1001][1001];

map < int , map < int , int > > dp;

int main() {

	int n,m;

	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=0;i<n;i++) {

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

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

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

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

		}

	}

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

	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.137753931983277x):
#include<bits/stdc++.h>

using namespace std;

#define int long long

int n;

int dp[1001][1001];

char arr[1001][1001];

int flag[1001][1001];

int h,w;

int m=1e9+7;

signed  main()

{

    cin>>h>>w;

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

    {

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

        {

            cin>>arr[i][j];

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

            {

            flag[i][j]=-1;

            dp[i][j]=0;

            }

 

        }

 

    }

 

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

    {

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

        {

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

            {

                flag[j][1]=-1;

                dp[j][1]=0;

            }

        }

    }

    

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

    {

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

        {

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

            {

                flag[1][j]=-1;

                dp[1][j]=0;

            }

        }

 

    }

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

    {

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

        {

 

            if(i==1||j==1)

            {

              if(flag[i][j]==0)

              dp[i][j]=1;

              else dp[i][j]=0;

 

            }

 

            else if(flag[i][j]!=-1)

            {

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

                

            }

            else if(flag[i][j]==-1)

            dp[i][j]=0;

            

        

        

        

        }

    }

 /*   for(int i=1;i<=h;i++)

    {

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

        {

            cout<<dp[i][j];

        }

        cout<<"\n";    

        }

        */

        cout<<dp[h][w];

}
// 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.441993516306825x):
#include<bits/stdc++.h>

using namespace std;

#define int long long

int n;

int dp[1001][1001];

char arr[1001][1001];

int flag[1001][1001];

int h,w;

int m=1e9+7;

signed  main()

{

    cin>>h>>w;

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

    {

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

        {

            cin>>arr[i][j];

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

            {

            flag[i][j]=-1;

            dp[i][j]=0;

            }

 

        }

 

    }

 

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

    {

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

        {

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

            {

                flag[j][1]=-1;

                dp[j][1]=0;

            }

        }

    }

    

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

    {

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

        {

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

            {

                flag[1][j]=-1;

                dp[1][j]=0;

            }

        }

 

    }

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

    {

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

        {

 

            if(i==1||j==1)

            {

              if(flag[i][j]==0)

              dp[i][j]=1;

              else dp[i][j]=0;

 

            }

 

            else if(flag[i][j]!=-1)

            {

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

                

            }

            else if(flag[i][j]==-1)

            dp[i][j]=0;

            

        

        

        

        }

    }

 /*   for(int i=1;i<=h;i++)

    {

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

        {

            cout<<dp[i][j];

        }

        cout<<"\n";    

        }

        */

        cout<<dp[h][w];

}