#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
  if ((x += a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator-=(const mint a) {
  if ((x += mod-a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t>>1);
  a *= a;
  if (t&1) a *= *this;
  return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint mpow(mint x, ll y){
  if(y == 0){
    return 1;
  }
  if(y % 2 == 0){
    mint a = mpow(x, y / 2);
    return a * a;
  }
  else{
    mint a = mpow(x, y / 2);
    return a * a * x;
  }
}

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H){
      cin >> S.at(i);
    }
    mint ans = 0;
    vector<vector<ll>> clut_r(H, vector<ll>(1, -1));
    rep(i, H){
      rep(j, W){
        if(S.at(i).at(j) == '#'){
          clut_r.at(i).push_back(j);
        }
      }
      clut_r.at(i).push_back(W);
    }
    vector<vector<ll>> clut_c(W, vector<ll>(1, -1));
    rep(i, W){
      rep(j, H){
        if(S.at(j).at(i) == '#'){
          clut_c.at(i).push_back(j);
        }
      }
      clut_c.at(i).push_back(H);
    }
    vector<vector<ll>> space(H, vector<ll>(W, 0)); //各マスを照らす照明を置けるマスの数
    rep(i, H){
      ll p = 0;
      rep(j, W){
        ll left = clut_r.at(i).at(p);
        ll right = clut_r.at(i).at(p+1);
        if(S.at(i).at(j) == '#'){
          p++;
          continue;
        }
        space.at(i).at(j) += right-left-1;
      }
    }
    rep(i, W){
      ll p = 0;
      rep(j, H){
        ll left = clut_c.at(i).at(p);
        ll right = clut_c.at(i).at(p+1);
        if(S.at(j).at(i) == '#'){
          p++;
          continue;
        }
        space.at(j).at(i) += right-left-2;
      }
    }
    ll K = 0;
    rep(i, H){
      rep(j, W){
        if(S.at(i).at(j) == '.'){
          K++;
        }
      }
    }
    rep(i, H){
      rep(j, W){
        if(S.at(i).at(j) == '.'){
          ans += mpow(2, K) - mpow(2, K-space.at(i).at(j)); //全体 - (i,j)を照らさない置き方
        }
      }
    }
    cout << ans << endl;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e3+5,MOD=1e9+7; 
int n,m,tot,ans,k;
int u[N][N],d[N][N],l[N][N],r[N][N]; 
char str[N][N];

inline int pow(int a,int n)
{
	int res=1;
	while (n)
	{
		if (n&1) res=res*a%MOD;
		a=a*a%MOD;
		n>>=1;
	}
	return res;
}

signed main(){
	scanf("%lld%lld",&n,&m);
	for (register int i=1; i<=n; ++i) scanf("%s",str[i]+1);
	for (register int i=1; i<=n; ++i)
	for (register int j=1; j<=m; ++j)
	if (str[i][j]=='.') u[i][j]=u[i-1][j]+1,l[i][j]=l[i][j-1]+1;
	else u[i][j]=l[i][j]=0;
	for (register int i=n; i>=1; --i)
	for (register int j=m; j>=1; --j)
	if (str[i][j]=='.') d[i][j]=d[i+1][j]+1,r[i][j]=r[i][j+1]+1;
	
	for (register int i=1; i<=n; ++i)
	for (register int j=1; j<=m; ++j) if (str[i][j]=='.') k++;
	ans=k*pow(2ll,k)%MOD;
	for (register int i=1; i<=n; ++i)
	for (register int j=1; j<=m; ++j)
	if (str[i][j]=='.')
	{
		tot=l[i][j]+r[i][j]+u[i][j]+d[i][j]-4+1;
		ans=((ans-pow(2ll,k-tot))%MOD+MOD)%MOD;
	}
	printf("%lld\n",ans);
return 0;
}