//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MOD=1000000007;

int n,m;
string grid[2005];
ll p2[4000005];

int l[2005][2005];
int r[2005][2005];
int up[2005][2005];
int down[2005][2005];


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n>>m;
	rep(x,0,n) cin>>grid[x];
	
	p2[0]=1;
	rep(x,1,4000005) p2[x]=p2[x-1]*2%MOD;
	
	ll tot=0;
	
	rep(x,0,n) rep(y,0,m) if (grid[x][y]=='.') tot++;
	ll ans=tot*p2[tot]%MOD;
	
	rep(x,0,n) rep(y,0,m){
		if (grid[x][y]=='#') l[x][y]=0;
		else if (y==0) l[x][y]=1;
		else l[x][y]=l[x][y-1]+1;
	}
	
	rep(x,0,n) rep(y,m,0){
		if (grid[x][y]=='#') r[x][y]=0;
		else if (y==m-1) r[x][y]=1;
		else r[x][y]=r[x][y+1]+1;
	}
	
	rep(x,0,n) rep(y,0,m){
		if (grid[x][y]=='#') down[x][y]=0;
		else if (x==0) down[x][y]=1;
		else down[x][y]=down[x-1][y]+1;
	}
	
	rep(x,n,0) rep(y,0,m){
		if (grid[x][y]=='#') up[x][y]=0;
		else if (x==n-1) up[x][y]=1;
		else up[x][y]=up[x+1][y]+1;
	}
	
	rep(x,0,n) rep(y,0,m) if (grid[x][y]=='.'){
		int curr=l[x][y]+r[x][y]+up[x][y]+down[x][y]-3;
		
		ans=(ans-p2[tot-curr]+MOD)%MOD;
		
		//cout<<curr<<endl;
	}
	
	cout<<ans<<endl;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

template <int mod>
struct ModInt {
  int64_t x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % 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) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  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) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    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 modulo() { return mod; }
  int get() const { return x; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  using Mint = ModInt<int(1e9 + 7)>;
  int H, W;
  cin >> H >> W;
  string S[H];
  for (int i = 0; i < H; i++) cin >> S[i];
  Mint ans = 0;
  int u[H][W], l[H][W];
  int K = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      u[i][j] = 0;
      l[i][j] = 0;
      if (S[i][j] == '#') continue;
      u[i][j] = 1;
      l[i][j] = 1;
      K++;
      if (i > 0) u[i][j] += u[i - 1][j];
      if (j > 0) l[i][j] += l[i][j - 1];
    }
  }
  int d[H][W], r[H][W];
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      d[i][j] = 0;
      r[i][j] = 0;
      if (S[i][j] == '#') continue;
      d[i][j] = 1;
      r[i][j] = 1;
      if (i + 1 < H) d[i][j] += d[i + 1][j];
      if (j + 1 < W) r[i][j] += r[i][j + 1];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') continue;
      int k = u[i][j] - 1 + d[i][j] - 1 + l[i][j] - 1 + r[i][j] - 1 + 1;
      ans += (Mint(2).pow(k) - 1) * Mint(2).pow(K - k);
    }
  }
  cout << ans << '\n';
  return 0;
}
