#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
char s[2010][2010];
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll mod=1000000007;
  ll h,w,i,j;
  scanf("%lld %lld\n",&h,&w);
  ll x[2010][2010];
  for(i=0;i<=h+1;i++){
    for(j=0;j<=w+1;j++){
      x[i][j]=0,s[i][j]='#';
    }
  }
  ll ans1=0;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%c",&s[i][j]);
      if(s[i][j]=='.'){
        ans1++;
      }
    }
    scanf("\n");
  }
  for(i=1;i<=h;i++){
    int count=1;
    for(j=1;j<=w;j++){
      if(s[i][j]=='.'){
        x[i][j]+=count;
        count++;
      }
      else{
        count=1;
        x[i][j]+=count;
      }
    }
  }
  for(i=1;i<=h;i++){
    int count=1;
    for(j=w;j>=1;j--){
      if(s[i][j]=='.'){
        x[i][j]+=count;
        count++;
      }
      else{
        count=1;
        x[i][j]+=count;
      }
    }
  }
  for(i=1;i<=w;i++){
    int count=1;
    for(j=1;j<=h;j++){
      if(s[j][i]=='.'){
        x[j][i]+=count;
        count++;
      }
      else{
        count=1;
        x[j][i]+=count;
      }
    }
  }
  for(i=1;i<=w;i++){
    int count=1;
    for(j=h;j>=1;j--){
      if(s[j][i]=='.'){
        x[j][i]+=count;
        count++;
      }
      else{
        count=1;
        x[j][i]+=count;
      }
    }
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      x[i][j]-=3;
    }
  }
  ll ans=0;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(s[i][j]=='.'){
        ans+=modpow(2,ans1,mod)-modpow(2,ans1-x[i][j],mod);
        ans+=mod+mod+mod;
        ans=ans%mod;
      }
    }
  }
  ans=ans%mod;
  cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

void solve(){
    int64_t N, A, B;
    cin >> N >> A >> B;
    int64_t all = (N-A+1)*(N-B+1);
    int64_t mx = max(int64_t(0), N-A-B+1);
    int64_t ans = power_mod(all, 2);
    add(ans, MOD - power_mod(all - mx*(mx+1), 2));
    cout << ans << endl;
}

int main(){
    int H, W;
    cin >> H >> W;
    string S[2000];
    for(int i=0; i<H; i++) cin >> S[i];
    static int U[2000][2000], D[2000][2000], L[2000][2000], R[2000][2000];
    int K = 0;
    int64_t ans = 0;
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(S[i][j] == '.'){
        K++;
        if(i && S[i-1][j] == '.') U[i][j] = U[i-1][j] + 1;
        if(j && S[i][j-1] == '.') L[i][j] = L[i][j-1] + 1;
    }
    for(int i=H-1; i>=0; i--) for(int j=W-1; j>=0; j--) if(S[i][j] == '.'){
        if(i<H-1 && S[i+1][j] == '.') D[i][j] = D[i+1][j] + 1;
        if(j<W-1 && S[i][j+1] == '.') R[i][j] = R[i][j+1] + 1;
        int ok = U[i][j] + L[i][j] + D[i][j] + R[i][j] + 1;
        add(ans, power_mod(2, K) - power_mod(2, K-ok) + MOD);
    }
    cout << ans << endl;
}
