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

#define ll long long

#define ull unsigned long long

#define IO ios::sync_with_stdio(false), cin.tie(0)

#define endl '\n'

#define main() int main()

#define ff1(i,n) for(int i=1;i<=n;++i)

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

#define pi acos(-1.0)

#define ms(a, x) memset(a, x, sizeof(a))

#define lowbit(x) ((x)&(-(x)))

#define pb push_back

#define binarycount __builtin_popcount(x)

#define tr t[root]

#define lson t[root << 1]

#define rson t[root << 1 | 1]

#define fir first

#define sec second

#define debug(x) cout<<x<<'\n'

#define sa(a) scanf("%d", &a)

#define sab(a, b) scanf("%d%d", &a, &b)

#define pa(a) printf("%d",a)

#define pab(a,b) printf("%d%d",a,b)

#define pii pair<string,int>

using namespace std;

#define maxn 1005

const int inf = 0x3f3f3f3f;

const int mod = 1e9+7;

const double eps = 1e-8;

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

ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}

int max(int x,int y){if(x>y) return x;return y;}

ll powmod(ll a,ll b){

    ull ans = 1, pow = a%mod;

    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }

    return ans%mod;

}



int n,m;

char mp[maxn][maxn];

int dp[maxn][maxn];

main()

{

	IO;

	cin>>n>>m;

	ms(dp,0);

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

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

		 cin>>mp[i][j];

		 

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

		if(mp[i][1]=='#')break;

		dp[i][1]=1;

	}	 

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

		if(mp[1][i]=='#')break;

		dp[1][i]=1;

	}

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

	{

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

		{

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

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

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

			}

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

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

			}

		}

	}



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

	

}


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

using namespace std;

#define  ll long long int

#define mx 1005

ll b[mx],c[mx];

ll dp[mx][mx];

ll dp1[mx][mx];

ll a[mx][mx];

ll n;



int main()

{

    ll n,m;

    cin>>n>>m;

    char a[n+6][m+6];

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

        for(int j=1;j<=m;j++) cin>>a[i][j];

    }

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

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

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

                dp[i][j]=0;

                continue;

            }

            if(i==1 && j==1) dp[i][j]=1;

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

                if(i==1){

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

                }

                else{

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

                }

            }

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



            dp[i][j]%=1000000007;

        }

    }

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

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

using namespace std;

#define  ll long long int

#define mx 1005

ll b[mx],c[mx];

ll dp[mx][mx];

ll dp1[mx][mx];

ll a[mx][mx];

ll n;



int main()

{

    ll n,m;

    cin>>n>>m;

    char a[n+6][m+6];

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

        for(int j=1;j<=m;j++) cin>>a[i][j];

    }

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

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

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

                dp[i][j]=0;

                continue;

            }

            if(i==1 && j==1) dp[i][j]=1;

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

                if(i==1){

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

                }

                else{

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

                }

            }

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



            dp[i][j]%=1000000007;

        }

    }

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

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

#include <ext/numeric>



using namespace std;

using namespace __gnu_cxx;



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

#define endl "\n"

#define pb push_back

#define F first

#define S second

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

#define isOdd(n)    (n&1)

#define LLMAX LLONG_MAX

#define LLMIN LLONG_MIN

#define IMN INT_MIN

#define IMX INT_MAX

#define pow(n, m) power((ll)n, (ll)m)

#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)

#define mem(x, val)    memset(x, val, sizeof(x)) //be careful

#define MOD 1000000007



typedef long long ll;

typedef long double ld;

typedef double dd;

typedef string str;

typedef pair<int, int> pii;



const int N = 1000;

ll dp[N][N];

char arr[N][N];

int n, m;

ll solve(int r = 0, int c = 0){

    if(r==n || c==m) return 0;



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



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



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



    if(~ret) return ret;



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

}

int main()

{

    THINK_TWICE_CODE_ONCE

    //freopen("test cases\\.txt", "r", stdin) ;

    cin>>n>>m;

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

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

            cin>>arr[i][j];

    mem(dp, -1);

    cout<<solve();

	return 0;

}


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

using namespace std;

#define  ll long long int

#define mx 1005

ll b[mx],c[mx];

ll dp[mx][mx];

ll dp1[mx][mx];

ll a[mx][mx];

ll n;



int main()

{

    ll n,m;

    cin>>n>>m;

    char a[n+6][m+6];

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

        for(int j=1;j<=m;j++) cin>>a[i][j];

    }

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

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

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

                dp[i][j]=0;

                continue;

            }

            if(i==1 && j==1) dp[i][j]=1;

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

                if(i==1){

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

                }

                else{

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

                }

            }

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



            dp[i][j]%=1000000007;

        }

    }

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

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

#define pi 3.14159

using namespace std;

typedef long long LL;

const LL MOD = 1e9 + 7;

const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;

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

long long n,m,dp[1007][1007];

char array1[1007][1007];

