#include <iostream>
#include <bits/stdc++.h>

using namespace std;

long long mod=1e9+7;

long long modpascal=14348907;

int ic(char c){
    if (c=='B') return 0;
    if (c=='R') return 1;
    return 2;
}

char ci(int i){
    if (i==0) return 'B';
    if (i==1) return 'R';
    return 'W';
}

long long pp(long long a, long long b){
    if (b==0) return 1;
    if (b==1) return a;
    if (b%2) return (a*pp((a*a)%modpascal,b/2))%modpascal;
    return pp((a*a)%modpascal,b/2);
}

long long inv(long long x){
    return pp(x,modpascal-2);
}

int ccc[3][3]={{1,0,0},{1,1,0},{1,-1,1}};

int cnk3(int m,int n)
{
    if (n==0) return 1;
    if (m==n) return 1;
    return cnk3(m/3,n/3)*ccc[m%3][n%3];
}

void cmain()
{
    int n;cin>>n;
    long long res=0;
    int mult=-1;
    if (n%2) mult=1;
    char c;
    for (int k=0;k<n;k++){
        cin >> c;
        //cout << n-1 << " " << k << " " << cnk3(n-1,k)<<endl;
        res+=cnk3(n-1,k)*ic(c)*mult;
    }
    res%=3;
    res+=3;
    res%=3;
    cout << ci(res) << endl;
    return;

}

void bmain()
{
    int n;cin>>n;
    set<long> a;
    long ai;
    for (int i=0;i<n;i++){
        cin>>ai;
        a.insert(ai);
    }
    n=a.size();
    vector<long> x={0};
    int i;
    for (set<long>::iterator it=a.begin();it!=a.end();it++){
        x.push_back(*it);
    }
    long long res=1;
    while (x.size()>1){
        long long old=x.back();
        x.pop_back();
        res*=old-x.back()+1;
        res%=mod;
    }
    cout << res << endl;
    return;

}

void amain()
{
    int a,b;cin>>a>>b;
    long cpt=800000;
    long s=0;
    vector<long> x;
    if (a>=b){
        while (a){
            a--;
            s+=cpt;
            x.push_back(cpt);
            cpt++;
        }
        while (b>1){
            cpt--;
            b--;
            s-=cpt;
            x.push_back(-cpt);
        }
        x.push_back(-s);
    }
    else{
        while (b){
            b--;
            s-=cpt;
            x.push_back(-cpt);
            cpt++;
        }
        while (a>1){
            cpt--;
            a--;
            s+=cpt;
            x.push_back(cpt);
        }
        x.push_back(-s);
    }
    for (int i=0;i<x.size();i++){
        cout << x[i] << " ";
    }

    return;
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    cmain();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vector<ll>>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define MOD 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    ll H,W;
    cin >>H>>W;
    vector<vector<char>>S(H,vector<char>(W));
    ll num=0;
    rep(i,H){
        rep(j,W){
            cin>>S[i][j];
            if(S[i][j]=='.'){
                num++;
            }
        }
        
    }
    if(num==0){
        cout<<0<<endl;
        return 0;
    }else if(num==1){
        cout<<1<<endl;
        return 0;
    }
    
    //vvl yoko(H,vector<ll>(W));
    vvl tate(H,vector<ll>(W));
    
    rep(j,W){
        ll cnt=0;
        ll now=0;
        rep(i,H){
            if(S[i][j]=='#'){
                rep3(k,now,i){
                    tate[k][j]=cnt;
                }
                now=i+1;
                cnt=0;
            }else{
                cnt++;
            }
            
        }
        rep3(k,now,H){
            tate[k][j]=cnt;
        }
    }


    ll Y=0;
    vvl yoko(H,vector<ll>(W));
    
    rep(i,H){
        ll cnt=0;
        ll now=0;
        rep(j,W){
            if(S[i][j]=='#'){
                rep3(k,now,j){
                    yoko[i][k]=cnt;
                }
                //Y=(Y+cnt*cnt)%MOD;
                now=j+1;
                cnt=0;
            }else{
                cnt++;
            }
            
        }
        rep3(k,now,W){
            yoko[i][k]=cnt;
        }
    }

    /*rep(i,H){
        rep(j,W){
            cout<<tate[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    rep(i,H){
        rep(j,W){
            cout<<tate[i][j]<<" ";
        }
        cout<<endl;
    }*/

    ll ans=0;
    rep(i,H){
        rep(j,W){
            if(tate[i][j]+yoko[i][j]-1>=0)
                ans =(ans+modpow(2,num,MOD)-modpow(2,num-(tate[i][j]+yoko[i][j]-1),MOD)+MOD)%MOD;
        }
    }
    /*cout<<num<<endl;*/
    cout<<(ans+MOD)%MOD<<endl;

    return 0;
    

}