#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using i_i = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

const ll MOD =  1000000007;



int main() {
	int h,w;
	cin >> h >> w;

	string s[h];
	
	rep(i, h) {
		cin >> s[i];
	}
	ll ch[h][w];
	ll cv[h][w];
	ll cr[h][w];

	ll total = 0;

	rep(y, h) {
		rep(x, w) {
			ch[y][x] = 0;
			cv[y][x] = 0;
			cr[y][x] = 0;
			if (s[y][x] == '.') {
				total ++;
			}
		}
	}

	rep(y, h) {
		int count = 0;
		int start = 0;
		rep(x, w) {
			if (s[y][x] == '.') {
				if (count == 0) {
					start = x;
				}
				count++;
			} else {
				if (count == 0) continue;
				for (int cx = start; cx < x; cx++) {
					ch[y][cx] = count;
				}
				count = 0;
			}
		}
		if (count > 0) {
			for (int cx = start; cx < w; cx++) {
				ch[y][cx] = count;
			}
		}
	}

	rep(x, w) {
		int count = 0;
		int start = 0;
		rep(y, h) {
			if (s[y][x] == '.') {
				if (count == 0) {
					start = y;
				}
				count++;
			} else {
				if (count == 0) continue;
				for (int cy = start; cy < y; cy++) {
					cv[cy][x] = count;
				}
				count = 0;
			}
		}
		if (count > 0) {
			for (int cy = start; cy < h; cy++) {
				cv[cy][x] = count;
			}
		}
	}

	rep(y, h) {
		rep(x, w) {
			cr[y][x] = ch[y][x] + cv[y][x];
			if (cr[y][x] > 0) cr[y][x] --;
		}
	}

	vector<ll> power2(2010 * 2010, 0);

	power2[0] = 1;
	rep(i,2010 * 2010) {
		power2[i + 1] = power2[i] * 2;
		power2[i + 1] %= MOD;
	}
	ll ans = 0;

	rep(y, h) {
		rep(x, w) {
			if (cr[y][x] == 0) continue;
			ll cur = (power2[cr[y][x]] - 1) * power2[total - cr[y][x]];
			cur %= MOD;
			ans += cur;
			ans %= MOD;
		}
	}
	cout << ans << endl;


	return 0; 
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mkp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<int>
#define mii             map<lli,lli>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define endl            "\n"
const double PI = acos(-1);

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
  return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
  return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
  lli res = 1;

  x = x % p;
  if (x == 0)
    return 0;

  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;


    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
  if (r == 0)
    return 1;
  if (r == 1)
    return n;


  lli pro = 1, k = n;
  while (k > r)
  {
    pro *= k;
    pro %= p;
    --k;
  }

  k = 2;
  while (k <= (n - r))
  {
    pro *= power(k, (p - 2), p);
    pro %= p;
    ++k;
  }

  return pro;
}


lli first_big(lli n, lli k, vector<lli> arr)
{
  lli l, r, ans = n;
  l = 0;
  r = n - 1;

  while (l <= r) {
    lli m = l + (r - l) / 2;

    if (arr[m] > k) {
      ans = m;
      r = m - 1;
    }

    else
      l = m + 1;
  }

  return ans;
}

lli last_small(lli n, lli k, vector<lli> arr)
{
  lli l, r, ans = -1;
  l = 0;
  r = n - 1;

  while (l <= r)
  {
    lli mid = (l + r) / 2;

    if (arr[mid] <= k)
    {
      ans = mid;
      l = mid + 1;
    }
    else
      r = mid - 1;
  }

  return ans;
}

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
#define MAXN 4000010

int main()
{
  c_p_c();

  lli h, w, k = 0, pro = 1, c = 0;
  vector<lli>pow_mod(MAXN);

  for (int i = 0; i < MAXN; ++i)
  {
    pow_mod[i] = pro;
    pro *= 2;
    pro %= mod;
  }

  cin >> h >> w;
  string str;

  char v[h][w];
  lli arr[h][w];
  memset(arr, 0, sizeof(arr));

  for (int i = 0; i < h; ++i)
  {
    cin >> str;
    for (int j = 0; j < w; ++j)
    {
      v[i][j] = str[j];
      if (str[j] == '.')
        ++k;
    }
  }

  for (lli i = 0; i < h; ++i)
  {
    for (lli j = 0; j < w; ++j)
    {
      if (v[i][j] == '.')
        ++c;
      else
      {
        if (c != 0)
          for (int p = j - c; p < j; ++p)
            arr[i][p] += c;
        c = 0;
      }
    }

    if (c != 0)
      for (int p = w - c; p < w; ++p)
        arr[i][p] += c;
    c = 0;
  }


  for (lli i = 0; i < w; ++i)
  {
    for (lli j = 0; j < h; ++j)
    {
      if (v[j][i] == '.')
        ++c;
      else
      {
        if (c != 0)
          for (int p = j - c; p < j; ++p)
            arr[p][i] += (c - 1);
        c = 0;
      }
    }

    if (c != 0)
      for (int p = h - c; p < h; ++p)
        arr[p][i] += (c - 1);
    c = 0;
  }

  lli ans = pow_mod[k];
  ans *= k;
  ans %= mod;

  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      if (arr[i][j] != 0)
      {
        ans -= pow_mod[k - arr[i][j]];
        ans = (ans + mod) % mod;
      }

  cout << ans << endl;
  return 0;
}