bool isvalid(int i,int j){

    return i>=0&&i<=n&&j>=0&&j<=m;

}

long long solve(int i,int j){

   if(i>n)

        return 0;

    if(j>m)

        return 0;

    if(array1[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+1,j)%MOD)+(solve(i,j+1)%MOD))%MOD;

}

int main()

{

int i,j;

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

cin>>n>>m;

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

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

        cin>>array1[i][j];

    }

}

printf("%lld",solve(0,0));











    return 0;

}


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

using namespace std;

#define  ll long long int

#define mx 1005

ll b[mx],c[mx];

ll dp[mx][mx];

ll dp1[mx][mx];

ll a[mx][mx];

ll n;



int main()

{

    ll n,m;

    cin>>n>>m;

    char a[n+6][m+6];

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

        for(int j=1;j<=m;j++) cin>>a[i][j];

    }

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

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

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

                dp[i][j]=0;

                continue;

            }

            if(i==1 && j==1) dp[i][j]=1;

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

                if(i==1){

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

                }

                else{

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

                }

            }

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



            dp[i][j]%=1000000007;

        }

    }

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

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

using namespace std;

#define  ll long long int

#define mx 1005

ll b[mx],c[mx];

ll dp[mx][mx];

ll dp1[mx][mx];

ll a[mx][mx];

ll n;



int main()

{

    ll n,m;

    cin>>n>>m;

    char a[n+6][m+6];

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

        for(int j=1;j<=m;j++) cin>>a[i][j];

    }

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

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

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

                dp[i][j]=0;

                continue;

            }

            if(i==1 && j==1) dp[i][j]=1;

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

                if(i==1){

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

                }

                else{

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

                }

            }

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



            dp[i][j]%=1000000007;

        }

    }

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

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

using namespace std;

#define  ll long long int

#define mx 1005

ll b[mx],c[mx];

ll dp[mx][mx];

ll dp1[mx][mx];

ll a[mx][mx];

ll n;



int main()

{

    ll n,m;

    cin>>n>>m;

    char a[n+6][m+6];

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

        for(int j=1;j<=m;j++) cin>>a[i][j];

    }

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

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

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

                dp[i][j]=0;

                continue;

            }

            if(i==1 && j==1) dp[i][j]=1;

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

                if(i==1){

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

                }

                else{

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

                }

            }

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



            dp[i][j]%=1000000007;

        }

    }

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

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

using namespace std;

#define  ll long long int

#define mx 1005

ll b[mx],c[mx];

ll dp[mx][mx];

ll dp1[mx][mx];

ll a[mx][mx];

ll n;



int main()

{

    ll n,m;

    cin>>n>>m;

    char a[n+6][m+6];

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

        for(int j=1;j<=m;j++) cin>>a[i][j];

    }

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

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

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

                dp[i][j]=0;

                continue;

            }

            if(i==1 && j==1) dp[i][j]=1;

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

                if(i==1){

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

                }

                else{

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

                }

            }

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



            dp[i][j]%=1000000007;

        }

    }

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

}
// 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.42095788930102x):
#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>

#include <ext/numeric>



using namespace std;

using namespace __gnu_cxx;



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

#define endl "\n"

#define pb push_back

#define F first

#define S second

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

#define isOdd(n)    (n&1)

#define LLMAX LLONG_MAX

#define LLMIN LLONG_MIN

#define IMN INT_MIN

#define IMX INT_MAX

#define pow(n, m) power((ll)n, (ll)m)

#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)

#define mem(x, val)    memset(x, val, sizeof(x)) //be careful

#define MOD 1000000007



typedef long long ll;

typedef long double ld;

typedef double dd;

typedef string str;

typedef pair<int, int> pii;



const int N = 1000;

ll dp[N][N];

char arr[N][N];

int n, m;

ll solve(int r = 0, int c = 0){

    if(r==n || c==m) return 0;



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



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



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



    if(~ret) return ret;



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

}

int main()

{

    THINK_TWICE_CODE_ONCE

    //freopen("test cases\\.txt", "r", stdin) ;

    cin>>n>>m;

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

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

            cin>>arr[i][j];

    mem(dp, -1);

    cout<<solve();

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.30009537095024x):
#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 pi 3.14159

using namespace std;

typedef long long LL;

const LL MOD = 1e9 + 7;

const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;

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

long long n,m,dp[1007][1007];

char array1[1007][1007];

bool isvalid(int i,int j){

    return i>=0&&i<=n&&j>=0&&j<=m;

}

long long solve(int i,int j){

   if(i>n)

        return 0;

    if(j>m)

        return 0;

    if(array1[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+1,j)%MOD)+(solve(i,j+1)%MOD))%MOD;

}

int main()

{

int i,j;

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

cin>>n>>m;

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

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

        cin>>array1[i][j];

    }

}

printf("%lld",solve(0,0));











    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.40481926945399x):
#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;

}