#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
 
cs int G = 3;
cs int ff = 2e6 + 1;
cs int inf = 1e18 + 1;
cs int base = 2333;
cs int M = 1e9 + 7;

int ksm(int a, int b) { return (b % 2 == 1 ? a : 1) * (b ? ksm(a * a % M, b / 2) : 1) % M; }
int x, y, a[2333][2333], b[2333][3333], l[ff], r[ff], Ans, ss;
char s;
void init()
{
	cin >> x >> y;
	rep(i, 1, x)
		rep(j, 1, y)
			cin >> s, a[i][j] = (s != '#'), ss += a[i][j];
	rep(i, 1, x)
	{
		int las = 0, s = 0;
		rep(j, 1, y)
		{
			if(a[i][j]) b[i][j] += s, s ++;
			else s = 0;
			
		}
		s = 0;
		sep(j, y, 1)
		{
			if(a[i][j]) b[i][j] += s, s ++;
			else s = 0;
			
		}
	}
//	rep(i, 1, x) rep(j, 1, y) cout <<b[i][j] << " "; cout << "\n";
	rep(i, 1, y)
	{
		int las = 0, s = 0;
		rep(j, 1, x)
		{
		//	cout << j << " " << i << " " <<s << "\n";
			if(a[j][i]) b[j][i] += s, s ++;
			else s = 0;
		//	
		}
		s = 0;
		sep(j, x, 1)
		{
			if(a[j][i]) b[j][i] += s, s ++;
			else s = 0;
		//	cout <<b[j][i] << "\n";
		}
	}
	rep(i, 1, x)
		rep(j, 1, y)
		{
			if(!a[i][j]) continue;
		//	cout <<b[i][j] << " ";
			int sum = b[i][j] + a[i][j];
		//	cout << sum <<"\n";
			Ans = Ans + ksm(2, ss) - ksm(2, ss - sum);
			Ans = (Ans % M + M) % M;
		}
	cout << Ans;
} 
signed main()
{
//	freopen("1.out", "w", stdout);
	int Ts = 1;
//	cin >> Ts;
	while(Ts--)
		init();
}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll calc[4000001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    calc[0]=1ll;
    for(int i=1;i<=4000000;i++)
        calc[i]=(calc[i-1]*2ll)%MOD;
    //cin>>t;
    while(t--){
        int h,w;
        cin>>h>>w;
        string s[h];
        for(int i=0;i<h;i++)
            cin>>s[i];
        int k=0;
        int dp[h][w];
        int dp1[h][w];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j]=='.'){
                    int l=j;
                    while(l<w&&s[i][l]=='.')
                        l++;
                    for(int p=j;p<l;p++)
                        dp[i][p]=l-j;
                    k+=l-j;
                    j=l-1;
                }
            }
        }
        for(int j=0;j<w;j++){
            for(int i=0;i<h;i++){
                if(s[i][j]=='.'){
                    int l=i;
                    while(l<h&&s[l][j]=='.')
                        l++;
                    for(int p=i;p<l;p++)
                        dp1[p][j]=l-i;
                    i=l-1;
                }
            }
        }
        ll ans=0ll;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j]=='.'){
                    int val=dp[i][j]+dp1[i][j]-1;
                    ans=(ans+((calc[k]-calc[k-val]+MOD)%MOD))%MOD;
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}