// E - Lamps
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define irep(i,s) for(int i=(int)(s);i>=0;--i)

int main(){
	int h, w; cin>>h>>w;
	int k = h * w;
	vector<string> S(h);
	rep(i, h){
		cin>>S[i];
		rep(j, w) if(S[i][j] == '#') --k;
	}

	vvi X(h, vi(w+1));
	rep(i, h){
		rep(j, w) if(S[i][j] == '.') X[i][j+1] += X[i][j] + 1;
		int mx = 0;
		irep(j, w) mx = X[i][j]? X[i][j] = max(mx, X[i][j]): 0;
	}

	vvi Y(h+1, vi(w));
	rep(j, w){
		rep(i, h) if(S[i][j] == '.') Y[i+1][j] += Y[i][j] + 1;
		int mx = 0;
		irep(i, h) mx = Y[i][j]? Y[i][j] = max(mx, Y[i][j]): 0;
	}

	int M = 1000000007;
	vector<int> pow2(k+1);
	pow2[0] = 1; rep(i, k) pow2[i+1] = pow2[i] * 2 % M;

	ll ans = (ll)k * pow2[k] % M;
	rep(i, h) rep(j, w){
		if(S[i][j] == '.'){
			ans -= pow2[k - (X[i][j+1] + Y[i+1][j] - 1)];
			ans %= M;
		}
	}
	cout<< (ans + M) % M <<endl;
}

#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  2e3+5;
const ll   M     =  4e6+5;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll n, m, p[N][N][4], p2[M];
string s[N];

void solve(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> s[i]; s[i] = '#' + s[i] + '#';
	}
	s[0] = s[n+1] = string(m+2,'#');
	int no = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '#') continue;
			no++;
		}
	}
	for(int i = 1; i <= n; i++){
		int prv = 0;
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '#') prv = j;
			else {
				p[i][j][0] = prv;
			}
		}
		prv = m+1;
		for(int j = m; j >= 1; j--){
			if(s[i][j] == '#') prv = j;
			else {
				p[i][j][1] = prv;
			}
		}
	}
	for(int i = 1; i <= m; i++){
		int prv = 0;
		for(int j = 1; j <= n; j++){
			if(s[j][i] == '#') prv = j;
			else {
				p[j][i][2] = prv;
			}
		}
		prv = n+1;
		for(int j = n; j >= 1; j--){
			if(s[j][i] == '#') prv = j;
			else {
				p[j][i][3] = prv;
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '#') continue;
			int tot = p[i][j][1] - p[i][j][0] + p[i][j][3] - p[i][j][2] - 3;
			ll res = (p2[no] - p2[no-tot] + mod) % mod;
			ans = (ans + res) % mod;
		}
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	p2[0] = 1;
	for(int i = 1; i < M; i++){
		p2[i] = p2[i-1] * 2 % mod;
	}
	int test = 1;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}