#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

typedef long long ll;

using namespace std;

int main(void) {
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  vector<vector<int> > cnt(H);
  for (int i = 0; i < H; i++) cin >> S[i];
  ll K = 0;
  for (int i = 0; i < H; i++) {
    cnt[i].resize(W);
    int l = 0;
    for (int j = 0; j <= W; j++) {
      if (j == W || S[i][j] == '#') {
        for (int k = j - 1; k >= max(0, j - l); k--) {
          cnt[i][k] += l;
        }
        l = 0;
      } else {  // if (S[i][j] == '.') {
        l++;
        K++;
      }
    }
  }

  for (int j = 0; j < W; j++) {
    int l = 0;
    for (int i = 0; i <= H; i++) {
      if (i == H || S[i][j] == '#') {
        for (int k = i - 1; k >= max(0, i - l); k--) {
          cnt[k][j] += l;
        }
        l = 0;
      } else {
        l++;  // if (S[i][j] == '.') l++;
      }
    }
  }

  vector<ll> p2ma;
  ll v = 1;
  for (int x = 0; x <= 4000000; x++) {
    p2ma.push_back(v);
    v *= 2;
    v %= 1000000007;
  }
  ll tot = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (cnt[i][j] > 0) {
        cnt[i][j]--;

        ll ij = ((p2ma[cnt[i][j]] - 1) * (p2ma[K - cnt[i][j]])) % 1000000007;
        tot += ij;
        tot = tot % 1000000007;
      }
    }
  }
  cout << tot << endl;

  return 0;
}

#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll mod = 1000000007;

bool field[2000][2000];
int ltor[2000][2000];
int rtol[2000][2000];
int ttob[2000][2000];
int btot[2000][2000];
ll pow2[4000001];

int main() {
  int h, w;
  cin >> h >> w;
  ll maxLight = 0;
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      if (s[j] == '.') { field[i][j] = true; maxLight++; }
      else field[i][j] = false;
    }
  }

  rep(i, h) {
    int cnt = 0;
    rep(j, w) {
      if (field[i][j]) {
        cnt++;
      } else {
        cnt = 0;
      }
      ltor[i][j] = cnt;
    }
    cnt = 0;
    for (int j = w - 1; j >= 0; j--) {
      if (field[i][j]) {
        cnt++;
      } else {
        cnt = 0;
      }
      rtol[i][j] = cnt;
    }
  }

  rep(i, w) {
    int cnt = 0;
    rep(j, h) {
      if (field[j][i]) {
        cnt++;
      } else {
        cnt = 0;
      }
      ttob[j][i] = cnt;
    }
    cnt = 0;
    for (int j = h - 1; j >= 0; j--) {
      if (field[j][i]) {
        cnt++;
      } else {
        cnt = 0;
      }
      btot[j][i] = cnt;
    }
  }

  /*rep(i, h) {
    rep(j, w) cout << ltor[i][j] << " ";
    cout << endl;
  }

  rep(i, h) {
    rep(j, w) cout << rtol[i][j] << " ";
    cout << endl;
  }*/

  ll total = 1;
  rep(i, maxLight) total = (2 * total) % mod;
  ll pow = 1;
  rep(i, h * w + 1) {
    pow2[i] = pow;
    pow = (pow * 2) % mod;
  }
  //cout << "total " << total << endl;

  ll ans = 0;

  rep(i, h) rep(j, w) {
    if (field[i][j]) {
      int cnt = ltor[i][j] + (j + 1 < w ? rtol[i][j + 1] : 0)
              + (i > 0 ? ttob[i - 1][j] : 0) + (i + 1 < h ? btot[i + 1][j] : 0);
      //cout << i << " " << j << " " << cnt << endl;
      ans = (ans + total - pow2[maxLight - cnt] + mod) % mod;
    }
  }

  cout << ans << endl;

  return 0;

}
/*
*/
