#include <bits/stdc++.h>
#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

constexpr ll mod = 1000000007;

ll mpow(ll x, ll n) {
    ll ans = 1; x %= mod;
    while (n != 0) {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ans;
}

int main() {
    int h, w;
    cin >> h >> w;
    ll k = 0;
    vector<vector<int>> grid(h, vector<int>(w, 0));
    rep(y, h) {
        string s;
        cin >> s;
        rep(x, w) {
            grid[y][x] = s[x] == '.';
            if (grid[y][x]) k++;
        }
    }
    vector<vector<P>> xs(h, vector<P>(w));
    rep(y, h) {
        int l = -1, r = -1;
        rep(x, w) {
            if (!grid[y][x]) {
                l = -1; r = -1;
                continue;
            }
            if (l == -1) {
                l = x;
            }
            if (r == -1) {
                r = x;
            }
            while (r < w && grid[y][r]) {
                r++;
            }
            xs[y][x] = { l, r };
        }
    }
    vector<vector<P>> ys(h, vector<P>(w));
    rep(x, w) {
        int t = -1, b = -1;
        rep(y, h) {
            if (!grid[y][x]) {
                t = -1; b = -1;
                continue;
            }
            if (t == -1) {
                t = y;
            }
            if (b == -1) {
                b = y;
            }
            while (b < h && grid[b][x]) {
                b++;
            }
            ys[y][x] = { t, b };
        }
    }
    //rep(y, h) {
    //    rep(x, w) {
    //        cout << x << "," << y << "," << xs[y][x].first << "," << xs[y][x].second << endl;
    //        cout << "," << ys[y][x].first << "," << ys[y][x].second << endl;
    //    }
    //}
    ll sum = 0;
    rep(y, h) {
        rep(x, w) {
            if (!grid[y][x]) {
                continue;
            }
            ll cy = ys[y][x].second - ys[y][x].first;
            ll cx = xs[y][x].second - xs[y][x].first;
            ll c = cy + cx - 1;
            ll p = k - c;
            ll a = (mpow(2, c) - 1 + mod) % mod;
            a *= mpow(2, p);
            a %= mod;
            sum += a;
            sum %= mod;
        }
    }
    cout << sum << endl;
    return 0;
}

#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll mod = 1e9 + 7;

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp) % mod;
    else
        return (((x*temp)%mod)*temp)%mod;
}


/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;
vector<bool> prime;

void Sieve(int n)
{
    prime = vector<bool> (n+1,true);
    //vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

ll modInverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 2e5 + 6;
const int N = 2005;

string str[N];

int n,m;

ll tot = 0;

ll dp[N][N][4];

ll mem[N][N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i=1;i<=n;i++)
    {
        cin >> str[i];
        str[i] = '%' + str[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(str[i][j] == '.')
            {
                for(int k=0;k<2;k++)
                    dp[i][j][k] = 1;
            }
            else
                continue;
            dp[i][j][0] += dp[i-1][j][0];
            dp[i][j][1] += dp[i][j-1][1];
            mem[i][j] += 1 + dp[i][j-1][1] + dp[i-1][j][0];
        }
    }
    for(int i=n;i>=1;i--)
    {
        for(int j=m;j>=1;j--)
        {
            if(str[i][j] == '.')
            {
                dp[i][j][2] = 1;
                dp[i][j][3] = 1;
            }
            else
                continue;
            dp[i][j][2] += dp[i+1][j][2];
            dp[i][j][3] += dp[i][j+1][3];
            mem[i][j] += dp[i][j+1][3] + dp[i+1][j][2];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(mem[i][j])
                tot++;
        }
    }
    ll ans = 0;
    ll pow[N*N];
    pow[0] = 1;
    for(int i=1;i<N*N;i++)
    {
        pow[i] = (pow[i-1]*2)%mod;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(mem[i][j])
            {
                ll two = pow[mem[i][j]];
                two = (two - 1 + mod)%mod;
                ll p = pow[tot-mem[i][j]];
                ans += (two*p)%mod;
                ans %= mod;
            }
        }
    }
    cout << ans;
}
