stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int N = 100005;

int n, m, k;

vector<int> fr[N], bl[N];

int cc[N], sz[N];

bool vis[N];



void dfs(int u, int c) {

	vis[u] = 1;

	cc[u] = c;

	sz[c]++;

	for(auto& v : fr[u]) {

		if(!vis[v])

			dfs(v, c);

	}

}



int main() {

	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	cin >> n >> m >> k;

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

		int a, b; cin >> a >> b;

		fr[a].push_back(b);

		fr[b].push_back(a);

	}

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

		int a, b; cin >> a >> b;

		bl[a].push_back(b);

		bl[b].push_back(a);

	}



	int idx = 0;

	memset(vis, 0, sizeof vis);

	memset(sz, 0, sizeof sz);

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

		if(!vis[i])

			dfs(i, ++idx);

	}



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

		int ans = sz[cc[i]] - fr[i].size() - 1;

		for(auto& v : bl[i]) {

			if(cc[v] == cc[i]) ans--;

		}

		cout << ans << " ";

	}

	cout << '\n';



	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=1e5+5;



int father[N],sum[N],ans[N];

int n,m,k,x,y;



int Findfather(int x){

    return father[x]==x?x:father[x]=Findfather(father[x]);

}



void Union(int a,int b){

    a=Findfather(a),b=Findfather(b);

    if(a!=b) father[b]=a,sum[a]+=sum[b];

}



void init(){

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

        father[i]=i,sum[i]=1;

}



int main(){

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

    init();

    while(m--){

        scanf("%d%d",&x,&y);

        ans[x]++,ans[y]++;

        Union(x,y);

    }

    while(k--){

        scanf("%d%d",&x,&y);

        if(Findfather(x)==Findfather(y)) ans[x]++,ans[y]++;

    }

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

        printf("%d ",sum[Findfather(i)]-ans[i]-1);

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>



#define INF 2100000000



using namespace std;



int minix(int a,int b,int c){

	if(b>=a && c>=a){

		return a;

	}

	if(a>=b && c>=b){

		return b;

	}

	if(b>=c && a>=c){

		return c;

	}

}



int main(){

	int n;

	int masu[1002][1002];

	int ura[1002][1002];

	char str[1002];

	while(1){

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

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

				masu[i][j]=0;

			}

		}

		scanf("%d",&n);

		if(n==0){

			break;

		}

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

			scanf("%s",str);

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

				if(str[j-1]=='.'){

					ura[i][j]=0;

				}else{

					ura[i][j]=1;

				}

			}

		}

		

		int maxi=0;

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

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

				if(ura[i][j]==0){

					masu[i][j]=minix(masu[i-1][j],masu[i][j-1],masu[i-1][j-1])+1;

					maxi=max(masu[i][j],maxi);

				}

			}

		}

		

		printf("%d\n",maxi);

	}

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<iostream>



#define INF 2100000000



using namespace std;



int minix(int a,int b,int c){

	if(b>=a && c>=a){

		return a;

	}

	if(a>=b && c>=b){

		return b;

	}

	if(b>=c && a>=c){

		return c;

	}

}



int main(){

	int n;

	int masu[1002][1002];

	int ura[1002][1002];

	char str[1002];

	while(1){

		scanf("%d",&n);

		if(n==0){

			break;

		}

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

			scanf("%s",str);

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

				if(str[j-1]=='.'){

					ura[i][j]=0;

				}else{

					ura[i][j]=1;

				}

			}

		}

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

			masu[i][0]=masu[0][i]=0;

		}

		int maxi=0;

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

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

				if(ura[i][j]==0){

					masu[i][j]=minix(masu[i-1][j],masu[i][j-1],masu[i-1][j-1])+1;

					maxi=max(masu[i][j],maxi);

				}else{

					masu[i][j]=0;

				}

			}

		}

		

		printf("%d\n",maxi);

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

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

        return 0 ;

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

        return dp[i][j]%mod;

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





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define eb emplace_back

#define fi first

#define se second

#define lb lower_bound

#define ub upper_bound

const int mod = 1e9+7;

const int mx = INT_MAX;

const long double pi = 4*atan((long double)1);

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vii;

int dp[1005][1005];

int n,m;

