#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
  int64_t v;
  Mint() { v = 0; }
  Mint(int64_t x) { v = x % MOD; if(v < 0) v += MOD; }

  Mint operator-() { return Mint(-v); };
  Mint operator+(Mint x) { return Mint(v + x.v); };
  Mint operator-(Mint x) { return Mint(v - x.v); };
  Mint operator*(Mint x) { return Mint(v * x.v); };
  Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

  Mint& operator+=(Mint x) { return *this = (*this + x); };
  Mint& operator-=(Mint x) { return *this = (*this - x); };
  Mint& operator*=(Mint x) { return *this = (*this * x); };
  Mint& operator/=(Mint x) { return *this = (*this / x); };

  static Mint pow(Mint base, int64_t exp) {
    if(exp == 0) return Mint(1);
    return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
  }

  friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

template<typename T> vector<T> tensor(int n, T v){ return vector<T>(n, v); }
template<typename... Ts> auto tensor(int n, Ts... ts) {
  return vector<decltype(tensor(ts...))>(n, tensor(ts...));
}

int main() {
  lint h, w;
  cin >> h >> w;
  auto S = tensor(h+2, w+2, '#');
  for(lint i=1; i<=h; i++)
  for(lint j=1; j<=w; j++) {
    cin >> S[i][j];
  }

  auto dp = tensor(h+2, w+2, 4, 1);
  for(lint i=1; i<=h; i++)
  for(lint j=1; j<=w; j++) {
    if(S[i][j] == '.') {
      dp[i][j+1][0] = dp[i][j][0] + 1;
      dp[i+1][j][1] = dp[i][j][1] + 1;
    } else {
      dp[i][j][0] = dp[i][j][1] = 0;
    }
  }

  for(lint i=h; i>=1; i--)
  for(lint j=w; j>=1; j--) {
    if(S[i][j] == '.') {
      dp[i][j-1][2] = dp[i][j][2] + 1;
      dp[i-1][j][3] = dp[i][j][3] + 1;
    } else {
      dp[i][j][2] = dp[i][j][3] = 0;
    }
  }

  lint dot = 0;
  for(lint i=1; i<=h; i++)
  for(lint j=1; j<=w; j++) {
    dot += S[i][j] == '.';
  }

  mint ans = 0;
  for(lint i=1; i<=h; i++)
  for(lint j=1; j<=w; j++) {
    lint count = 0;
    for(lint k=0; k<4; k++) count += dp[i][j][k];
    count = max(count-3, 0LL);
    ans += mint::pow(2, dot) - mint::pow(2, dot-count);
  }
  cout << ans << endl;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int MOD=1e9+7;
int D[2010][2010];
int E[2010][2010];

ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x %MOD;
    x=x*x %MOD;
    n/=2;
  }
  return ans;
}

int a;
int f(int i,int j){
  return ((modpow(2,D[i][j])-1+MOD)%MOD)*modpow(2,a-D[i][j])%MOD;
}

int main(){
  int h,w;
  cin>>h>>w;
  
  vector<string> A(h);
  rep(i,h) cin>>A[i];
  
  int cnt=0;
  rep(i,h){
    rep(j,w){
      if(A[i][j]=='#'){
        D[i][j]=0;
        cnt++;
      }
      else{
        if(j==0) D[i][j]=1;
        else D[i][j]=D[i][j-1]+1;
      }
    }
  }
  rep(i,h){
    for(int j=max(w-2,0);j>=0;j--){
      if(D[i][j]==0) continue;
      if(D[i][j]<D[i][j+1]) D[i][j]=D[i][j+1];
    }
  }

  rep(j,w){
    rep(i,h){
      if(A[i][j]=='#') E[i][j]=0;
      else{
        if(i==0) E[i][j]=1;
        else E[i][j]=E[i-1][j]+1;
      }
    }
  }
  rep(j,w){
    for(int i=max(h-2,0);i>=0;i--){
      if(E[i][j]==0) continue;
      if(E[i][j]<E[i+1][j]) E[i][j]=E[i+1][j];
    }
  }

  rep(i,h){
    rep(j,w){
      D[i][j]=max(D[i][j]+E[i][j]-1,0);
    }
  }

  a=h*w-cnt;
  ll ans=0;
  rep(i,h){
    rep(j,w){
      ans=(ans+f(i,j))%MOD;
    }
  }
  cout<<ans<<endl;
    
  return 0;
}