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

using namespace std;

#define ll long long

const int mod=1e9+7;

int n,m;

char grid[1009][1009];

int vis[1009][1009];

ll num[1009][1009];

ll dp(int x,int y){

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

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

    if(vis[x][y])return num[x][y];

    vis[x][y]=1;

//    num[x][y]=(num[x][y]+dp(x,y+1))%mod;

//    num[x][y]=(num[x][y]+dp(x+1,y))%mod;

    num[x][y]=(dp(x,y+1)%mod+dp(x+1,y)%mod)%mod;

    return num[x][y]%mod;

}

int main()

{

    ios::sync_with_stdio(false);

    cin>>n>>m;

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

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

    cout<<dp(1,1)%mod<<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.417219412276614x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

const int mod=1e9+7;

int n,m;

char grid[1009][1009];

int vis[1009][1009];

ll num[1009][1009];

ll dp(int x,int y){

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

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

    if(vis[x][y])return num[x][y];

    vis[x][y]=1;

//    num[x][y]=(num[x][y]+dp(x,y+1))%mod;

//    num[x][y]=(num[x][y]+dp(x+1,y))%mod;

    num[x][y]=(dp(x,y+1)%mod+dp(x+1,y)%mod)%mod;

    return num[x][y]%mod;

}

int main()

{

    ios::sync_with_stdio(false);

    cin>>n>>m;

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

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

    cout<<dp(1,1)%mod<<endl;

    return 0;

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

#define ll long long

#define m 1000000007;

using namespace std;



char grid[1007][1007];

ll dp[1007][1007];

bool vis[1007][1007];

int h,w;



bool valid( int i, int j )

{

    if( i<0 or j<0 )

        return 0;

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

        return 0;

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

        return 0;

    return 1;

}



ll rec( int i, int j )

{

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

        return 1;

    if(vis[i][j])

        return dp[i][j];



    ll q1= 0, q2= 0;



    if( valid(i+1,j) )

        q1= rec( i+1,j )%m;

    if( valid(i,j+1) )

        q2= rec( i, j+1 )%m;



    vis[i][j]= 1;



    return dp[i][j]= (q1+q2)%m;

}



int main()

{

    cin>>h>>w;



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

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

            cin>>grid[i][j];



    cout<< rec(0,0) <<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.52746503192968x):
#include <bits/stdc++.h>

#define ll long long

#define m 1000000007;

using namespace std;



char grid[1007][1007];

ll dp[1007][1007];

bool vis[1007][1007];

int h,w;



bool valid( int i, int j )

{

    if( i<0 or j<0 )

        return 0;

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

        return 0;

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

        return 0;

    return 1;

}



ll rec( int i, int j )

{

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

        return 1;

    if(vis[i][j])

        return dp[i][j];



    ll q1= 0, q2= 0;



    if( valid(i+1,j) )

        q1= rec( i+1,j )%m;

    if( valid(i,j+1) )

        q2= rec( i, j+1 )%m;



    vis[i][j]= 1;



    return dp[i][j]= (q1+q2)%m;

}



int main()

{

    cin>>h>>w;



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

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

            cin>>grid[i][j];



    cout<< rec(0,0) <<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.405087539854698x):
#include <bits/stdc++.h>

#define ll long long

#define m 1000000007;

using namespace std;



char grid[1007][1007];

ll dp[1007][1007];

bool vis[1007][1007];

int h,w;



bool valid( int i, int j )

{

    if( i<0 or j<0 )

        return 0;

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

        return 0;

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

        return 0;

    return 1;

}



ll rec( int i, int j )

{

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

        return 1;

    if(vis[i][j])

        return dp[i][j];



    ll q1= 0, q2= 0;



    if( valid(i+1,j) )

        q1= rec( i+1,j )%m;

    if( valid(i,j+1) )

        q2= rec( i, j+1 )%m;



    vis[i][j]= 1;



    return dp[i][j]= (q1+q2)%m;

}



int main()

{

    cin>>h>>w;



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

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

            cin>>grid[i][j];



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



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

using namespace std;

int const mod = 1e9+7;



int h,w;

bool a[1001][1001];

int dp[1001][1001];



int solve(int x, int y){

    if (y == w-1 && x == h-1) return 1;

    else if (!a[x][y]) return dp[x][y] = 0;

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

    int aux = 0,aux2 = 0;

    if (x < h-1) aux = solve(x+1,y);

    if (y < w-1) aux2 = solve(x,y+1);

    return dp[x][y] = (aux+aux2)%mod;

}



int main(int argc, char const *argv[]) {

    cin >> h >> w;

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

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

            char c; cin >> c;

            if (c == '.') a[i][j] = 1;

            else a[i][j] = 0;

            dp[i][j] = -1;

        }

    }

    cout << solve(0,0) << 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.525535861189555x):
#include <bits/stdc++.h>

using namespace std;

int const mod = 1e9+7;



int h,w;

bool a[1001][1001];

int dp[1001][1001];



int solve(int x, int y){

    if (y == w-1 && x == h-1) return 1;

    else if (!a[x][y]) return dp[x][y] = 0;

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

    int aux = 0,aux2 = 0;

    if (x < h-1) aux = solve(x+1,y);

    if (y < w-1) aux2 = solve(x,y+1);

    return dp[x][y] = (aux+aux2)%mod;

}



int main(int argc, char const *argv[]) {

    cin >> h >> w;

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

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

            char c; cin >> c;

            if (c == '.') a[i][j] = 1;

            else a[i][j] = 0;

            dp[i][j] = -1;

        }

    }

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

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

