stablegradients/pie-gem5-pairs huggingface dataset:
// 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.627022238015728x):
#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:
/*

** 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.612047638299474x):
#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>

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

using namespace std;

using ll=long long;

const int N=1e3+10;

const int mod=1e9+7;

char g[N][N];

int dp[N][N];

int h,w;



int main(){

    cin>>h>>w;

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

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

            cin>>g[i][j];

            dp[j][0]=0;

        }

        dp[0][i]=0;

    }

    

    dp[1][1]=1;

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

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

            if(g[i][j]!='#' and (i>1 or j>1)){

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

            }

        }

    }

    cout<<(dp[h][w])%mod<<'\n';

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

using namespace std;

using ll=long long;

const int N=1e3+10;

const int mod=1e9+7;

char g[N][N];

int dp[N][N];

int h,w;



int main(){

    cin>>h>>w;

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

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

            cin>>g[i][j];

            dp[j][0]=0;

        }

        dp[0][i]=0;

    }

    

    dp[1][1]=1;

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

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

            if(g[i][j]!='#' and (i>1 or j>1)){

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

            }

        }

    }

    cout<<(dp[h][w])%mod<<'\n';

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

using namespace std;

using ll=long long;

const int N=1e3+10;

const int mod=1e9+7;

char g[N][N];

int dp[N][N];

int h,w;



int main(){

    cin>>h>>w;

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

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

            cin>>g[i][j];

            dp[j][0]=0;

        }

        dp[0][i]=0;

    }

    

    dp[1][1]=1;

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

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

            if(g[i][j]!='#' and (i>1 or j>1)){

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

            }

        }

    }

    cout<<(dp[h][w])%mod<<'\n';

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

using namespace std;

using ll=long long;

const int N=1e3+10;

const int mod=1e9+7;

char g[N][N];

int dp[N][N];

int h,w;



int main(){

    cin>>h>>w;

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

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

            cin>>g[i][j];

            dp[j][0]=0;

        }

        dp[0][i]=0;

    }

    

    dp[1][1]=1;

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

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

            if(g[i][j]!='#' and (i>1 or j>1)){

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

            }

        }

    }

    cout<<(dp[h][w])%mod<<'\n';

    return 0;

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

using namespace std;

using ll=long long;

const int N=1e3+10;

const int mod=1e9+7;

char g[N][N];

int dp[N][N];

int h,w;



int main(){

    cin>>h>>w;

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

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

            cin>>g[i][j];

            dp[j][0]=0;

        }

        dp[0][i]=0;

    }

    

    dp[1][1]=1;

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

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

            if(g[i][j]!='#' and (i>1 or j>1)){

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

            }

        }

    }

    cout<<(dp[h][w])%mod<<'\n';

    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: 1.8695657393504668x):
#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;

}
// 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: 1.845714893575312x):
#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;

}
// 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: 1.8663630702481375x):
#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;

}
// 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: 1.8634599877361018x):
#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;

}