#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <cstring>
#include <cassert>

using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

//#define L_JUDGE

#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;


inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar();  }
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    return x * f;

}


LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }



const int MOD=1e9+7;
const int MAXN=2010;

char G[MAXN][MAXN];
LL H, W;
LL d[MAXN][MAXN];

void Solve(){
    cin>>H>>W;
    int cnt=0;
    for(int i=0;i<H;i++){
        cin>>G[i];
        for(int j=0;j<W;j++){
            if(G[i][j]=='.')cnt++;
        }
    }
    memset(d, 0, sizeof(d));
    for(int ri=0;ri<H;ri++){
        int l[MAXN], r[MAXN];
        int a=-1, b=W;
        for(int ci=0;ci<W;ci++){
            if(G[ri][ci]=='#'){
                a=ci;
            }
            l[ci]=a;
        }
        for(int ci=W-1;ci>=0;ci--){
            if(G[ri][ci]=='#'){
                b=ci;
            }
            r[ci]=b;
        }
        for(int ci=0;ci<W;ci++){
            if(r[ci]-1>=l[ci]+1)
                d[ri][ci]+=(r[ci]-1-l[ci]-1);
        }
    }
    for(int ci=0;ci<W;ci++){
        int l[MAXN], r[MAXN];
        int a=-1,b=H;
        for(int ri=0;ri<H;ri++){
            if(G[ri][ci]=='#'){
                a=ri;
            }
            l[ri]=a;
        }
        for(int ri=H-1;ri>=0;ri--){
            if(G[ri][ci]=='#'){
                b=ri;
            }
            r[ri]=b;
        }
        for(int ri=0;ri<H;ri++){
            if(r[ri]-1>=l[ri]+1)
                d[ri][ci]+=(r[ri]-1-l[ri]);
        }
    }
    LL ans=0;
    for(int ri=0;ri<H;ri++){
        for(int ci=0;ci<W;ci++){
            if(G[ri][ci]=='#')continue;
            ans = ans+bin(2, cnt-d[ri][ci], MOD)*(bin(2, d[ri][ci], MOD)-1)%MOD;
            ans %= MOD;
        }
    }
    cout<<ans<<endl;
}


int main(){
#ifdef L_JUDGE
    freopen("in.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    Solve();
    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
using i64 = int_fast64_t;
constexpr i64 MAX = 10000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{

public:
  i64 a;

  constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
  constexpr i64 &value() noexcept { return a; }
  constexpr const i64 &value() const noexcept { return a; }
  constexpr modcal operator+(const modcal rhs) const noexcept
  {
    return modcal(*this) += rhs;
  }
  constexpr modcal operator-(const modcal rhs) const noexcept
  {
    return modcal(*this) -= rhs;
  }
  constexpr modcal operator*(const modcal rhs) const noexcept
  {
    return modcal(*this) *= rhs;
  }
  constexpr modcal operator/(const modcal rhs) noexcept
  {
    return modcal(*this) /= rhs;
  }
  constexpr modcal &operator+=(const modcal rhs) noexcept
  {
    a += rhs.a;
    if (a >= modulus)
    {
      a -= modulus;
    }
    return *this;
  }
  constexpr modcal &operator-=(const modcal rhs) noexcept
  {
    if (a < rhs.a)
    {
      a += modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modcal &operator*=(const modcal rhs) noexcept
  {
    a = a * rhs.a % modulus;
    return *this;
  }
  constexpr modcal &operator/=(modcal rhs) noexcept
  {
    i64 exp = modulus - 2;
    while (exp)
    {
      if (exp % 2)
      {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  void COMninit()
  {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
      fac[i] = fac[i - 1] * i % modulus;
      inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
      finv[i] = finv[i - 1] * inv[i] % modulus;
    }
  }
  i64 COMn(i64 n, i64 k)
  {
    if (n < k)
      return 0;
    if (n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
  }
  constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
  {
    if (n == 0)
      return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1)
      t = t * a;
    return t;
  }
};
using modc = modcal<1000000007>;
i64 Left[2100][2100],Right[2100][2100],Up[2100][2100],Down[2100][2100];
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 h,w;
    cin >> h >> w;
    vector<string> a(h);
    i64 k = 0;
    rep(i,h){
        cin >> a[i];
        rep(j,w){
            if(a[i][j] == '.')k++;
        }
    }
    rep(i,h){
        i64 cur = 0;
        rep(j,w){
            if(a[i][j] == '#')cur = 0;
            else cur++;
            Left[i][j] = cur;
        }
    }
    rep(i,h){
        i64 cur = 0;
        for(i32 j = w - 1; 0 <= j; j--){
            if(a[i][j] == '#')cur = 0;
            else cur++;
            Right[i][j] = cur;

        }
    }
    rep(j,w){
        i64 cur = 0;
        rep(i,h){
            if(a[i][j] == '#')cur = 0;
            else cur++;
            Up[i][j] = cur;
        }
    }
    rep(j,w) {
        i64 cur = 0;
        for (i32 i = h - 1; i >= 0; i--) {
            if (a[i][j] == '#')cur = 0;
            else cur++;
            Down[i][j] = cur;
        }
    }

    modc ans = 0;
    rep(i,h){
        rep(j,w){
            if(a[i][j] == '#')continue;
            i64 num = Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3;
            modc base = 2;
            ans += ans.modpow(base,k).a;
            ans -= ans.modpow(base,(k - num)).a;
        }
    }
    cout << ans.a << endl;
}