#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

const int MOD = 1e9 + 7;

using mint = ModInt<MOD>;

int main() { 
    int h, w;
    cin >> h >> w;
    vector<string> s;
    rep(i, h){
        string x;
        cin >> x;
        s.push_back(x);
    }

    vector<vector<int>> hbox(h), wbox(w);
    rep(i, h){
        hbox[i].push_back(-1);
        hbox[i].push_back(w);
    }
    rep(i, w){
        wbox[i].push_back(-1);
        wbox[i].push_back(h);
    }

    int messcnt = 0;

    rep(i, h){
        rep(j, w){
            if(s[i][j]=='#'){
                messcnt++;
                hbox[i].push_back(j);
                wbox[j].push_back(i);
            }
        }
    }

    rep(i, h){
        sort(hbox[i].begin(), hbox[i].end());
    }

    rep(i, w){
        sort(wbox[i].begin(), wbox[i].end());
    }

    vector<mint> two(h*w-messcnt+1);
    two[0] = 1;
    rep2(i, 1, h*w-messcnt+1){
        two[i] = two[i-1]*2;
    }

    mint res = 0;

    rep(i, h){
        rep(j, w){
            if(s[i][j]=='.'){
                auto it = upper_bound(hbox[i].begin(), hbox[i].end(), j);
                int hnum = (*(it) - *(--it)) - 1;
                it = upper_bound(wbox[j].begin(), wbox[j].end(), i);
                int wnum = (*(it) - *(--it)) - 1;
                int x = hnum + wnum - 1;
                res += two[h*w-messcnt] - two[h*w-messcnt - x];
            }
        }
    }

    cout << res << endl;
    return 0; 
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    vector<vector<int>> A(H, vector<int> (W, -1));
    vector<vector<int>> y(H, vector<int> (W, -1));
    vector<vector<int>> t(H, vector<int> (W, -1));
    for (int i = 0; i < H; i++) {
        if(S[i][0] == '.'){
            y[i][0] = 1;
        }
        for (int j = 1; j < W; j++) {
            if(S[i][j-1] == '#'){
                if(S[i][j] == '.'){
                    y[i][j] = 1;
                }
            }
            else{
                if(S[i][j] == '.'){
                    y[i][j] = y[i][j-1] + 1;
                }
            }
        }
        int tmp = -1;
        for (int j = W-1; j >= 0; j--) {
            if(y[i][j] == -1){
                tmp = -1;
            }
            else{
                if(tmp == -1){
                    tmp = y[i][j];
                }
                else{
                    y[i][j] = tmp;
                }
            }
        }
    }
    for (int i = 0; i < W; i++) {
        if(S[0][i] == '.'){
            t[0][i] = 1;
        }
        for (int j = 1; j < H; j++) {
            if(S[j-1][i] == '#'){
                if(S[j][i] == '.'){
                    t[j][i] = 1;
                }
            }
            else{
                if(S[j][i] == '.'){
                    t[j][i] = t[j-1][i] + 1;
                }
            }
        }
        int tmp = -1;
        for (int j = H-1; j >= 0; j--) {
            if(t[j][i] == -1){
                tmp = -1;
            }
            else{
                if(tmp == -1){
                    tmp = t[j][i];
                }
                else{
                    t[j][i] = tmp;
                }
            }
        }
    }
    ll cnt = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            A[i][j] = y[i][j] + t[i][j] - 1;
            if(S[i][j] == '.') cnt++;
        }
    }

    vector<ll> p(5000);
    p[0] = 1;

    vector<ll> inv(5); inv[1] = 1;
    for (int i = 2; i < 5; i++) {
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
    }   
    for (int i = 1; i < 5000; i++) {
        p[i] = p[i-1] * inv[2] % MOD;
    }

    ll tk = 1;
    for (ll i = 0; i < cnt; i++) {
        tk = tk * 2 % MOD;
    }

    ll ans = 0; ll tmp;
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            if(A[i][j] >= 1){
                tmp = (1 - p[A[i][j]] + MOD) % MOD;
                ans = (ans + tmp) % MOD;
            }
        }
    }
    ans = ans * tk % MOD;
    printf("%lld\n", ans);
    // printf("%lld\n", tk);
    // printf("%d\n", A[0][0]);
    // printf("%d\n", A[0][1]);
    // printf("%d\n", A[0][2]);
    // printf("%d\n", y[0][0]);
    // printf("%d\n", y[0][1]);
    // printf("%d\n", y[0][2]);

    // printf("%d\n", t[0][0]);
    // printf("%d\n", t[0][1]);
    // printf("%d\n", t[0][2]);
    // printf("%d\n", t[1][0]);
    // printf("%d\n", t[1][1]);
    // printf("%d\n", t[1][2]);
}