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

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

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

using namespace std;

using namespace __gnu_pbds;

using ll = long long;

using _TYPE = int;

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

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



int h, w;

const int MAX = 1002;

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

char grid[MAX][MAX];

int memo[MAX][MAX];



int dp(int r, int c) {

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

		return 0;

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

		return 1;

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

	if(rt != -1)

		return (rt % MOD);

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

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

	return (rt % MOD);

}



int main() {

    IO;

    cin >> h >> w;

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

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

    		cin >> grid[i][j];

    }

    memset(memo, -1, sizeof memo);

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

    return 0;

}


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

using namespace std;



const int MAX_N = 1e5 + 5;

const int MAX_L = 20; // ~ Log N

const long long MOD = 1e9 + 7;

const long long INF = 1e9 + 7;



typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> ii;

typedef vector<ii> vii;

typedef vector<vi> vvi;



const int MAXH = 1010, MAXW = 1010;



char grid[MAXH][MAXW];

int dp[MAXH][MAXW];

bool visited[MAXH][MAXW];



int h, w;



ll solve(int x, int y){

	if(x >= h || y >= w) return 0;

	if(grid[x][y] == '#') return 0;

	if(visited[x][y]) return dp[x][y];

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

	

	visited[x][y] = true;

	return dp[x][y] = (solve(x+1,y) + solve(x,y+1))%MOD;

}



int main(){

	ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    

    //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 >> grid[i][j];

	}

	ll ans = solve(0,0);

	cout << ans;

	

	return 0;

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

using namespace std;

#define oo (long long)1e9

#define ll long long

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

const ll mod = 1e9+7;

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

#define PI 3.14159265359

vector<pair<int,int>>v;

ll m,n;

char a[1009][1009];

ll dp[1009][1009];

ll solve(int i,int j)

{

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

        return 0;

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

        return 1;

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

        return dp[i][j];

    ll ans=0;

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

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

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

}

int main()

{

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

    _IOS();

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

    cin>>n>>m;

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

    {

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

        {

            cin>>a[i][j];

        }

    }

    cout<<solve(0,0);

}



//


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

using namespace std;



const int MAX_N = 1e5 + 5;

const int MAX_L = 20; // ~ Log N

const long long MOD = 1e9 + 7;

const long long INF = 1e9 + 7;



typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> ii;

typedef vector<ii> vii;

typedef vector<vi> vvi;



const int MAXH = 1010, MAXW = 1010;



char grid[MAXH][MAXW];

int dp[MAXH][MAXW];

bool visited[MAXH][MAXW];



int h, w;



ll solve(int x, int y){

	if(x >= h || y >= w) return 0;

	if(grid[x][y] == '#') return 0;

	if(visited[x][y]) return dp[x][y];

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

	

	visited[x][y] = true;

	return dp[x][y] = (solve(x+1,y) + solve(x,y+1))%MOD;

}



int main(){

	ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    

    //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 >> grid[i][j];

	}

	ll ans = solve(0,0);

	cout << ans;

	

	return 0;

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

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

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

#define pb push_back

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

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

using namespace std;

typedef long long ll;

const int oo = 1e9+5;

const ll MOD =1e9+7;

const double pi = acos(-1);

void fast(){

    ios_base :: sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int n, m;

bool valid (int r,int c){

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

}



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

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



char a[1001][1001];

int dp[1001][1001];



int path(int r, int c){

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

        return 0;

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

        return 1;



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

    if(ret != -1) return ret;



    ret = 0;



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

}



int main()

{

    fast();



    cin>>n>>m;

    f(i, 0, n)

    f(j, 0, m)

        cin>>a[i][j];

    memset(dp, -1);

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



    return 0;

}


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

using namespace std;



const int MAX_N = 1e5 + 5;

const int MAX_L = 20; // ~ Log N

const long long MOD = 1e9 + 7;

const long long INF = 1e9 + 7;



typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> ii;

typedef vector<ii> vii;

typedef vector<vi> vvi;



const int MAXH = 1010, MAXW = 1010;



char grid[MAXH][MAXW];

int dp[MAXH][MAXW];

bool visited[MAXH][MAXW];



int h, w;



ll solve(int x, int y){

	if(x >= h || y >= w) return 0;

	if(grid[x][y] == '#') return 0;

	if(visited[x][y]) return dp[x][y];

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

	

	visited[x][y] = true;

	return dp[x][y] = (solve(x+1,y) + solve(x,y+1))%MOD;

}



int main(){

	ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    

    //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 >> grid[i][j];

	}

	ll ans = solve(0,0);

	cout << ans;

	

	return 0;

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

using namespace std;

using ll = long long;

using ii = pair<int, int>;

using iii = pair<ii, int>;

#define vt vector

#define pb push_back

#define pf push_front

#define mp make_pair

#define fi first

#define se second

#define __lcm(a, b) a * b / __gcd(a, b)x

const int MOD = 1e9 + 7;

const int INF = 2e9;

const int N = 1e3 + 5;



int R, C;

int dp[N][N];

char grid[N][N];



int add(int x, int y) {

    return ((x % MOD) + (y % MOD)) % MOD;

}



bool inside(int r, int c) {

    return r >= 1 && r <= R && c >= 1 && c <= C;

}



int f(int r, int c) {

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

    if(!inside(r, c)) return 0;

    if(r == R && c == C) return 1;

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

    if(sol != -1) return sol;

    return sol = add(f(r + 1, c), f(r, c + 1));

}



void solve() {

    cin >> R >> C;

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

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

            cin >> grid[i][j];

        }

    }

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

    cout << f(1, 1) % MOD << "\n";

}



