#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
const int INF = 1009009009;
const ll mod = 1000000007;

int h,w;
ll t=0;


int main(){
    cin >> h >> w;

    vector<string> mp(h);
    rep(i,h){
        cin >> mp[i];
    }

    rep(i,h)rep(j,w){
        if(mp[i][j]=='.') t++;
    }

    vector<vector<ll>> dp1(h,vector<ll>(w,0));
    vector<vector<ll>> dp2(h,vector<ll>(w,0));

    rep(i,h){
        ll now = 0;
        rep(j,w){
            if(mp[i][j]=='.'){
                now ++;
            }

            if(mp[i][j]=='#'){
                dp1[i][j] = 0;
                rep(k,now){
                    dp1[i][j-1-k] = now;
                }
                now = 0;
                continue;
            }
            if(j==w-1){
                rep(k,now){
                    dp1[i][j-k] = now;
                }
                now = 0;
            }
        }
    }

    rep(j,w){
        ll now = 0;
        rep(i,h){
            if(mp[i][j]=='.'){
                now ++;
            }

            if(mp[i][j]=='#'){
                dp2[i][j] = 0;
                rep(k,now){
                    dp2[i-1-k][j] = now;
                }
                now = 0;
                continue;
            }
            if(i==h-1){
                rep(k,now){
                    dp2[i-k][j] = now;
                }
                now = 0;
            }
        }
    }

/*
    rep(i,h){
        rep(j,w){
            cout << dp1[i][j];
        }
        cout << endl;
    }

    rep(i,h){
        rep(j,w){
            cout << dp2[i][j];
        }
        cout << endl;
    }
*/
    ll p2[h*w+1];

    p2[0] = 1;
    rep(i,h*w){
        p2[i+1] = (2*p2[i])%mod;
    }

   // cout << p2[t] << endl;

    ll ans = 0;

    rep(i,h){
        rep(j,w){
            if(dp1[i][j]==0) continue;
            ans = (ans + p2[t] - p2[t-dp1[i][j]-dp2[i][j]+1])%mod;
        }
    }

    cout << (ans + mod)%mod << endl;

}
#include <iostream>
#include <vector>
#define ll long long
#define mod %1000000007

using namespace std;

int main(){
  int high,wide;
  cin >> high;
  cin >> wide;
  vector<vector<int>> lamp(high+2,vector<int>(wide+2,-1));
  int num = 0;

  for(int i = 0;i < high;i ++){
    for(int j = 0;j < wide;j ++){
      char a;
      cin >> a;
      if(a == '.'){
        num ++;
        lamp[i+1][j+1] = 0;
      }
    }
  }

  ll ans = 0;
  vector<ll> mul(5000001,1);
  vector<ll> add(num+1);
  for(int i = 0;i < 5000000;i ++){
    mul[i+1] = (mul[i]*2)mod;
  }
  add[1] = mul[num-1];
  for(int i = 1;i < num;i ++){
    add[i+1] = (add[i] + mul[num-i-1])mod;
  }
  
  for(int i = 0;i < high+2;i ++){
    for(int j = 0;j < wide+2;j ++){
      if(lamp[i][j] != -1){
        int k = 0;
        while(lamp[i][j+k] != -1){
          k ++;
        }
        for(int l = 0;l < k;l ++){
          
          lamp[i][j] += k;
           j ++;
        }
      }
    }
    
  }

  for(int i = 0;i < wide+2;i ++){
    for(int j = 0;j < high+2;j ++){
      if(lamp[j][i] != -1){
        int k = 0;
        while(lamp[j+k][i] != -1){
          k ++;
        }
        for(int l = 0;l < k;l ++){
          
          lamp[j][i] += k-1;
          j ++;
        }
      }
    }
    
  }
  
  for(int i = 0;i < high+2;i ++){
    for(int j = 0;j < wide+2;j ++){
      if(lamp[i][j] == -1){
        continue;
      }
      ans = (ans +add[lamp[i][j]])mod;
      
    }
   
  }

  cout << ans << endl;
  
  return 0;
}