#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
const int mod = 1e9 + 7;
int n, m, l[N][N], r[N][N], u[N][N], d[N][N], two[N*N];
char s[N][N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	two[0] = 1;
	for(int i=1; i<=n*m; i++) two[i] = 2ll*two[i-1]%mod;
	for(int i=1; i<=n; i++) cin >> (s[i]+1);
	int k = 0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			if(s[i][j]=='.') k++;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			if(s[i][j]=='#') u[i][j] = 0, l[i][j] = 0;
			else u[i][j] = u[i-1][j] + 1, l[i][j] = l[i][j-1] + 1;
	for(int i=n; i>=1; i--)
		for(int j=m; j>=1; j--)
			if(s[i][j]=='#') d[i][j] = 0, r[i][j] = 0;
			else d[i][j] = d[i+1][j] + 1, r[i][j] = r[i][j+1] + 1;
	int ans = 0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
		{
			if(s[i][j]=='#') continue;
			int x = l[i][j] + r[i][j] - 1, y = u[i][j] + d[i][j] - 1;
			ans = (ans - two[k-1] + mod)%mod;
			ans = (ans - 1ll*two[k-x-y+1]*(two[x+y-2]-two[x-1]-two[y-1]+1)%mod + mod)%mod;
		}
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
		{
			if(s[i][j]=='#') continue;
			int x = r[i][j];
			ans = (ans + 1ll*x*(two[x]-1)%mod*two[k-x])%mod;
			j += r[i][j] - 1;
		}
	for(int j=1; j<=m; j++)
		for(int i=1; i<=n; i++)
		{
			if(s[i][j]=='#') continue;
			int y = d[i][j];
			ans = (ans + 1ll*y*(two[y]-1)%mod*two[k-y])%mod;
			i += d[i][j] - 1;
		}
	if(ans<0) ans += mod;
	cout << ans << '\n';
	return 0;
}
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H)cin >> S[i];
  vector<llvec> L(H+1, llvec(W+1, 0));
  vector<llvec> R(H+1, llvec(W+1, 0));
  vector<llvec> U(H+1, llvec(W+1, 0));
  vector<llvec> B(H+1, llvec(W+1, 0));
  rep(i, H){
    rep(j, W){
      U[i+1][j] = U[i][j] + 1;
      if(S[i][j]=='#')U[i+1][j]=0;
    }
  }
  rep(i, H){
    rep(j, W){
      B[H-i-1][j] = B[H-i][j] + 1;
      if(S[H-i-1][j]=='#')B[H-i-1][j]=0;
    }
  }
  rep(i, H){
    rep(j, W){
      L[i][j+1] = L[i][j] + 1;
      if(S[i][j]=='#')L[i][j+1]=0;
    }
  }
  rep(i, H){
    rep(j, W){
      R[i][W-j-1] = R[i][W-j] + 1;
      if(S[i][W-j-1]=='#')R[i][W-j-1]=0;
    }
  }
  ll m=0;
  rep(i, H)rep(j, W)if(S[i][j]=='.')m++;
  /*
  cerr << m << endl;
  rep(i, H){DUMP(k, L[i]);cerr << endl;}
  rep(i, H){DUMP(k, R[i]);cerr << endl;}
  rep(i, H){DUMP(k, U[i+1]);cerr << endl;}
  rep(i, H){DUMP(k, B[i]);cerr << endl;}*/
  ll ans = 0;
  rep(i, H){
    rep(j, W){
      if(S[i][j]=='.'){
        ll c = L[i][j+1]+U[i+1][j] + B[i][j] + R[i][j] - 3;
        ans = mod(ans + mod(modpow(2, m-c, MOD)*(modpow(2,c, MOD)-1), MOD), MOD);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
