#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
using ll = long long;
const int N=2020;
char mp[N][N];
int L[N][N];
int R[N][N];
int D[N][N];
int U[N][N];
ll fpow(ll x, ll n)
{
ll res=1;
for (;n;n>>=1) {
if (n&1) res=res*x%mod;
x=x*x%mod;
}
return res;
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++) {
scanf("%s",mp[i]+1);
}
ll ans=0;
int cnt=0;
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) {
if (mp[i][j]=='.') {
++cnt;
L[i][j]=L[i][j-1];
U[i][j]=U[i-1][j];
} else {
L[i][j]=j;
U[i][j]=i;
}
}
}
for (int i=n;i>=1;i--) R[i][m+1]=m+1;
for (int j=m;j>=1;j--) D[n+1][j]=n+1;
for (int i=n;i>=1;i--) {
for (int j=m;j>=1;j--) {
if (mp[i][j]=='.') {
R[i][j]=R[i][j+1];
D[i][j]=D[i+1][j];
} else {
R[i][j]=j;
D[i][j]=i;
}
}
}
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) if (mp[i][j]=='.') {
int c = (j-L[i][j]-1)
+(i-U[i][j]-1)
+(D[i][j]-i-1)
+(R[i][j]-j-1)
+1;
// printf("%d %d %d %d\n",L[i][j],U[i][j],R[i][j],D[i][j]);
// printf("%d %d %d %d\n",i,j,cnt,c);
ans += (fpow(2,cnt)-fpow(2,cnt-c))%mod;
ans %= mod;
}
}
if (ans<0) ans+=mod;
printf("%lld\n",ans);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgbW9kPTEwMDAwMDAwMDc7CnVzaW5nIGxsID0gbG9uZyBsb25nOwoKY29uc3QgaW50IE49MjAyMDsKY2hhciBtcFtOXVtOXTsKaW50IExbTl1bTl07CmludCBSW05dW05dOwppbnQgRFtOXVtOXTsKaW50IFVbTl1bTl07CgpsbCBmcG93KGxsIHgsIGxsIG4pCnsKICAgIGxsIHJlcz0xOwogICAgZm9yICg7bjtuPj49MSkgewogICAgICAgIGlmIChuJjEpIHJlcz1yZXMqeCVtb2Q7CiAgICAgICAgeD14KnglbW9kOwogICAgfQogICAgcmV0dXJuIHJlczsKfQoKaW50IG1haW4oKQp7CiAgICBpbnQgbixtOwogICAgc2NhbmYoIiVkJWQiLCZuLCZtKTsKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKykgewogICAgICAgIHNjYW5mKCIlcyIsbXBbaV0rMSk7CiAgICB9CiAgICBsbCBhbnM9MDsKICAgIGludCBjbnQ9MDsKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKykgewogICAgICAgIGZvciAoaW50IGo9MTtqPD1tO2orKykgewogICAgICAgICAgICBpZiAobXBbaV1bal09PScuJykgewogICAgICAgICAgICAgICAgKytjbnQ7CiAgICAgICAgICAgICAgICBMW2ldW2pdPUxbaV1bai0xXTsKICAgICAgICAgICAgICAgIFVbaV1bal09VVtpLTFdW2pdOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgTFtpXVtqXT1qOwogICAgICAgICAgICAgICAgVVtpXVtqXT1pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgZm9yIChpbnQgaT1uO2k+PTE7aS0tKSBSW2ldW20rMV09bSsxOwogICAgZm9yIChpbnQgaj1tO2o+PTE7ai0tKSBEW24rMV1bal09bisxOwogICAgZm9yIChpbnQgaT1uO2k+PTE7aS0tKSB7CiAgICAgICAgZm9yIChpbnQgaj1tO2o+PTE7ai0tKSB7CiAgICAgICAgICAgIGlmIChtcFtpXVtqXT09Jy4nKSB7CiAgICAgICAgICAgICAgICBSW2ldW2pdPVJbaV1baisxXTsKICAgICAgICAgICAgICAgIERbaV1bal09RFtpKzFdW2pdOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgUltpXVtqXT1qOwogICAgICAgICAgICAgICAgRFtpXVtqXT1pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKSB7CiAgICAgICAgZm9yIChpbnQgaj0xO2o8PW07aisrKSBpZiAobXBbaV1bal09PScuJykgewogICAgICAgICAgICBpbnQgYyA9IChqLUxbaV1bal0tMSkKICAgICAgICAgICAgICAgICAgICArKGktVVtpXVtqXS0xKQogICAgICAgICAgICAgICAgICAgICsoRFtpXVtqXS1pLTEpCiAgICAgICAgICAgICAgICAgICAgKyhSW2ldW2pdLWotMSkKICAgICAgICAgICAgICAgICAgICArMTsKICAgICAgICAgICAgLy8gcHJpbnRmKCIlZCAlZCAlZCAlZFxuIixMW2ldW2pdLFVbaV1bal0sUltpXVtqXSxEW2ldW2pdKTsKICAgICAgICAgICAgLy8gcHJpbnRmKCIlZCAlZCAlZCAlZFxuIixpLGosY250LGMpOwogICAgICAgICAgICBhbnMgKz0gKGZwb3coMixjbnQpLWZwb3coMixjbnQtYykpJW1vZDsKICAgICAgICAgICAgYW5zICU9IG1vZDsKICAgICAgICB9CiAgICB9CiAgICBpZiAoYW5zPDApIGFucys9bW9kOwogICAgcHJpbnRmKCIlbGxkXG4iLGFucyk7CiAgICByZXR1cm4gMDsKfQ==