/** 	Author: Apoorva Mittal  **/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define nl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repD(i, a, b) for (int i = a; i >= b; i--)
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define init(i, k) memset(i, k, sizeof i)
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define inp(a) rep(i, 0, a.size()) cin >> a[i];
#define out(a)                               \
    cout << #a << ": " << endl;              \
    rep(i, 0, a.size()) cout << a[i] << " "; \
    cout << endl;
#define out2d(a)                \
    cout << #a << ": " << endl; \
    rep(i, 0, a.size())         \
    {                           \
        rep(j, 0, a[0].size())  \
                cout            \
            << a[i][j] << " ";  \
        cout << endl;           \
    }
#define flush fflush(stdout);
#define lb lower_bound
#define ub upper_bound
#define maxe *max_element
#define mine *min_element
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define pqueue priority_queue
#define precise(x) cout << fixed << showpoint << setprecision(x);
#define setbit(x) __builtin_popcountll(x)
#define gcd(a, b) __gcd(a, b)
#define deb(x) cout << #x << " " << x << endl;
#define Y "YES"
#define N "NO"
const int mod = 1e9 + 7;
// ====== Useful functions begin ======
inline int add(int a, int b) { return ((a % mod) + (b % mod)) % mod; }
inline int sub(int a, int b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
// ====== Useful functions end ======
const int inf = 1e18;
const int maxn = 1e3 + 5;

//--------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------

void solve()
{
    int n, m;

    cin >> n >> m;
    vvi arr(n, vi(m));

    rep(i, 0, n)
    {
        rep(j, 0, m)
        {
            char c;
            cin >> c;
            if (c == '.')
                arr[i][j] = 0;
            else
            {
                arr[i][j] = -1;
            }
        }
    }

    vvi dp(n, vi(m, -1));

    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = m - 1; j >= 0; j--)
        {
            if (i == n - 1 && j == m - 1)
            {
                dp[i][j] = 1;
                continue;
            }

            if (i == n - 1)
            {
                if (arr[i][j] == -1 || dp[i][j + 1] == -1)
                    dp[i][j] = -1;

                else
                {
                    dp[i][j] = dp[i][j + 1];
                }
            }

            else if (j == m - 1)
            {
                if (arr[i][j] == -1 || dp[i + 1][j] == -1)
                    dp[i][j] = -1;

                else
                {
                    dp[i][j] = dp[i + 1][j];
                }
            }
            else
            {
                if (arr[i][j] == -1)
                    dp[i][j] = -1;
                else
                {
                    int ans=0;
                    if(dp[i+1][j]!=-1) ans=dp[i+1][j];
                    if(dp[i][j+1]!=-1) ans = add(ans,dp[i][j+1]);

                    if(ans!=0)
                    dp[i][j] = ans;                   
                }
            }
        }
    }
    // out2d(dp)
    if(dp[0][0]!=-1)
    cout<<dp[0][0]<<endl;
    else cout<<0<<endl;
}
signed main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    speed;
    int t = 1;
    // cin >> t;

    for (int tt = 1; tt <= t; tt++)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
}

Measured memory_bytes: 16000