#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

template<int M>
class ModInt {
   public:
    ll value;
    constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; }
    constexpr ModInt pow(ll n) const { if (!n) return 1; ModInt a = pow(n >> 1); a *= a; if (n & 1) a *= *this; return a; }
    constexpr ModInt inv() const { return this->pow(M - 2); }
    constexpr ModInt operator + (const ModInt &rhs) const { return ModInt(*this) += rhs; };
    constexpr ModInt operator - (const ModInt &rhs) const { return ModInt(*this) -= rhs; };
    constexpr ModInt operator * (const ModInt &rhs) const { return ModInt(*this) *= rhs; };
    constexpr ModInt operator / (const ModInt &rhs) const { return ModInt(*this) /= rhs; };
    constexpr ModInt &operator += (const ModInt &rhs) { value += rhs.value; if (value >= M) value -= M; return *this; };
    constexpr ModInt &operator -= (const ModInt &rhs) { value -= rhs.value; if (value <  0) value += M; return *this; };
    constexpr ModInt &operator *= (const ModInt &rhs) { value = value * rhs.value % M; return *this; };
    constexpr ModInt &operator /= (const ModInt &rhs) { return (*this) *= rhs.inv(); };
    constexpr bool operator == (const ModInt &rhs) { return value == rhs.value; }
    constexpr bool operator != (const ModInt &rhs) { return value != rhs.value; }
    friend ostream &operator << (ostream &os, const ModInt &rhs) { os << rhs.value; return os; }
};

using mint = ModInt<MOD>;

int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H);
    REP(i, 0, H) cin >> S[i];

    int tot = 0;
    vector<vector<int>> R(H, vector<int>(W, 0)), C(H, vector<int>(W, 0));
    REP(i, 0, H) REP(j, 0, W) {
        if (S[i][j] == '#') continue;
        R[i][j] = 1 + ((j > 0) ? R[i][j - 1] : 0);
        C[i][j] = 1 + ((i > 0) ? C[i - 1][j] : 0);
        tot++;
    }
    REP(i, 0, H) for (int j = W - 1; j > 0; j--) if (R[i][j] && R[i][j - 1]) R[i][j - 1] = R[i][j];
    REP(j, 0, W) for (int i = H - 1; i > 0; i--) if (C[i][j] && C[i - 1][j]) C[i - 1][j] = C[i][j];

    mint ans = 0;
    REP(i, 0, H) REP(j, 0, W) {
        if (S[i][j] == '#') continue;
        // cout << "#(" << i << "," << j << ") : " << R[i][j] << ", " << C[i][j] << endl; 
        int cnt = R[i][j] + C[i][j] - (R[i][j] && C[i][j]);
        ans += (mint(2).pow(cnt) - 1) * mint(2).pow(tot - cnt);
    }
    cout << ans << endl;

    return 0;
}
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define MOD 1000000007
//https://flex.phys.tohoku.ac.jp/~maru/implementations/exponentiation_squaring.php
long long pow(long long a, long long n, long long m) {
    long long ret = 1;
    for (; n > 0; n >>= 1, a = a * a % m) {
        if (n % 2 == 1) {
            ret = ret * a % m;
        }
    }
    return ret;
}

int main() {
    long long H,W;
    long long ans=0;
    long long dot=0;
    cin>>H>>W;
    string S[H];
    long long r[H][W];
    long long l[H][W];
    long long u[H][W];
    long long d[H][W];
    for(long long i=0;i<H;i++){
        cin>>S[i];
    }

    for(long long i=0;i<H;i++){
        for(long long j=0;j<W;j++){
            if(S[i][j]=='.') dot++;
        }
    }

    for(long long i=0;i<H;i++){
        long long c=0;
        for(long long j=0;j<W;j++){
            if(S[i][j]=='.') c++;
            else c=0;
            r[i][j]=c;
        }
    }

    for(long long i=0;i<H;i++){
        long long c=0;
        for(long long j=W-1;j>=0;j--){
            if(S[i][j]=='.') c++;
            else c=0;
            l[i][j]=c;
        }
    }

    for(long long j=0;j<W;j++){
        long long c=0;
        for(long long i=0;i<H;i++){
            if(S[i][j]=='.') c++;
            else c=0;
            d[i][j]=c;
        }
    }

    for(long long j=0;j<W;j++){
        long long c=0;
        for(long long i=H-1;i>=0;i--){
            if(S[i][j]=='.') c++;
            else c=0;
            u[i][j]=c;
        }
    }

    for(long long i=0;i<H;i++){
        for(long long j=0;j<W;j++){
            if(S[i][j]=='.'){
                long long dot2=r[i][j]+l[i][j]+u[i][j]+d[i][j]-3;
                long long a=(pow(2,dot2,MOD)-1)%MOD;
                while(a<0) a+=MOD;
                long long b=pow(2,dot-dot2,MOD);
                //cout<<i<<","<<j<<"---"<<dot<<","<<dot2<<"---"<<a<<","<<b<<endl;
                ans+=a*b%MOD;
                ans%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}
