#include <bits/stdc++.h>

using namespace std;

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) {
				ret *= a;
			}
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 1000000007;
using mint = modint<MOD>;

template <class T> T fastpow(T a, long long p) {
	T tmp = a;
	T ret = 1;
	while (p) {
		if (p & 1) ret *= tmp;
		p >>= 1;
		tmp = tmp * tmp;
	}
	return ret;
}

class Solution {
public:
	void solve() {
		int h, w;
		cin >> h >> w;
		vector<string> ss(h);
		for (int i = 0; i < h; i++) cin >> ss[i];
		vector<vector<int>> sx(h, vector<int>(w, 0));
		vector<vector<int>> sy(h, vector<int>(w, 0));
		int cv = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (ss[i][j] == '.') {
					cv++;
					if (i != 0)
						sy[i][j] = sy[i - 1][j] + 1;
					else
						sy[i][j] = 1;
					if (j != 0)
						sx[i][j] = sx[i][j - 1] + 1;
					else
						sx[i][j] = 1;
				}
			}
		}
		for (int i = h - 1; i >= 0; i--) {
			for (int j = w - 1; j >= 0; j--) {
				if (ss[i][j] == '.') {
					if (i != h - 1 && ss[i + 1][j] == '.') sy[i][j] = sy[i + 1][j];
					if (j != w - 1 && ss[i][j + 1] == '.') sx[i][j] = sx[i][j + 1];
				}
			}
		}
		mint ans = fastpow(mint{2}, cv) * cv;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (ss[i][j] == '.') {
					ans -= fastpow(mint{2}, cv - sx[i][j] - sy[i][j] + 1);
				}
			}
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>

using namespace std;

//#define pb push_back
//#define mp make_pair
#define fi first
#define se second

typedef long long ll;

//#define rep(_i,iv,n) for(int _i=(int)(iv);_i<(int)(n);++_i)
#define rep0(_i,n) for(int _i=0;_i<(int)(n);++_i)
//#define REP(_i,iv,_l,n) for(int _i=(int)(iv),_l=(int)(n);_i<_l;++_i)
#define REP0(_i,_l,n) for(int _i=0,_l=(int)(n);_i<_l;++_i)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;

typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<ll> vll;
typedef vector<vll > vvll;

#define INF 1<<30

td pair<int, int > pii;
td priority_queue<pii,vector<pii>,greater<pii> > pq;

#define mod7 1000000007

long long modpow(long long a, long long n, long long mod) {//O(log2(n))
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(int argc, const char * argv[]) {
    int H,W;
    cin>>H>>W;
    vvb room(H,vb(W));
    int K=0;
    rep0(i, H){
        string str;
        cin>>str;
        rep0(j, W){
            room[i][j]=str[j]=='.';
            if(room[i][j]){
                ++K;
            }
        }
    }//4e6
    
    vvi rowCont(H,vi(W,0));
    rep0(i,H){
        rep0(j, W){
            if(room[i][j]){
                int count=0,j1=j;
                while(j1<W&&room[i][j1]){
                    ++count;
                    ++j1;
                }
                while(j<j1){
                    rowCont[i][j]=count;
                    ++j;
                }
            }
        }
    }
    
    vvi colCont(H,vi(W,0));
    rep0(j, W){
        rep0(i,H){
            if(room[i][j]){
                int count=0,i1=i;
                while(i1<H&&room[i1][j]){
                    ++count;
                    ++i1;
                }
                while(i<i1){
                    colCont[i][j]=count;
                    ++i;
                }
            }
        }
    }
    
    ll X=(modpow(2,K, mod7)*K)%mod7;
    
//    cout<<"x="<<X<<endl;
    rep0(i, H){//H*W*(4*H*W+log2(K-T))
        rep0(j, W){
            if(room[i][j]){
                int T=colCont[i][j]+rowCont[i][j]-1;
//                cout<<i<<","<<j<<":"<<T<<endl;
                X-=modpow(2, K-T, mod7);
                X%=mod7;
                if(X<0){
                    X+=mod7;
                }
            }
        }
    }
    
    cout<<X<<endl;
    
    
    return 0;
}