int main() {

 

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);



    solve();

    

}

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

using namespace std;



const int MAX_N = 1e5 + 5;

const int MAX_L = 20; // ~ Log N

const long long MOD = 1e9 + 7;

const long long INF = 1e9 + 7;



typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> ii;

typedef vector<ii> vii;

typedef vector<vi> vvi;



const int MAXH = 1010, MAXW = 1010;



char grid[MAXH][MAXW];

int dp[MAXH][MAXW];

bool visited[MAXH][MAXW];



int h, w;



ll solve(int x, int y){

	if(x >= h || y >= w) return 0;

	if(grid[x][y] == '#') return 0;

	if(visited[x][y]) return dp[x][y];

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

	

	visited[x][y] = true;

	return dp[x][y] = (solve(x+1,y) + solve(x,y+1))%MOD;

}



int main(){

	ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    

    //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 >> grid[i][j];

	}

	ll ans = solve(0,0);

	cout << ans;

	

	return 0;

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

using namespace std;

#define int long long 



const int mod=1e9+7;



int mat[1005][1005];

int ans[1005][1005];





int countPaths(int H,int W){

    ans[0][0]=1;



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

        if(mat[i][0]==1) {

            ans[i][0] = ans[i - 1][0];

        }

    }



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

        if(mat[0][i]!=0) {

            ans[0][i] = ans[0][i - 1];

        }

    }

    

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

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

            if(mat[i][j]!=0)

            {

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

            }

        }

    }

    

   return ans[H-1][W-1]%mod;

}



#undef int

int main() {

#define int long long

    int H,W;

    cin >> H >> W;

    char x;



    memset(ans,0,sizeof(ans));

    ans[0][0]=1;

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

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

            cin >> x;

            if(x=='.')

                mat[i][j]=1;

            else

                mat[i][j]=0;

        }

    }

     cout << countPaths(H,W)%mod << endl;

     /*

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

     {

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

         {

             cout << ans[i][j] << " ";

         }

         cout << endl;

     }

     */

}

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

using namespace std;

#define int long long



const int mod=1e9+7;

const int nax= 1005;

char mat[nax][nax];

int dp[nax][nax];



#undef int

int main() {

#define int long long

    int H,W;

    cin >> H >> W;

    int ans=0;



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

    {

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

        {

            cin >> mat[i][j];

        }

    }



    dp[0][0]=1;

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

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

           dp[0][i]=0;

        else

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



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

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

            dp[i][0] = 0;

        else

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



    

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

    {

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

        {

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

               dp[i][j]=0;

            else

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

        }

    }

    ans=(dp[H-1][W-1]%mod);

    cout << ans << endl;

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

using namespace std;

#define ll long long

#define mod 1000000007

char a[1005][1005];

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



ll solve( int h, int w){

    if(h==1 && w==1) return 1;

    if(h<1 || w<1) return 0;

    if(a[h][w] == '#'){

        return 0;

    }

    if(dp[h][w]!=-1) return dp[h][w];

    ll op1=0,op2=0;

    if(a[h-1][w] != '#')  op1 = solve(h-1,w);

    else op1=0;

    if(a[h][w-1] != '#')  op2 = solve(h,w-1);

    else op2=0;

    

    return dp[h][w] = ( op1+op2 ) %mod;

}

int main() {

    int h,w;

    cin>>h>>w;

    // char a[h][w];

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

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

            cin>>a[i][j];

        }

    }

    

    memset(dp,-1,sizeof dp);

    cout<< solve(h,w)<<endl;



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

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

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

    //     }cout<<endl;

    // }

}


// Faster C++ solution for the same problem (measured speedup: 9.481667973751172x):
#include <iostream>

