/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

*/

#include <bits/stdc++.h>
using namespace std;
#define sz(x) (ll)(x).size()
#define trav(x) for(auto& it: x)
#define all(x) x.begin(), x.end()
#define stp fixed<<setprecision(20)
#define tc ll tt; cin>>tt; while(tt--)
#define For(i, st, en) for(ll i=st; i<en; i++)
#define rFor(i, st, en) for(ll i=st; i>=en; i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define printv(x) For(i, 0, sz(x)){cout<<x[i]<<" ";} cout<<endl;
#define print2v(x) For(i, 0, sz(x)){For(j, 0, sz(x[i])){cout<<x[i][j]<<" ";} cout<<endl;}
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
#define endl '\n'
#define MAXN 300005
#define MOD 1000000007
#define INF 1000000000000000007
#define bitc __builtin_popcountll

#ifdef ROBOT
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (double)(clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n";

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define end_routine()
#define trace(...) 
#endif

void splitx(string s, char c, vector<string> &v){
    int i=0, j;
    while(i<sz(s)){
        j=i; string temp;
        while(j<sz(s) && s[j]!=c){temp+=s[j]; j++;}
        v.pb(temp); i=j+1;
    }
}

vi dx{1, 0, -1, 0, 1, 1, -1, -1};
vi dy{0, 1, 0, -1, 1, -1, 1, -1};


/*################################ ¯\_(ツ)_/¯ ################################*/

int n, m;
vector<string> v(1000);
vvi dp(1000, vi(1000, 0));
vvi vis(1000, vi(1000, 0));

signed main(){
    fast
    #ifdef ROBOT
        freopen("/home/yell0wfl4sh/Competitive/input.txt", "r", stdin);
        freopen("/home/yell0wfl4sh/Competitive/output.txt", "w", stdout);
    #endif
    
    cin>>n>>m;
    For(i, 0, n){
    	cin>>v[i];
    }
    dp[n-1][m-1]=1;
    vis[n-1][m-1]=1;
    queue<pii> q;
    q.push({n-1, m-1});
    int x, y;
    while(!q.empty()){
    	x = (q.front()).F;
    	y = (q.front()).S;
    	q.pop();
    	if(x-1>=0 && v[x-1][y]=='.'){
    		if(!vis[x-1][y]){
	    		q.push({x-1, y});
	    		vis[x-1][y]=1;
    		}
    	}
    	if(y-1>=0 && v[x][y-1]=='.'){
    		if(!vis[x][y-1]){
	    		q.push({x, y-1});
	    		vis[x][y-1]=1;
    		}
    	}
    	if(x+1<n) dp[x][y]+=dp[x+1][y];
    	if(y+1<m) dp[x][y]+=dp[x][y+1];
    	dp[x][y]%=MOD;
    }

    int ans=dp[0][0];

    cout<<ans<<endl;


    end_routine()
    return 0;
}



Measured memory_bytes: 17024