#include <cstdio>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <sstream>
#include <ostream>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <iomanip>
#include <set>
#include <bitset>
//#include<unordered_map>
#define INT_MINs -2000000000
#define INT_MAXs 1000000001
#define MID int mid=(l+r)/2
#define REP1(i,x,y) for(int i=x;i<y;i++)
#define REP2(i,x,y) for(int i=x;i<=y;i++)
#define ls (2*k)
#define rs (2*k+1)
#define lson l,mid,2*k
#define rson mid+1,r,2*k+1
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define IOS ios::sync_with_stdio(0);cin.tie(NULL);
#define pb(a) push_back(a)
#define pi acos(-1)
#define endl '\n'
//#define int long long
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll ba=131;
//ll qk(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x;y>>=1;x=x*x;}return ans;}
const int dx[8] = { 0,-1,0,1,-1,-1,1,1}, dy[8] = { -1,0,1,0,-1,1,-1,1};
const int dxx[8]= {2,1,-1,-2,-2,-1, 1, 2},dyy[8]= {1,2,2,1, -1,-2,-2,-1};
ll dp[2005][2005],sum[3][2005][2005];
char str1[2005][2005];
void solve()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%s",str1[i]+1);
    dp[1][1]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i==j&&i==1) continue;
            if(str1[i][j]=='#'){
                sum[1][i][j]=sum[2][i][j]=sum[0][i][j]=0;
            }else{
                sum[0][i][j]=(sum[0][i-1][j-1]+dp[i-1][j-1])%mod;
                sum[1][i][j]=(sum[1][i-1][j]+dp[i-1][j])%mod;
                sum[2][i][j]=(sum[2][i][j-1]+dp[i][j-1])%mod;
                dp[i][j]=(dp[i][j]+sum[0][i][j]+sum[1][i][j]+sum[2][i][j])%mod;;
                //cout<<dp[i][j]<<endl;
            }
        }
    }
    cout<<dp[n][m]<<endl;
}
int main()
{
    //IOS;
    solve();
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,0,1,0};
int dw[] = {0,1,0,-1};

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    int n,m; cin >> n >> m;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) sum += a[i];
    if(n+m < n+sum){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    repr(i,1,n+sum+1){
        ans *= (n+m-i+1)*modinv(i,MOD)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