using namespace std;

#define mod 1000000007

char grid[1001][1001]={0};

int dp[1001][1001];



int main() {

    int h,w;    

    cin>>h>>w;

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

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

            cin>>grid[i][j];

        }

    }

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

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

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

    //     }cout<<endl;

    // }

    // cout<<helper(h-1,w-1);

    dp[1][1]=1;

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

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

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

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

        }

    }

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

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

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

    //     }

    //     cout<<endl;

    // }

    cout<<dp[h][w]<<endl;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

#include <string>

#include <deque>

#include <list>

#include <map>

#include <queue>

#include <set>

#include <stack>

#include <cstring>

#include <iomanip>



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

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

#define Jrep(j,n) for(int j=0;j<(n);j++)

#define Jreps(j,n) for(int j=1;j<=(n);j++)

const int INF = 0x3f3f3f3f;

const long long LINF = 0x3f3f3f3f3f3f3f3fLL;



using namespace std;

int main(){

  cin.tie(0);

  ios::sync_with_stdio(false);

  

  int h,w;

  cin>>h>>w;

  long long sum[1010][1010]={};

  char x;

  sum[1][1]=1;

  reps(i,h){

      Jreps(j,w){

	  cin>>x;

	  if(x=='.'){

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

	  }

      }

  }

  cout<<sum[h][w]<<'\n';

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.8584861414624394x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <string>

#include <deque>

#include <list>

#include <map>

#include <queue>

#include <set>

#include <stack>

#include <cstring>

#include <iomanip>

#include <utility>



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

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

#define lol long long

const int INF = 0x3f3f3f3f;

const long long LINF = 0x3f3f3f3f3f3f3f3fLL;



using namespace std;



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    int h,w;

    cin>>h>>w;



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

    char mas[1005][1005];

    reps(i,h){

	reps(j,w){

	    cin>>mas[i][j];

	}

    }



    dp[1][1]++;

    reps(i,h){

	reps(j,w){



	    if(mas[i][j]!='#'){

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

		dp[i][j]%=1000000007;

	    }

	

	}

    }



    cout<<dp[h][w]<<'\n';

    return 0;

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

using namespace std;

typedef long long ll;

ll f,c;

char matriz[1005][1005];

ll memo[1005][1005];



ll mod(ll x){

    return x%1000000007;

}



bool validPos(ll i, ll j){

	return i > 0 and j > 0 and i <= f and j <= c;

}

ll dp(ll a,ll b){

    if(memo[a][b]!=-1) return memo[a][b];

    if(a==1 and b==1) return 1;

    else{

        if(matriz[a][b]!='#' and validPos(a,b)){

            memo[a][b]= mod(mod(dp(a,b-1)) + mod(dp(a-1,b)));

        }else{

            memo[a][b]=0;

        }

    }

    return memo[a][b];

}



int main(){

    

    cin>>f>>c;

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

    for(int i=0;i<=f;i++) memo[0][i]=0;

    for(int j=0;j<=c;j++) memo[j][0]=0;

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

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

            cin>>matriz[i][j];

        }

    }

    cout<<dp(f,c)<<"\n";

    

}


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

typedef long long ll;

const int N = 1000 + 5;

int dp[N][N];

char grid[N][N];

int h, w;

const ll mod = 1e9 + 7;



void self_add(int &a, int b) {

    a += b;

    if (a >= mod)

        a -= mod;

}



int solve(int i, int j) {

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

        return 1;

    if (i > h - 1 || j > w - 1)

        return 0;

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

        return 0;

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

        return dp[i][j];

    int res = 0;

    self_add(res, solve(i + 1, j));

    self_add(res, solve(i, j + 1));

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

}



int main() {

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> h >> w;

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

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

            cin >> grid[i][j];

    memset(dp, -1, sizeof dp);

    cout << solve(0, 0);

    return 0;

}


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

using namespace std;

typedef long long ll;

const int N = 1000 + 5;

int dp[N][N];

char grid[N][N];

int h, w;

const ll mod = 1e9 + 7;



void self_add(int &a, int b) {

    a += b;

    if (a >= mod)

        a -= mod;

}



int main() {

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> h >> w;

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

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

            cin >> grid[i][j];

    dp[0][0] = 1;

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

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

            if (!i && !j)

                continue;

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

                continue;

            if (i)

                self_add(dp[i][j], dp[i - 1][j]);

            if (j)

                self_add(dp[i][j], dp[i][j - 1]);

        }

    }

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

    return 0;

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

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



using ll = long long;

using namespace std;



const int MOD = 1e9 + 7;

const int N = 1010;

char grid[N][N];

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



