#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#define sz(x) ((int)(x).size())
#define mp make_pair
#define full(a) a.begin(), a.end()
#define pii pair<int, int>
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 3e5 + 5;

// printf("%.2f\n", value); digits after decimal
// 'a' - 97
// 'A' - 65

ll binpow(ll a, ll b) 
{
    a %= mod;
    ll res = 1;
    while (b > 0) 
    {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
    int h, w; cin >> h >> w;
    ll tidy = 0;
    vector<vector<char>> v(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> v[i][j];
            if (v[i][j] == '.') tidy++;
        }
    }
    ll all = binpow(2, tidy);
    ll c = 0;
    ll cnt_row = -1;
    vector<ll> col(w, -1);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (v[i][j] == '#')
            {
                cnt_row = -1;
                col[j] = -1;
                continue;
            }
            if (cnt_row == -1)
            {
                cnt_row++;
                for (int k = j; k < w; k++)
                {
                    if (v[i][k] == '#') break;
                    cnt_row++;
                }
            }
            if (col[j] == -1)
            {
                col[j]++;
                for (int k = i; k < h; k++)
                {
                    if (v[k][j] == '#') break;
                    col[j]++;
                }
            }
            ll num = cnt_row + col[j];
            num--;
            c += (all + mod - binpow(2, tidy - num));
            c %= mod;
        }
        cnt_row = -1;
    }
    cout << c;
    return 0;
}
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/10/10 20:03:44
 ************************************************************************/
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define pb push_back
#define pr pair<int,int>
#define fi first
#define se second
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int mod=1e9+7;
int n,m,dx[5]={0,0,-1,1},dy[5]={-1,1,0,0};
LL ans=0,num=0,l[2020][2020],r[2020][2020],u[2020][2020],d[2020][2020];
char s[2020][2020];
LL qpow(LL y){
	LL x=2,res=1;
	while(y){
		if(y&1) res=(res*x)%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	n=read(); m=read();
	For(i,1,n) scanf("%s",s[i]+1);
	For(i,1,n) For(j,1,m){
		num+=(s[i][j]=='.');
		if(s[i][j]=='.'){
			if(s[i-1][j]=='.') u[i][j]=u[i-1][j]+1;
			if(s[i][j-1]=='.') l[i][j]=l[i][j-1]+1;
		}
	}
	for(int i=n;i;--i) for(int j=m;j;--j)
		if(s[i][j]=='.'){
			if(s[i+1][j]=='.') d[i][j]=d[i+1][j]+1;
			if(s[i][j+1]=='.') r[i][j]=r[i][j+1]+1;
		}
	For(i,1,n) For(j,1,m)
		if(s[i][j]=='.'){
			LL tmp=1+l[i][j]+r[i][j]+u[i][j]+d[i][j];
			ans+=(qpow(tmp)-1ll)*qpow(num-tmp)%mod;
			ans%=mod;
		}
	printf("%lld\n",ans);
	return 0;
}
