#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=2000,maxt=maxn*maxn,MOD=1e9+7;

int n,m,ans,cnt,pw[maxt+5];char pic[maxn+5][maxn+5];
int U[maxn+5][maxn+5],D[maxn+5][maxn+5],L[maxn+5][maxn+5],R[maxn+5][maxn+5];

inline char readc(){
	static char buf[100000],*l=buf,*r=buf;
	return l==r && (r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
#define ADD(x,y) (((x)+(y))%MOD)
#define MUL(x,y) ((LL)(x)*(y)%MOD)
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			char ch=readc();while (ch!='.' && ch!='#') ch=readc();
			cnt+=ch=='.';pic[i][j]=ch;
		}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++) pic[i][j]=='.'?L[i][j]=L[i][j-1]+1:L[i][j]=0;
		for (int j=m;j>=1;j--) pic[i][j]=='.'?R[i][j]=R[i][j+1]+1:R[i][j]=0;
	}
	for (int j=1;j<=m;j++){
		for (int i=1;i<=n;i++) pic[i][j]=='.'?U[i][j]=U[i-1][j]+1:U[i][j]=0;
		for (int i=n;i>=1;i--) pic[i][j]=='.'?D[i][j]=D[i+1][j]+1:D[i][j]=0;
	}
	pw[0]=1;for (int i=1;i<=cnt+1;i++) pw[i]=(pw[i-1]<<1)%MOD;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			if (pic[i][j]=='#') continue;
			int now=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
			ans=ADD(ans,MUL(pw[now]-1,pw[cnt-now]));
		}
	printf("%d\n",ans);
	return 0;
}
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define rev(v)  if(!v.empty())reverse(v.begin(),v.end())
#define PI 3.141592653589793238
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

pii find(ll b,ll c){
	
	if(c==0){
		return make_pair(b,b);
	}
	if(c%2){
		ll n=c/2;
		return make_pair(-b-n,-b+n);
	}
	
	return make_pair(b-c/2,b+c/2-1);
}

pii in(ll l,ll r,ll ss,ll se){
	return make_pair(max(ss,l),min(se,r));
}
void solve()
{
     ll b,c;
	 cin>>b>>c;
	 
	 ll l=find(b,c).ff;
	 ll r=find(b,c).ss;
	 
//	 cout<<l<<" "<<r<<endl;
	 
	 ll ss=find(b,c-1).ff;
	 ll se=find(b,c-1).ss;
	 
//	 cout<<ss<<" "<<se<<endl;
	 ll sl=in(l,r,ss,se).ff;
	 ll sr=in(l,r,ss,se).ss;
	 
	 cout<<(max(0LL,r-l+1)+max(0LL,se-ss+1)-max(0LL,sr-sl+1));
	 
	    
}
int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}
