/*
                              _,add8ba,
                            ,d888888888b,
                           d8888888888888b                        _,ad8ba,_
                          d888888888888888)                     ,d888888888b,
                          I8888888888888888 _________          ,8888888888888b
                __________`Y88888888888888P"""""""""""baaa,__ ,888888888888888,
            ,adP"""""""""""9888888888P""^                 ^""Y8888888888888888I
         ,a8"^           ,d888P"888P^                           ^"Y8888888888P'
       ,a8^            ,d8888'                                     ^Y8888888P'
      a88'           ,d8888P'                                        I88P"^
    ,d88'           d88888P'                                          "b,
   ,d88'           d888888'                                            `b,
  ,d88'           d888888I                                              `b,
  d88I           ,8888888'            ___                                `b,
 ,888'           d8888888          ,d88888b,              ____            `b,
 d888           ,8888888I         d88888888b,           ,d8888b,           `b
,8888           I8888888I        d8888888888I          ,88888888b           8,
I8888           88888888b       d88888888888'          8888888888b          8I
d8886           888888888       Y888888888P'           Y8888888888,        ,8b
88888b          I88888888b      `Y8888888^             `Y888888888I        d88,
Y88888b         `888888888b,      `""""^                `Y8888888P'       d888I
`888888b         88888888888b,                           `Y8888P^        d88888
 Y888888b       ,8888888888888ba,_          _______        `""^        ,d888888
 I8888888b,    ,888888888888888888ba,_     d88888888b               ,ad8888888I
 `888888888b,  I8888888888888888888888b,    ^"Y888P"^      ____.,ad88888888888I
  88888888888b,`888888888888888888888888b,     ""      ad888888888888888888888'
  8888888888888698888888888888888888888888b_,ad88ba,_,d88888888888888888888888
  88888888888888888888888888888888888888888b,`"""^ d8888888888888888888888888I
  8888888888888888888888888888888888888888888baaad888888888888888888888888888'
  Y8888888888888888888888888888888888888888888888888888888888888888888888888P
  I888888888888888888888888888888888888888888888P^  ^Y8888888888888888888888'
  `Y88888888888888888P88888888888888888888888888'     ^88888888888888888888I
   `Y8888888888888888 `8888888888888888888888888       8888888888888888888P'
    `Y888888888888888  `888888888888888888888888,     ,888888888888888888P'
     `Y88888888888888b  `88888888888888888888888I     I888888888888888888'
       "Y8888888888888b  `8888888888888888888888I     I88888888888888888'
         "Y88888888888P   `888888888888888888888b     d8888888888888888'
            ^""""""""^     `Y88888888888888888888,    888888888888888P'
                             "8888888888888888888b,   Y888888888888P^
                              `Y888888888888888888b   `Y8888888P"^
                                "Y8888888888888888P     `""""^
                                  `"YY88888888888P'
                                       ^""""""""'
*/
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// int main()
// {
//     ll l1,l2,l3,now,min,ind;
//     char c;
//     string s1,s2,s3;
//     cin>>l1>>l2>>l3;
//     cin>>s1>>s2>>s3;
//     vector<char> v;;
//     min=99999;
//     ind=0;
//     for (int i = 0; i < s2.length(); ++i)
//     {
//         now=s2[i]-'a';
//         if(min>now && s2[i]-'a'<s3[0]-'a')
//         {
//             min=now;
//             c=s2[i];
//             ind=i;
//         }
//     }
//     //cout<<ind<<endl;
//     for (int i = ind; i < s2.length(); ++i)
//     {
//         //cout<<s2[i];
//         if(s2[i]-'a'< s3[0]-'a')
//             v.pb(s2[i]);
//         else
//             break;
//     }
//     cout<<s1;
//     for (int i = 0; i < v.size(); ++i)
//     {
//         cout<<v[i];
//     }
//     cout<<s3;
// }

int main()
{
    ll h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    ll dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            //cout<<"ejfehfe";
            cin>>a[i][j];
        }
    }
    if(a[1][1]=='#')
        dp[1][1]=0;
    else
        dp[1][1]=1;
    for (int i = 2; i <= w; ++i)
    {
        if(a[1][i]=='.')
        {
            dp[1][i]+=dp[1][i-1];
            dp[1][i]%=mod;
        }
        else if(a[1][i]=='#')
        {
            //last=0;
            dp[1][i]=0;
        }
    }
    for (int i = 2; i <= h; ++i)
    {
        if(a[i][1]=='.')
        {
            dp[i][1]+=dp[i-1][1];
            dp[i][1]%=mod;
        }
        else if(a[i][1]=='#')
        {
            //last=0;
            dp[i][1]=0;
        }
    }
    

    for (int i = 2; i <= h; ++i)
    {
        for (int j = 2; j <= w; ++j)
        {
            if(a[i][j]!='#')
            {
                if(a[i-1][j]!='#')
                    dp[i][j]+=dp[i-1][j];
                
                if(a[i][j-1]!='#')
                    dp[i][j]+=dp[i][j-1];
                dp[i][j]=dp[i][j]%mod;
            }
            else
            {
                dp[i][j]=0;
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[h][w];
}

Measured memory_bytes: 9088