#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=99824453;
vin dx={-1,0,1,0};
vin dy={0,1,0,-1};

ll modpow(ll a,ll n,ll m=inf){
    ll res=1;
    while(n){
        if(n&1)res=res*a%m;
        a=a*a%m;
        n>>=1;
    }
    return res;
}

int main(){
    ll h,w;cin>>h>>w;
    vstr s(h);rep(i,h)cin>>s[i];
    vvin up(h,vin(w)),down(h,vin(w)),right(h,vin(w)),left(h,vin(w));
    int tmp=-1;ll k=h*w;
    rep(i,h){
        tmp=-1;
        rep(j,w){
            left[i][j]=tmp;
            if(s[i][j]=='#'){
                tmp=j;
                k--;
            }
        }
        tmp=w;
        for(int j=w-1;j>=0;j--){
            right[i][j]=tmp;
            if(s[i][j]=='#')tmp=j;
        }
    }
    rep(j,w){
        tmp=-1;
        rep(i,h){
            up[i][j]=tmp;
            if(s[i][j]=='#')tmp=i;
        }
        tmp=h;
        for(int i=h-1;i>=0;i--){
            down[i][j]=tmp;
            if(s[i][j]=='#')tmp=i;
        }
    }
    ll all=modpow((ll)2,k),light,can;
    ll ans=(ll)0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='.'){
            light=(down[i][j]-up[i][j]-(ll)1)+(right[i][j]-left[i][j]-(ll)1)-(ll)1;
            can=all-modpow((ll)2,k-light);
            if(can<0)can+=inf;
            ans+=can;ans%=inf;
        }
    }
    cout<<ans<<endl;
}
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int n;
    cin >> n;
    int arr[n];
    REP(i, n){
        cin >> arr[i];
    }
    ll ret = 1e18;
    REP(i, 1 << (n - 1)){
        int curr = arr[0], res = 0;
        REP(j, n - 1){
            if ((i >> j) & 1){
                res ^= curr;
                curr = arr[j + 1];
            }
            else{
                curr |= arr[j + 1];
            }
        }
        res ^= curr;
        ret = min(ret, (ll)res);
    }
    cout << ret << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}