#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;//998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
ll dp1[2001][2001];
ll dp2[2001][2001]; 
int main() {
   int h,w;cin>>h>>w;
   vector<string> v;
   string last(w+1,'#');
   rep(i,h){
      string s;cin>>s;
      v.push_back(s);
      v[i].push_back('#');
   }
   int sum=0;
   rep(i,h)rep(j,w)sum+=(v[i][j]=='.');
   rep(i,h){
      rep(j,w){
         dp1[i][j]=dp2[i][j]=(v[i][j]=='.');
      }
   }
   rep(i,h){
      rep(j,w-1){
         if(v[i][j+1]=='.'&&v[i][j]=='.'){
            dp1[i][j+1]=dp1[i][j]+1;
         }
      }
   }
   rep(i,h){
      for (int j = w - 1; j > 0; j--)
      {
         if(v[i][j-1]=='.'&&v[i][j]=='.'){
            dp1[i][j-1]=dp1[i][j];
         }
      }
   }
   rep(j,w){
      rep(i,h-1){
            if(v[i+1][j]=='.'&&v[i][j]=='.'){
            dp2[i+1][j]=dp2[i][j]+1;
         }
      }
   }
   rep(j,w){
      for (int i = h-1; i > 0; i--)
      {
         if(v[i-1][j]=='.'&&v[i][j]=='.'){
            dp2[i-1][j]=dp2[i][j];
         }
      }
   }
   mint ans=0;
   mint two=2;
   rep(i,h){
      rep(j,w){
         if(v[i][j]=='.')
         ans+=(two.pow(dp1[i][j]+dp2[i][j]-1)-1)*two.pow(sum-dp1[i][j]-dp2[i][j]+1);
      }
   }
   cout<<ans<<endl;
}
/**
 * Written by : Ujjawal Pabreja [cuber_coder]
 * Email : ujjawalpabreja99@gmail.com
*/
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define endl "\n"
const int mod = 1e9 + 7;
const int MAX = 2e5 + 1;
ll power(ll x, ll p) {
    ll ans = 1;
    while (p) {
        if (p & 1) {
            ans = (ans * x) % mod;
            p--;
        }
        x = (x * x) % mod;
        p >>= 1;
    }
    return ans;
}
ll add(ll x, ll y) {
    return ((x % mod) + (y % mod)) % mod;
}
ll mul(ll x, ll y) {
    return ((x % mod) * (y % mod)) % mod;
}
ll sub(ll x, ll y) {
    return ((x % mod) - (y % mod) + mod) % mod;
}


void Solve() {
    ll n, m;
    cin >> n >> m;
    string s[n];
    ll tidy = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < m; j++) {
            tidy += (s[i][j] == '.');
        }
    }
    vector <vector <ll>> a(n, vector <ll>(m));
    for (int j = 0; j < m; j++) {
        for (int i = 0; i < n; ) {
            if (s[i][j] == '#') {
                i++;
                continue;
            }
            int k = i + 1, len = 1;
            while (k < n and s[k][j] == '.') {
                len++;
                k++;
            }
            while (i < k) {
                a[i][j] = len;
                i++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m;) {
            if (s[i][j] == '#') {
                j++;
                continue;
            }
            int k = j + 1, len = 1;
            while (k < m and s[i][k] == '.') {
                len++;
                k++;
            }
            while (j < k) {
                a[i][j] += len;
                j++;
            }
        }
    }
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < m; j++) {
    //         cout << a[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '#') {
                continue;
            }
            ll tot = a[i][j] - 1;
            ll ways = sub(power(2, tot), 1);
            ans = add(ans, mul(ways, power(2, tidy - tot)));
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int testcases = 1;
    // cin >> testcases;

    while (testcases--) {
        Solve();
    }
}