#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define mod 1000000007
#define ll long long
using namespace std;
const int maxx=600010;
ll t,n,m;
ll ans=0,total=0,sum=0,cnt=0,l=1,r=1;
ll a[maxx],x[maxx],y[maxx];
ll bjl[3111][3111],bjr[3111][3111];
char c[3111][3111];
ll ksm(ll x,ll p)
{
	ll res=1;
	while(p)
	{
		if(p&1)res=res*x%mod;
		x=x*x%mod;
		p>>=1;
	}
	return res;
}
int main()
{
	cin>>n>>m;
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
		{
			cin>>c[i][j];
			if(c[i][j]=='.')total++;
		}
	for(register int i=1;i<=n;i++)c[i][m+1]='#';
	for(register int i=1;i<=m;i++)c[n+1][i]='#'; 
	for(register int i=1;i<=n+1;i++)
	{
		l=1;
		for(register int j=1;j<=m+1;j++)
		{
			if(c[i][j]=='#')
			{
				for(register int k=l;k<j;k++)bjl[i][k]=x[i];
				x[i]=0,l=j+1;
			}
			else x[i]++;
		}
	}
	for(register int j=1;j<=m+1;j++)
	{
		r=1;
		for(register int i=1;i<=n+1;i++)
		{
			if(c[i][j]=='#')
			{
				for(register int k=r;k<i;k++)bjr[k][j]=y[j];
				r=i+1;
				y[j]=0;
			}
			else y[j]++;
		}
	}
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
		{
			if(c[i][j]=='.')
			{
				sum=bjl[i][j]+bjr[i][j]-1;
				ans=(ans+(ksm(2,sum)%mod-1+mod)%mod*ksm(2,total-sum)%mod)%mod;
			}
		}
	printf("%lld",ans);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define all(v) v.begin(),v.end()
#define  mat vector<vector<ll>>
#define el cout<<'\n';
const ll N=2e3+5;
ll lf[N][N];
ll rt[N][N],up[N][N],down[N][N];


ll pw(ll k){
    ll a=2;
    ll ans=1;
    while(k){
        if(k&1){
        ans*=a;
        ans%=mod;
        }
        
        a*=a;
        a%=mod;
        k>>=1;
    }
    return ans;
    }
void solve(){
  ll n,m,k;
  cin>>n>>m;
  int ar[n][m];
  k=0;
  fr(i,0,n){
      fr(j,0,m){
     char ch;
     cin>>ch;
     ar[i][j]=(ch=='.'?1:0);
     k+=ar[i][j];
      }
  }

  for(int i=0;i<n;i++){
      fr(j,0,m){
          if(j==0) lf[i][j]=ar[i][j];
           else if(ar[i][j]==1)
           lf[i][j]+=lf[i][j-1]+1;
           
           if(i==0)
           up[i][j]=ar[i][j];
           else if(ar[i][j])
           up[i][j]=up[i-1][j]+1;
           
      }
  }
   
  for(int i=n-1;i>=0;i--){
      for(int j=m-1;j>=0;j--){
    if(j==m-1)
        rt[i][j]=ar[i][j];
    else if(ar[i][j]==1)
        rt[i][j]=rt[i][j+1]+1;
      


      if(i==n-1)
        down[i][j]=ar[i][j];
      else if(ar[i][j]==1)
        down[i][j]=down[i+1][j]+1;
  }
  }
//   d1(k)
  
  ll ans=k*pw(k)%mod;
  ll ng=0;
  fr(i,0,n){
      fr(j,0,m){
          if(ar[i][j]==1){
         ll l=0,r=0,u=0,d=0;
         if(j!=0)
         l=lf[i][j-1];
         if(j!=m-1)
         r=rt[i][j+1];
         if(i!=0)
         u=up[i-1][j];
         if(i!=n-1)
         d=down[i+1][j];
         ll tot=l+r+u+d+1;
        //  d1(tot);
         ng+=pw(k-tot);
         
         ng%=mod;
         
         
          }
         
      }
  }  
  cout<<(ans-ng+mod)%mod;
  

}
int main(){
 boost
 ll t=1; 

// cin>>t;

    while(t--){
      solve();
      el
        }
    return 0;
}
