#include<cstdio>
#define mod 998244353
#define N 5001
#define M 51
using namespace std;
int n,m;
int stack[N];
long long f[M][N],jc[N],njc[N];
long long ksmi(long long x,long long y)
{
	long long total=1,ab=x,p=y;
	while (p)
	{
		if (p%2==1) total=total*ab%mod;
		ab=ab*ab%mod;
		p/=2;
	}
	return total;
}
long long C(int n,int m){
	return jc[n]*njc[m]%mod*njc[n-m]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);
	int sm=m;
	int top=0;
	jc[0]=1;
	for (int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
	njc[n]=ksmi(jc[n],mod-2);
	for (int i=n-1;i>=0;i--) njc[i]=njc[i+1]*(i+1)%mod;
	for (int i=1;i<=n;i++)
	while (m!=0)
	{
		stack[++top]=m%2;
		m/=2;
	}
	f[0][0]=1;
	for (int i=1;i<=top;i++)
	{
		for (int j=0;j<=n;j++)
		{
			if (f[i-1][j]==0) continue;
			int cur=j%2;
			if (cur!=stack[i]) continue;
			for (int k=0;k<=n;k+=2)
				f[i][(j/2)+(k/2)]=(f[i][(j+k)/2]+f[i-1][j]*C(n,k)%mod)%mod;
		}
	}
	printf("%lld\n",f[top][0]);
}
#include<iostream>
#include<vector>
using namespace std;
const long long int MAX = 3000;
const long long int MOD = 1000000007;
int main(){
	long long int H,W,K=0;
	long long int sum,ans=0;
	vector<long long int> two;
	string S;
	bool F[MAX+2][MAX+2]={0};
	long long int M[MAX+2][MAX+2][4]={0};
	cin>>H>>W;
	for(int i=1;i<=H;i++){
		cin>>S;
		for(int j=1;j<=W;j++){
			F[i][j]=(S[j-1]=='.');
			K+=F[i][j];
		}
	}
	two.push_back(1);
	for(int i=1;i<=K;i++)two.push_back(two[i-1]*2%MOD);
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(!F[i][j])continue;
			M[i][j][0]=(M[i][j-1][0]+1)*F[i][j-1];
			M[i][j][1]=(M[i-1][j][1]+1)*F[i-1][j];
		}
	}
	for(int i=H;i>=1;i--){
		for(int j=W;j>=1;j--){
			if(!F[i][j])continue;
			M[i][j][2]=(M[i][j+1][2]+1)*F[i][j+1];
			M[i][j][3]=(M[i+1][j][3]+1)*F[i+1][j];
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(!F[i][j])continue;
			sum=1;
			for(int k=0;k<4;k++)sum+=M[i][j][k];
			ans+=(two[K]-two[K-sum])%MOD;
			ans=(ans%MOD+MOD)%MOD;
		}
	}
	cout<<ans;
	return 0;
}