#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (decltype(end) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(end) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;
template<int64_t M = 1000000007>
class ModInt {
public:
	ModInt() : val_(0) {};

	ModInt(int64_t val) {
		this->val_ = val;
		this->val_ %= M;
		while (this->val_ >= M) this->val_ -= M;
		while (this->val_ < 0)  this->val_ += M;
	}

	operator int64_t() const {
		return this->val_;
	}

	ModInt& operator += (int64_t val) {
		this->val_ += val;
		this->val_ %= M;
		while (this->val_ >= M) this->val_ -= M;
		while (this->val_ < 0) this->val_ += M;

		return *this;
	}

	ModInt& operator -= (int64_t val) {
		this->val_ -= val;
		this->val_ %= M;
		while (this->val_ >= M) this->val_ -= M;
		while (this->val_ < 0) this->val_ += M;

		return *this;
	}

	ModInt& operator *= (int64_t val) {
		this->val_ *= val;
		this->val_ %= M;

		return *this;
	}

	ModInt& operator /= (int64_t val) {
		ModInt v = ModInt::pow(val, M - 2);
		*this *= v;

		return *this;
	}

	ModInt operator + (int64_t v) const {
		ModInt ret = *this;
		return (ret += v);
	}

	ModInt operator - (int64_t v) const {
		ModInt ret = *this;
		return (ret -= v);
	}

	ModInt operator * (int64_t v) const {
		ModInt ret = *this;
		return (ret *= v);
	}

	ModInt operator / (int64_t v) const {
		ModInt ret = *this;
		return (ret /= v);
	}

	static ModInt pow(ModInt n, int64_t m) {
		if (m == 0) {
			ModInt ret(1);
			return ret;
		}
		if (m == 1) {
			return n;
		}

		ModInt v = pow(n, m / 2);
		ModInt ret = v * v;
		if (m & 1) {
			ret *= n;
		}
		return ret;
	}

	ostream& operator << (ostream& out) {
		out << this->val_;
		return out;
	}

private:
	int64_t val_;
};
bool gmap[2001][2001];
int  nmap[2001][2001];

ModInt <> val(int n, int m)
{
	ModInt<> s = 2;
	auto a = ModInt<>::pow(2, n);
	auto d = ModInt<>::pow(2, n - m);
	//cout << n << " " << m << endl;
	return a - d;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int h, w; cin >> h >> w;
	int g = 0;
	FOR_LT(i, 0, h) {
		string s; cin >> s;
		FOR_LT(j, 0, w) {
			if (s[j] == '#') {
				gmap[i][j] = true;
				g++;
			}
			else {
				nmap[i][j] = 1;
			}
		}
	}


	FOR_LT(i, 0, h) {
		int j = 0;
		int s = -1;
		while (j < w) {
			while (j < w && gmap[i][j]) j++;
			s = j;
			while (j < w && !gmap[i][j]) j++;
			if (s != -1) {
				int c = (j - s);
				//cout << c << endl;
				FOR_LT(k, s, j) {
					nmap[i][k] += c - 1;
					//cout << i << " " << k << " " << nmap[i][k] << endl;
				}
			}
			s = -1;
		}
	}

	FOR_LT(j, 0, w) {
		int i = 0;
		int s = -1;
		while (i < h) {
			while (i < h && gmap[i][j]) i++;
			s = i;
			while (i < h && !gmap[i][j]) i++;
			if (s != -1) {
				int c = (i - s);
				FOR_LT(k, s, i) {
					nmap[k][j] += c - 1;
				}
			}
			s = -1;
		}
	}

	ModInt<> ans = 0;
	FOR_LT(i, 0, h) {
		FOR_LT(j, 0, w) {
			ans += val(h * w - g, nmap[i][j]);
		}
	}
	cout << ans << endl;

	return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod ll(1e9+7)
#define inv ll(500000004)
ll exp(ll a,ll b)
{
	if(b==0)
	 return 1;
	if(b%2==0){
		return exp(a*a%mod,b/2);
	}
	return a*exp(a*a%mod,(b-1)/2)%mod;
}
int main()
{
	int h,w;
	cin>>h>>w;
	int cnt=0;
	vector<string>arr(h);
	for(int i=0; i<h; i++)
	 cin>>arr[i];
	vector<vector<int> >mtr1(h,vector<int>(w)),mtr2(h,vector<int>(w));
	for(int i=0; i<h; i++){
		int len=0;
		for(int j=0; j<w; j++){
			if(arr[i][j]=='#'){
				len=0;
			}
			else{
				len++;
				cnt++;
				mtr1[i][j]=len;
			}
		}
	}
	for(int i=0; i<h; i++){
		int num=0;
		for(int j=w-1; j>=0; j--){
			if(mtr1[i][j]>0){
			   num=max(num,mtr1[i][j]);
			   mtr1[i][j]=num;	
			}
			else
			 num=0;
		}
	}
	for(int i=0; i<w; i++){
		int len=0;
		for(int j=0; j<h; j++){
			if(arr[j][i]=='#')
			 len=0;
			else{
				len++;
				mtr2[j][i]=len;
			}
		}
	}
	for(int i=0; i<w; i++){
		int num=0;
		for(int j=h-1; j>=0; j--){
			if(mtr2[j][i]>0){
				num=max(num,mtr2[j][i]);
				mtr2[j][i]=num;
			}
			else
			 num=0;
		}
	}
	ll ans=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(arr[i][j]=='.'){
		      ll num1=mtr1[i][j]+mtr2[i][j]-1;
		      ll num2=cnt-num1;
			  ans=(ans+(exp(2,num1)-1+mod)*exp(2,num2)%mod)%mod;		
			}
		}
	}
	cout<<ans;
	return 0;
	
}