char mat[1005][1005];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

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

		{

			cin>>mat[i][j];

		}

	}

	dp[0][0] = 1;

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

	{

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

		{

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

				continue;

			if(i>0)

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

			if(j>0)

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

		}

	}

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

#include<unordered_set>	

using namespace std;

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

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

#define clr(v, d)		memset(v, d, sizeof(v))

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

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

typedef long long         ll;

const double EPS = (1e-7);

int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

#define pb					push_back

#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

clock_t T;

#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl

void GOAT()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

#ifndef ONLINE_JUDGE

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

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

#else

#endif



}

int r, c;

char grid[1007][1007];

int mem[1007][1007];

bool valid(int i, int j)

{

	return (i < r && j < c);

}

const int m = 1e9 + 7;

int solve(int i, int j)

{

	if (i == r - 1 && j == c - 1)return 1;

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

	if (~ret)return ret;

	ret = 0;

	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;

	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;

	return ret%m;

}

int main() {

	//GOAT();

	

		clr(mem, -1);

		cin >> r >> c;

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

		{

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

			{

				cin>>grid[i][j];

			}

		}

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

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define eb emplace_back

#define fi first

#define se second

#define lb lower_bound

#define ub upper_bound

const int mod = 1e9+7;

const int mx = INT_MAX;

const long double pi = 4*atan((long double)1);

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vii;

int dp[1005][1005];

int n,m;

char mat[1005][1005];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

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

		{

			cin>>mat[i][j];

		}

	}

	dp[0][0] = 1;

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

	{

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

		{

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

				continue;

			if(i>0)

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

			if(j>0)

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

		}

	}

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;



const int N = 1007, M = 1e9 + 7;



char mat[N][N];





int memo[N][N];

int n, m;



int solve(int i, int j) {

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

    if(i >= n or j >= m) return 0;



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

    

    int & st = memo[i][j];

    if(st == -1) {

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

        st %= M;

    }

    return st;

}



int main() {

    memset(memo, -1, sizeof memo);

    cin >> n >> m;



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

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

            cin >> mat[i][j];

        }

    }



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

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define eb emplace_back

#define fi first

#define se second

#define lb lower_bound

#define ub upper_bound

const int mod = 1e9+7;

const int mx = INT_MAX;

const long double pi = 4*atan((long double)1);

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vii;

int dp[1005][1005];

int n,m;

char mat[1005][1005];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

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

		{

			cin>>mat[i][j];

		}

	}

	dp[0][0] = 1;

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

	{

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

		{

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

				continue;

			if(i>0)

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

			if(j>0)

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

		}

	}

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/* Ajay Jadhav */

#include <bits/stdc++.h>

 

#define ll          long long

#define pb          push_back

#define pii         pair<int,int>

#define vi          vector<int>

#define vii         vector<pii>

#define mi          map<int,int>

#define mii         map<pii,int>

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

#define x           first

#define y           second

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

#define endl        '\n'

#define hell        1000000007

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

using namespace std;

const int N=1001;

int h,w;

char g[N][N];

long long dp[N][N];

long long f(int i,int j)

{

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

        return 1;

    if(i>=h or j>=w or g[i][j]=='#')

        return 0;

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

        return dp[i][j];

    long long fi=f(i+1,j)%hell;

    long long se=f(i,j+1)%hell;

    dp[i][j]=(fi+se)%hell;

    return dp[i][j];

}



void solve()

{

    cin>>h>>w;

    rep(i,0,h) rep(j,0,w) cin>>g[i][j];

    memset(dp,-1,sizeof dp);

    cout<<f(0,0);

}

 

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t=1;

    // cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n,m;

    cin>>n>>m;

    int ar[n+3][m+5];

    char ch;

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

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

              if(ch=='#')ar[i][j]=0;

              else ar[i][j]=1;

        }



    long long int dp[n+4][m+4];

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n and ar[i][0]!=0;i++)dp[i][0]=1;

    for(int i=0;i<m and ar[0][i]!=0;i++)dp[0][i]=1;



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

    {

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

        {

            if(ar[i][j]==0){

                dp[i][j]=0;

                continue;

            }

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

            dp[i][j]%=1000000007;

        }



    }





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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

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



}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: