#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

template< typename T >
T mod_pow(T x, T n, const T &p) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h + 2);
    vector<vector<ll>> cross(h + 2, vector<ll>(w+2));
    s[0] = string(w + 2, '#');
    s[h+1] = string(w + 2, '#');
    for (int i = 1; i <= h; ++i) {
        cin >> s[i];
        s[i] = '#' + s[i] + '#';
    }
    ll l = 0;
    for (int i = 1; i <= h; ++i) {
        ll temp = 0;
        for (int j = 0; j <= w; ++j) {
            if (s[i][j] == '.') {
                cross[i][j] += temp - 1;
                l++;
                continue;
            }
            temp = 0;
            for (int k = j + 1; k <= w; ++k) {
                if (s[i][k] == '.') temp++;
                else break;
            }
        }
    }
    for (int j = 1; j <= w; ++j) {
        ll temp = 0;
        for (int i = 0; i <= h; ++i) {
            if (s[i][j] == '.') {
                cross[i][j] += temp;
                continue;
            }
            temp = 0;
            for (int k = i + 1; k <= h; ++k) {
                if (s[k][j] == '.') temp++;
                else break;
            }
        }
    }
    ll result = 0;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            result += (mod_pow(2ll, cross[i][j], mod) - 1) * (mod_pow(2ll, l - cross[i][j], mod)) % mod;
            result %= mod;
        }
    }
    cout << result << endl;
}

#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define ld double
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define MAXIM 4000001
ll mod = 1e9 + 7;

vector<vll> v,row,col;
vll pw2(MAXIM);

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

void calc(){
    pw2[0] = 1;
    rep(i,1,MAXIM){
        pw2[i] = pw2[i - 1]*2;
        while(pw2[i] > mod) pw2[i] -= mod;
    }
}


void solve(){
    ll n,m;
    cin >> n >> m;
    v.assign(n,vll(m));
    row.assign(n,vll(1,-1)),
    col.assign(m,vll(1,-1));
    ll dot = 0;
    rep(i,0,n){
        rep(j,0,m){
            char c;
            cin >> c;
            if(c == '.'){ 
                v[i][j] = 1;
                dot++;
            }
            else{ 
                v[i][j] = 0;
                row[i].pb(j);
                col[j].pb(i);
            }
        }
    }
    rep(i,0,n) row[i].pb(m);
    rep(j,0,m) col[j].pb(n);
    ll ans = 0;
    rep(i,0,n){
        rep(j,0,m){
            if(v[i][j] == 0) continue;
            ll x1 = upper_bound(all(row[i]),j) - row[i].begin();
            ll x2 = upper_bound(all(col[j]),i) - col[j].begin();
            ll temp = (row[i][x1] - row[i][x1 - 1] - 1) + (col[j][x2] - col[j][x2 - 1] - 1) - 1;
            ll t1 = (pw2[temp] - 1 + mod);
            ll t2 = pw2[dot - temp];
            ll t = t1*t2;
            if(t > mod) t %= mod;
            ans += t;
            if(ans > mod) ans -= mod;
        }
    }
    cout << ans << br;
}
	
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
 
	ll t = 1;
    calc();
	// cin >> t;
	rep(i,0,t){
        // cout << "Case #" << i + 1 << ": ";
		solve();
	}
 
}	