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

const int MOD = 1e9+7;

template<uint_fast64_t Modulus = MOD>
struct Modint {
  using u64 = uint_fast64_t;
  u64 a;

  constexpr Modint(const u64 x = 0) noexcept : a(x % Modulus) {}

  constexpr Modint operator+(const Modint rhs) const noexcept {
    return Modint(*this) += rhs;
  }
  constexpr Modint operator-(const Modint rhs) const noexcept {
    return Modint(*this) -= rhs;
  }
  constexpr Modint operator*(const Modint rhs) const noexcept {
    return Modint(*this) *= rhs;
  }
  constexpr Modint operator/(const Modint rhs) const noexcept {
    return Modint(*this) /= rhs;
  }

  constexpr Modint &operator+=(const Modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) a -= Modulus;
    return *this;
  }
  constexpr Modint &operator-=(const Modint rhs) noexcept {
    if (a < rhs.a) a += Modulus;
    a -= rhs.a;
    return *this;
  }
  constexpr Modint &operator*=(const Modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr Modint &operator/=(Modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp & 1) *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }

  Modint pow(u64 t) const {
    if (!t) return 1;
    Modint x = pow(t>>1);
    x *= x;
    if (t&1) x *= *this;
    return x;
  }

  explicit operator bool() const {
    return a;
  }

  friend ostream &operator<<(ostream &os, const Modint &m) {
    return os << m.a;
  }
};

using mint = Modint<>;

void solve() {
  int h, w; cin >> h >> w;
  vector<string> g(h);
  for(auto &s : g) cin >> s;

  vector<vector<bool>> b(h, vector<bool>(w, false));
  int sum = 0;
  for(int i=0; i<h; ++i) {
    for(int j=0; j<w; ++j) {
      if(g[i][j] == '.') {
        ++sum;
      } else {
        b[i][j] = true;
      }
    }
  }

  vector<vector<int>> cnt(h, vector<int>(w, -1));
  for(int i=0; i<h; ++i) {
    int prev = 0;
    for(int j=0; j<=w; ++j) {
      if(j == w || b[i][j]) {
        for(int k=prev; k<j; ++k) {
          cnt[i][k] += j - prev;
        }
        prev = j+1;
      }
    }
  }
  for(int j=0; j<w; ++j) {
    int prev = 0;
    for(int i=0; i<=h; ++i) {
      if(i == h || b[i][j]) {
        for(int k=prev; k<i; ++k) {
          cnt[k][j] += i - prev;
        }
        prev = i+1;
      }
    }
  }

  vector<mint> two(sum+1);
  two[0] = 1;
  for(int i=0; i<sum; ++i) {
    two[i+1] = two[i] * 2;
  }

  mint ans = two[sum] * sum;
  for(int i=0; i<h; ++i) {
    for(int j=0; j<w; ++j) {
      if(cnt[i][j] > 0) {
        ans -= two[sum - cnt[i][j]];
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}

#include<bits/stdc++.h>
typedef int64_t i64;
typedef long double f128;
using namespace std;

template<typename T>
void scan(T& n)
{
  cin>>n;
  return;
}

void scan()
{
  return;
}

template<typename T,class... Args>
void scan(T& n,Args&... args)
{
  scan(n);
  scan(args...);
  return;
}

template<typename T>
void scan_array(T start,T end)
{
  T now=start;
  for(;now!=end;++now)
  {
    scan(*now);
  }
  return;
}

template<typename T>
void print(T n)
{
  cout<<n;
  return;
}

template<typename T>
void println(T n)
{
  print(n);
  print('\n');
  return;
}

template<typename T,class... Args>
void println(T n,Args... args)
{
  print(n);
  print(' ');
  println(args...);
  return;
}

template<typename T>
void print_array(T start,T end)
{
  T now=start;
  print(*now);
  ++now;
  for(;now!=end;++now)
  {
    print(' ');
    print(*now);
  }
  print('\n');
  return;
}

i64 pow_mod(i64 a,i64 n,i64 mod)
{
  i64 res=1,now=a;
  while(n)
  {
    if(n&1)
    {
      res=res*now%mod;
    }
    now=now*now%mod;
    n>>=1;
  }
  return res;
}

i64 inv_mod(i64 a,i64 mod)
{
  return pow_mod(a,mod-2,mod);
}

int main()
{
  i64 constexpr mod=1000000007;
  i64 H,W;
  scan(H,W);
  vector<string> S(H);
  scan_array(S.begin(),S.end());
  i64 K=0;
  for(i64 i=0;i<H;++i)
  {
    for(i64 j=0;j<W;++j)
    {
      if(S[i][j]=='.')
      {
        K+=1;
      }
    }
  }
  vector<vector<i64>> sum1(H,vector<i64> (W)),sum2(H,vector<i64> (W));
  for(int i=0;i<H;++i)
  {
    int start=-1,len=0;
    for(int j=0;j<W;++j)
    {
      if(S[i][j]=='#')
      {
        if(start==-1)
        {
          continue;
        }
        for(int k=start;k<j;++k)
        {
          sum1[i][k]=len;
        }
        start=-1;
        len=0;
        continue;
      }
      if(start==-1)
      {
        start=j;
      }
      len+=1;
    }
    if(start==-1)
    {
      continue;
    }
    for(int k=start;k<W;++k)
    {
      sum1[i][k]=len;
    }
  }
  for(int j=0;j<W;++j)
  {
    int start=-1,len=0;
    for(int i=0;i<H;++i)
    {
      if(S[i][j]=='#')
      {
        if(start==-1)
        {
          continue;
        }
        for(int k=start;k<i;++k)
        {
          sum2[k][j]=len;
        }
        start=-1;
        len=0;
        continue;
      }
      if(start==-1)
      {
        start=i;
      }
      len+=1;
    }
    if(start==-1)
    {
      continue;
    }
    for(int k=start;k<H;++k)
    {
      sum2[k][j]=len;
    }
  }
  vector<vector<i64>> vec(H,vector<i64> (W));
  for(int i=0;i<H;++i)
  {
    for(int j=0;j<W;++j)
    {
      vec[i][j]=K-(sum1[i][j]+sum2[i][j]-1);
    }
  }
  i64 sum=0;
  for(int i=0;i<H;++i)
  {
    for(int j=0;j<W;++j)
    {
      if(vec[i][j]==K+1)
      {
        continue;
      }
      sum+=pow_mod(2,vec[i][j],mod);
    }
  }
  sum%=mod;
  i64 ans=pow_mod(2,K,mod)*K%mod-sum;
  ans=(ans%mod+mod)%mod;
  println(ans);
}