#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

const ll mod = 1e9 + 7;
const int maxn = 2002;
char saveori[maxn][maxn];

ll ff[4100005];
void init(){
    ff[0] = 1;
    for(int i =1;i<=4000005;i++){
        ff[i] = ff[i - 1] * 2;
        ff[i] %= mod;
    }
}

int tor[maxn][maxn];
int tol[maxn][maxn];
int tou[maxn][maxn];
int tod[maxn][maxn];

void solve(){
    int n ,m;
    cin>>n>>m;
    for(int i =1;i<=n;i++){
        scanf("%s", saveori[i] + 1);
    }

    int tot = 0;
    for(int i =1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            tot += (saveori[i][j] == '.');
        }
    }

    for(int i =1;i<=n;i++){
        tol[i][0] = 0;
        for(int j = 1;j<=m;j++){
            if(saveori[i][j] == '.'){
                tol[i][j] = tol[i][j-1] + 1;
            }
            else{
                tol[i][j] = 0;
            }
        }
    }

    for(int i =1;i<=n;i++){
        tor[i][m+1] = 0;
        for(int j =m;j>=1;j--){
            if(saveori[i][j] == '.'){
                tor[i][j] = tor[i][j+1] + 1;
            }
            else{
                tor[i][j] = 0;
            }
        }
    }

    for(int j = 1;j<=m;j++){
        tou[int(0)][j] = 0;
        for(int i = 1;i<=n;i++){
            if(saveori[i][j] == '.'){
                tou[i][j] = tou[i-1][j] + 1;
            }
            else{
                tou[i][j] = 0;
            }
        }
    }

    for(int j = 1;j<=m;j++){
        tod[n+1][j] = 0;
        for(int i = n;i>=1;i--){
            if(saveori[i][j] == '.'){
                tod[i][j] = tod[i + 1][j] + 1;
            }
        }
    }

    int ans = 0;
    for(int i =1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            if(saveori[i][j] != '.')
                continue;
            ll nowcnt = tol[i][j] + tod[i][j] + tor[i][j] + tou[i][j];
            nowcnt-=3;
            ll nowans = (ff[nowcnt] - 1)* ff[tot - nowcnt];
            nowans %= mod;
            ans += nowans;
            ans %= mod;
        }
    }
    cout<<ans<<endl;
}

signed main() {
    //freopen("in.txt", "r", stdin);
    init();
    solve();
}

#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

template<typename T>
T pown(T b, ll e) {
    if(e == 0) return 1;
    T p = pown(b, e / 2);
    if(e % 2 == 0) return p * p;
    return p * p * b;
}

template<const int mod>
struct Intmod {
    ll a;
    Intmod(ll a = 0): a(((a % mod) + mod) % mod) {}

    Intmod operator-() const {return Intmod(-a);}

    Intmod& operator+=(const Intmod b) {
        if((a += b.a) >= mod) a -= mod;
        return *this;
    }
    Intmod& operator+=(const ll b) {
        if((a += b) >= Intmod(mod).a) a -= mod;
        return *this;
    }
    Intmod& operator-=(const Intmod b) {
        if((a -= b.a) < 0) a += mod;
        return *this;
    }
    Intmod& operator-=(const ll b) {
        if((a -= Intmod(b).a) < 0) a += mod;
        return *this;
    }
    Intmod& operator*=(const Intmod b) {
        (a *= b.a) %= mod;
        return *this;
    }
    Intmod& operator*=(const ll b) {
        (a *= Intmod(b).a) %= mod;
        return *this;
    }

    template<typename T> Intmod operator+(const T b) const {return Intmod(*this) += b;}
    template<typename T> Intmod operator-(const T b) const {return Intmod(*this) -= b;}
    template<typename T> Intmod operator*(const T b) const {return Intmod(*this) *= b;}

    // Valid for prime mod. pown() needs to be included.
    int i = 0;
    Intmod inv() {
        if(a == 0) throw "Inverse of zero does not exist.";
        if(!i) i = pown(*this, mod - 2).a;
        return Intmod(i);
    }
    Intmod& operator/=(const Intmod b) {return *this *= b.inv();}
    Intmod& operator/=(const ll b) {return *this *= Intmod(b).inv();}
    template<typename T> Intmod operator/(const T b) const {return Intmod(*this) /= b;}
};
template<const int mod> Intmod<mod> operator+(const ll b, Intmod<mod> a) {return a += b;}
template<const int mod> Intmod<mod> operator-(const ll b, Intmod<mod> a) {return a -= b;}
template<const int mod> Intmod<mod> operator*(const ll b, Intmod<mod> a) {return a *= b;}
template<const int mod> Intmod<mod> operator/(const ll b, Intmod<mod> a) {return a /= b;} //Valid for prime mod.

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    const int MOD = 1000000007;

    int h, w, k = 0;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) {
        cin >> s.at(i);
        rep(j, w) if(s.at(i).at(j) == '.') k++;
    }

    vector<vector<int>> eh(h, vector<int>(w)), ew(h, vector<int>(w));
    int temp = 0;
    rep(i, h) {
        temp = 0;
        rep(j, w + 1) {
            if(j == w || s.at(i).at(j) == '#') {
                for(int jt = temp; jt < j; ++jt) ew.at(i).at(jt) = j - temp;
                temp = j + 1;
            }
        }
    }
    rep(i, w) {
        temp = 0;
        rep(j, h + 1) {
            if(j == h || s.at(j).at(i) == '#') {
                for(int jt = temp; jt < j; ++jt) eh.at(jt).at(i) = j - temp;
                temp = j + 1;
            }
        }
    }

    Intmod<MOD> bi = 2;
    Intmod<MOD> ans = pown(bi, k);
    ans *= k;

    rep(i, h) {
        rep(j, w) {
            if(s.at(i).at(j) == '.') ans -= pown(bi, k + 1 - eh.at(i).at(j) - ew.at(i).at(j));
        }
    }

    printf("%lld\n", ans.a);

    return 0;
}