int solve(int i, int j)

{

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

		return 1;

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

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

		return dp = 0;



	if (dp != -1)

		return dp;

	

	dp = 0;

	if (i > 0)

		dp += solve(i - 1, j);

	if (j > 0)

		dp += solve(i, j - 1);

	dp %= MOD;

	return dp;

}



int main()

{

	ios_base::sync_with_stdio(false);

	cin.tie(nullptr);



#ifdef LOCAL_DEFINE

	freopen("in.txt", "r", stdin);

#endif



	cin >> n >> m;



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

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

			cin >> grid[i][j];



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



	cout << solve(n - 1, m - 1) << '\n';



	return 0;

}

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

using namespace std;



const int N = 1010;

const int MOD = 1e9 + 7;

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



inline int add(int a, int b) { if ((a += b) >= MOD) a -= MOD; return a; }



int main() {

   ios_base::sync_with_stdio(0);

   cin.tie(0);

   cin >> n >> m;

   dp[0][1] = 1;

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

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

         char c;

         cin >> c;

         if (c == '.')

            dp[i][j] = add(dp[i][j], add(dp[i - 1][j], dp[i][j - 1]));

         

      }

   }

   cout << dp[n][m] << '\n';

   return 0;

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

#pragma GCC optimize "03"

using namespace std;



#define int long long int

#define pb push_back

#define pii pair<int,int>

#define fi first

#define se second

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

#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }

#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }

#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }

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

#ifndef LOCAL

#define endl '\n'

#endif

const int inf = INT_MAX;

const double eps = 0.0000001;

const double PI = acos(-1.0);

const int MOD = 1e9+7;

const int N  = 1e3+5;



char a[N][N];

int dp[N][N];



int solve (int i, int j) {

	if (a[i][j] == '#') return 0;

	if (i == 1 && j == 1) return 1;

	if (i < 1 || j < 1) return 0;

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

	dp[i][j] = (solve(i-1, j) + solve(i,j -1))%MOD;

	return dp[i][j];

}



signed main(){

    #ifdef LOCAL

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

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

    #endif  

    IOS;



    int n, m;

    cin >> n >> m;

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

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

    		dp[i][j] = -1;

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

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

    		cin >> a[i][j];

    	}

    }

    cout << solve(n, m);

    return 0;

}


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

#pragma GCC optimize "03"

using namespace std;



#define int long long int

#define pb push_back

#define pii pair<int,int>

#define fi first

#define se second

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

#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }

#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }

#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }

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

#ifndef LOCAL

#define endl '\n'

#endif

const int inf = INT_MAX;

const double eps = 0.0000001;

const double PI = acos(-1.0);

const int MOD = 1e9+7;

const int N  = 1e3+5;



char a[N][N];

int dp[N][N], ready[N][N];



int solve (int i, int j) {

	if (a[i][j] == '#') return 0;

	if (i == 1 && j == 1) return 1;

	if (i < 1 || j < 1) return 0;

	if (ready[i][j]) return dp[i][j];

	dp[i][j] = (solve(i-1, j) + solve(i,j -1))%MOD;

	ready[i][j] = 1;

	return dp[i][j];

}



signed main(){

    #ifdef LOCAL

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

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

    #endif  

    IOS;



    int n, m;

    cin >> n >> m;

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

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

    		cin >> a[i][j];

    	}

    }

    cout << solve(n, m);

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;



int h, w;

char path[1001][1001];

long long  memo[1001][1001];

long long numberofpath(int i, int j)

{

	long long answer = 0; 

	if (i < 0 || j < 0 || i == h || j == w) return 0;

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

	else if (path[i][j] == '#') return 0; 

	else

	{

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

		else

		{

			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);

			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);

		}

	}



	return memo[i][j] = answer;

}





int main()

{

	memset(memo,-1, sizeof memo);

	cin >> h >> w; 

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

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

			cin >> path[i][j];



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

	cout << endl;



	system("pause");

}


// Faster C++ solution for the same problem (measured speedup: 9.313766176599376x):
#include<iostream>



using namespace std;

const int N=2000,M=1000000007;

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

bool check[N][N];

char s[N][N];

int pro(int x,int y){

	if(y>=m) return 0; if(x>=n) return 0;

	if(s[x][y]=='#') return 0;

	if(check[x][y]) return dp[x][y];

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

	check[x][y]=true;

	return dp[x][y]=(pro(x+1,y)+pro(x,y+1))%M;

}

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin>>n>>m;

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

		check[i][j]=false;

		cin>>s[i][j];

	}

	if(s[n-1][m-1]=='#'){

		cout<<0;

		return 0;

	}

	cout<<pro(0,0);

}