	#include<bits/stdc++.h>
	#define mod ((long)(1e9+7))
	using namespace std;
	
	int main(int argc, char const *argcv[])
	{
	    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        int h,w;
        cin>>h;
      	cin>>w;
        string s[h];
        for(int i=0;i<h;i++)
            cin>>s[i];    
        int g[h+1][w+1];
        int u[h+1][w+1];
        int l[h+1][w+1];
        int d[h+1][w+1];
        int r[h+1][w+1];
        long  p2[h*w+4];
        p2[0]=1;
        for(int i=1;i<(h*w+4);i++)
            p2[i]=(p2[i-1]*2ll)%mod;
          
        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;
                    g[i][j]=0;

                    if(s[i][j]=='.')
                        {
                            g[i][j]=1;
                            k++;
                            if(i>0)
                                u[i][j]+=u[i-1][j];
                            if(j>0)
                                l[i][j]+=l[i][j-1];
                            u[i][j]++;
                            l[i][j]++;

                        }

                }
        long long ans=0;
        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(g[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];
                            d[i][j]++;
                            r[i][j]++;
                            
                        int cnum=0;
                        cnum=cnum+u[i][j];
                        cnum=cnum+l[i][j];
                        cnum=cnum+r[i][j];
                        cnum=cnum+d[i][j];
                        cnum=cnum-3;
                        if(k-cnum<0)
                        	cout<<"Wrong"<<endl;
                        ans=(ans+(p2[k]*1ll+mod*1ll-p2[k-cnum]*1ll)%mod)%mod;
                        }
                        
                }

        cout<<ans<<endl;
	}
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

const lint mod = MOD;
class mint{
    public:
        long long x;

    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend istream& operator>>(istream& is, mint& m){
        long long x; is >> x; m = x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<int>> hor(h, vector<int>(w, 1)), ver(h, vector<int>(w, 1));
    
    rep(i, h){
        rep(j, w){
            if(j == 0 || s[i][j] == '#') continue;
            if(s[i][j-1] == '.') hor[i][j] = hor[i][j-1] + 1;
        }
        repr(j, w){
            if(j == w-1 || s[i][j] == '#') continue;
            if(s[i][j+1] == '.') hor[i][j] = hor[i][j+1];
        }
    }
    rep(j, w){
        rep(i, h){
            if(i == 0 || s[i][j] == '#') continue;
            if(s[i-1][j] == '.') ver[i][j] = ver[i-1][j] + 1;
        }
        repr(i, h){
            if(i == h-1 || s[i][j] == '#') continue;
            if(s[i+1][j] == '.') ver[i][j] = ver[i+1][j];
        }
    }

    vector<vector<int>> p(h, vector<int>(w));
    lint k = 0;
    rep(i, h) rep(j, w){
        if(s[i][j] == '#') continue;
        p[i][j] = hor[i][j] + ver[i][j] - 1;
        k += 1;
    }

    mint ans = mint(2).pow(k) * k;
    rep(i, h) rep(j, w){
        if(s[i][j] == '#') continue;
        ans -= mint(2).pow(k - p[i][j]);
    }
    out(ans);

}