#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_HW = 2005;
const ll MOD = 1e9+7;
char c[MAX_HW][MAX_HW];
ll cntu[MAX_HW][MAX_HW],cntd[MAX_HW][MAX_HW],cntl[MAX_HW][MAX_HW],cntr[MAX_HW][MAX_HW];
ll mypow2[MAX_HW*MAX_HW];

void init()
{
	mypow2[0] = 1;
	rep(i,MAX_HW*MAX_HW-1)
	{
		mypow2[i+1] = mypow2[i] * 2 % MOD;
	}
}

int main()
{
	init();
	int H,W;
	cin >> H >> W;
	ll cnt = 0;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> c[i][j];
			if (c[i][j] == '.') cnt++;
		}
	}

	ll temp = 0;
	rep(i,H)
	{
		temp = 0;
		rep(j,W)
		{
			if (c[i][j] == '.') temp++;
			else temp = 0;
			cntl[i][j] = temp;
		}
	}
	temp = 0;
	rep(i,H)
	{
		temp = 0;
		for (int j = W-1; j >= 0; --j)
		{
			if (c[i][j] == '.') temp++;
			else temp = 0;
			cntr[i][j] = temp;
		}
	}
	temp = 0;
	rep(j,W)
	{
		temp = 0;
		rep(i,H)
		{
			if (c[i][j] == '.') temp++;
			else temp = 0;
			cntu[i][j] = temp;
		}
	}
	temp = 0;
	rep(j,W)
	{
		temp = 0;
		for (int i = H-1; i >= 0; --i)
		{
			if (c[i][j] == '.') temp++;
			else temp = 0;
			cntd[i][j] = temp;
		}
	}

	/*
	rep(i,H)
	{
		rep(j,W)
		{
			cout << cntr[i][j] << " ";
		}
		cout << endl;
	}
	*/

	ll ans = 0;
	rep(i,H)
	{
		rep(j,W)
		{
			if (c[i][j] == '.')
			{
				temp = cntr[i][j] + cntl[i][j] + cntd[i][j] + cntu[i][j] - 3;
				ll temp2 = ((mypow2[temp] - 1 + MOD) % MOD) * mypow2[cnt-temp] % MOD;
				ans = (ans + temp2) % MOD;
				//cout << temp << " " << ans << endl;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
#include<iostream>
#define ll long long
//我把题目读成求周长段数的还有救嘛…… 
using namespace std;
bool s[11][11];
bool pd(ll i,ll j){
	ll he=s[i][j]+s[i][j+1]+s[i+1][j]+s[i+1][j+1];
	if(he==1 or he==3) return 1;
	else return 0;
}
int main(){
	ll h,w,i,j,sl=0;
	char sr;
	cin>>h>>w;
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			cin>>sr;
			if(sr=='.') s[i][j]=0;
			else s[i][j]=1;
		}
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(pd(i,j)) sl++;
		}
	}
	cout<<sl;
    return 0;
}