#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define MOD 1000000007

int mpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = (int64_t) res * a % MOD;
		a = (int64_t) a * a % MOD;
	}
	return res;
}

#ifdef WIN32
#define getchar_fast getchar
#else
#define getchar_fast getchar_unlocked
#endif

int main() {
	int h = ri();
	int w = ri();
	int16_t a[h][w];
	getchar_fast();
	for (auto &i : a) {
		for (int j = 0; j < w; j++) i[j] = getchar_fast() == '.';
		getchar_fast();
	}
	
	int16_t free[h][w];
	memset(free, 0, sizeof(free));
	for (int i = 0; i < h; i++) {
		int start = 0;
		for (int j = 0; j <= w; j++) if (j == w || !a[i][j]) {
			for (int k = start; k < j; k++) free[i][k] += j - start;
			start = j + 1;
		}
	}
	int16_t vertical[w];
	memset(vertical, 0, sizeof(vertical));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) free[i][j] += (vertical[j] = a[i][j] ? vertical[j] + 1 : 0);
	}
	memset(vertical, 0, sizeof(vertical));
	for (int i = h; i--; ) {
		for (int j = 0; j < w; j++) free[i][j] += (vertical[j] = a[i][j] ? vertical[j] + 1 : 0);
	}
	
	int k = 0;
	for (auto &i : a) k += std::accumulate(i, i + w, 0);
	int b2[h + w];
	int all = mpow(2, k), cur = all;
	for (int i = 0; i < h + w; i++) {
		if (i) {
			if (cur & 1) cur = (cur + MOD) >> 1;
			else cur >>= 1;
		}
		b2[i] = cur ? MOD - cur : 0;
	}
	
	
	int64_t res = (int64_t) k * all;
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (a[i][j]) res += b2[free[i][j] - 2];
	std::cout << res % MOD << std::endl;
	
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    ll m = INF;
    rep1(i, n){
        cin >> a[i];
        m = min(m, a[i]);
    }
    map<ll, ll> ma;
    rep1(i, n){
        ma[a[i]%m]++;
    }
    vector<ll> b;
    for (auto x: ma){
        if (x.first!=0) b.push_back(x.first);
    }
    while (b.size()>0){
        m = b[0];
        map<ll, ll> res;
        for (auto x: b) if (x%m!=0) res[x%m]++;
        b.assign(0, 0);
        for (auto x: res) b.push_back(x.first);
    }
    cout << m << endl;
    //printf("%.12f", ans);
}