#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int MOD2 = 998'244'353;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}










int main(){
    int N; std::cin >> N;
    std::vector<int> A(N);
    for(auto &e: A) std::cin >> e;
    std::vector<std::vector<int>> dp(N, std::vector<int>(N));
    for(int i{0}; i < N; ++i){
        for(int j{i}; j < N; ++j){
            int r{0};
            for(int k{i}; k <= j; ++k){
                r |= A[k];
            }
            dp[i][j] = r;
        }
    }
    int ans{2*INF};
    for(int i{0}, i_len{1 << (N -1)}; i < i_len; ++i){
        int res{}, prv{};
        for(int j{0}, j_len{N-1}; j < j_len; ++j){
            if((i >> j) & 1){
                res ^= dp[prv][j];
                prv = j + 1;
            }
        }
        res ^= dp[prv][N-1];
        chmin(ans, res);
    }
    std::cout << ans << std::endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll p[4000005],cnt[2005][2005],hell=pow(10,9)+7;
ll mul(ll x,ll y){
	x=(x*y)%hell;
	return x;
}
ll add(ll x,ll y){
	x+=y;
	if(x>=hell)
		x-=hell;
	return x;
}
ll sub(ll x,ll y){
	x-=y;
	if(x<0)
		x+=hell;
	return x;
}
void solve(){
	ll n,m,c=0;
	cin>>n>>m;
	vector<string> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
		for(ll j=0;j<m;j++)
			if(v[i][j]=='.')
				c++;
	}
	for(ll i=0;i<n;i++)
		for(ll j=0;j<m;j++){
			if(v[i][j]=='#')
				continue;
			ll k=j;
			while(k<m&&v[i][k]=='.')
				k++;
			ll x=k-j;
			while(j<k){
				cnt[i][j]=x;
				j++;
			}
			j--;
		}
	for(ll j=0;j<m;j++)
		for(ll i=0;i<n;i++){
			if(v[i][j]=='#')
				continue;
			ll k=i;
			while(k<n&&v[k][j]=='.')
				k++;
			ll x=k-i;
			while(i<k){
				cnt[i][j]+=x-1;
				i++;
			}
			i--;
		}
	ll res=0;
	for(ll i=0;i<n;i++)
		for(ll j=0;j<m;j++)
			if(v[i][j]=='.'){
				ll val=sub(p[cnt[i][j]],1);
				val=mul(val,p[c-cnt[i][j]]);
				res=add(res,val);
			}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    p[0]=1;
    for(ll i=1;i<4000005;i++)
    	p[i]=mul(p[i-1],2);
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}