using namespace std;

int const mod = 1e9+7;



int h,w;

bool a[1001][1001];

int dp[1001][1001];



int solve(int x, int y){

    if (y == w-1 && x == h-1) return 1;

    else if (!a[x][y]) return dp[x][y] = 0;

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

    int aux = 0,aux2 = 0;

    if (x < h-1) aux = solve(x+1,y);

    if (y < w-1) aux2 = solve(x,y+1);

    return dp[x][y] = (aux+aux2)%mod;

}



int main(int argc, char const *argv[]) {

    cin >> h >> w;

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

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

            char c; cin >> c;

            if (c == '.') a[i][j] = 1;

            else a[i][j] = 0;

            dp[i][j] = -1;

        }

    }

    cout << solve(0,0) << 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.643542156975027x):
#include <bits/stdc++.h>

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f

#define INF 0x3f3f3f3f

#define pb push_back

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

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

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

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

using namespace std;

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<long long, int> pli;

typedef pair<long long, long long> pll;

const int mod = 1e9 + 7;

const int N = 1e3+10;

const int M = 1e6+10;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}

inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}

inline ll C(ll y, ll x) { ll ans = 1; if(y < 0 || x < 0 || y < x) return 0; y %= mod; if(!y || !x) return 1; for0(i, x) ans = ans * (y-i) % mod; for1(i, x) ans = ans * Pow(i, mod-2) % mod; return ans; }

//==================================================================================================================================================================//



int n, m, dp[N][N];

char mp[N][N];



int main() {

   dp[1][1] = 1;

   scanf("%d %d", &n, &m);

   for1(i, n) for1(j, m) {

      scanf(" %c", &mp[i][j]);

   }

   for1(i, n) for1(j, m) {

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

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

   }

   printf("%d\n", dp[n][m]);

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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f

#define INF 0x3f3f3f3f

#define pb push_back

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

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

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

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

using namespace std;

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef pair<long long, int> pli;

typedef pair<long long, long long> pll;

const int mod = 1e9 + 7;

const int N = 1e3+10;

const int M = 1e6+10;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}

inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}

inline ll C(ll y, ll x) { ll ans = 1; if(y < 0 || x < 0 || y < x) return 0; y %= mod; if(!y || !x) return 1; for0(i, x) ans = ans * (y-i) % mod; for1(i, x) ans = ans * Pow(i, mod-2) % mod; return ans; }

//==================================================================================================================================================================//



int n, m, dp[N][N];

char mp[N][N];



int main() {

   dp[1][1] = 1;

   scanf("%d %d", &n, &m);

   for1(i, n) for1(j, m) {

      scanf(" %c", &mp[i][j]);

   }

   for1(i, n) for1(j, m) {

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

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

   }

   printf("%d\n", dp[n][m]);

   return 0;

}