#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 18;
int connect[N],f[1 << N];

int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i = 0;i < n;++i)	connect[i] |= (1 << i);
	
	for(int i = 0;i < m;++i)
	{
		int u,v;scanf("%d%d",&u,&v);
		--u;--v;
		connect[u] |= (1 << v);
		connect[v] |= (1 << u);
	}
	
	f[0] = 0;
	for(int i = 1;i < (1 << n);++i)
	{
		f[i] = 1e5+7;
		bool indp = 1;
		for(int j = 0;j < n;++j)
			if((i >> j & 1) && ((connect[j] & i) != i))
				indp = 0;
		if(indp)	f[i] = 1;
		for(int s = i;s;s = (s - 1) & i)
			f[i] = min(f[i],f[s] + f[i - s]);
	}
	printf("%d",f[(1 << n) - 1]);
    return 0;
}
#include<iostream> 
#include<cstdio> 
#include<algorithm>
#define re register
#define ri register int 
#define For(i,a,b) for(ri i=a;i<=b;++i) 
#define iFor(i,a,b) for(ri i=a;i>=b;--i) 
#define File(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
#define gtch() (_p1==_p2&&(_p2=(_p1=buf)+fread(buf,1,1<<22,stdin),_p1==_p2)?EOF:*_p1++)
using namespace std;
typedef long long ll;
char buf[1<<22],*_p1=buf,*_p2=buf;
inline ll fr(){
	re ll r=0;re char c=gtch();ri b=0;
	while(!isdigit(c))b=(c=='-'),c=gtch();
	while(isdigit(c))r=r*10+c-'0',c=gtch();
	return b?-r:r;
}
inline int fc(){
	re char c=gtch();
	while(c==' '||c=='\n')c=gtch();
	return c=='.';
}
const ll MOD=1e9+7;
const int MAXN=2005;
const ll INF=9e17+5;
int n,m;
int ar[MAXN][MAXN];
int up[MAXN][MAXN],dn[MAXN][MAXN],lt[MAXN][MAXN],rt[MAXN][MAXN];
ll p2[MAXN*MAXN];
int tot;
inline void input(){
	n=fr(),m=fr();
	For(i,1,n) For(j,1,m) ar[i][j]=fc(),tot+=ar[i][j];
	p2[0]=1;For(i,1,n*m) p2[i]=p2[i-1]*2%MOD;
	For(i,1,n) For(j,1,m) if(ar[i][j-1]) lt[i][j]=lt[i][j-1]+1;else lt[i][j]=0;
	For(i,1,n) iFor(j,m,1) if(ar[i][j+1]) rt[i][j]=rt[i][j+1]+1;else rt[i][j]=0;
	For(i,1,n) For(j,1,m) if(ar[i-1][j]) up[i][j]=up[i-1][j]+1;else up[i][j]=0;
	iFor(i,n,1) For(j,1,m) if(ar[i+1][j]) dn[i][j]=dn[i+1][j]+1;else dn[i][j]=0;
}
signed main(){
//	File("temp")
	input();
	ll ans=0;
	For(i,1,n) For(j,1,m){
		if(!ar[i][j]) continue;
		ll t=lt[i][j]+rt[i][j]+up[i][j]+dn[i][j]+1;
		ans+=(p2[t]-1)*p2[tot-t]%MOD;
		ans%=MOD;
	}
	cout<<ans;
	return 0;
} 