The king demon is waiting in his dungeon to defeat a brave man. His dungeon consists of H \times W grids. Each cell is connected to four (i.e. north, south, east and west) neighboring cells and some cells are occupied by obstacles.

To attack the brave man, the king demon created and sent a servant that walks around in the dungeon. However, soon the king demon found that the servant does not work as he wants. The servant is too dumb. If the dungeon had cyclic path, it might keep walking along the cycle forever.

In order to make sure that the servant eventually find the brave man, the king demon decided to eliminate all cycles by building walls between cells. At the same time, he must be careful so that there is at least one path between any two cells not occupied by obstacles.

Your task is to write a program that computes in how many ways the kind demon can build walls.



Input

The first line of each test case has two integers H and W (1 \leq H \leq 500, 1 \leq W \leq 15), which are the height and the width of the dungeon. Following H lines consist of exactly W letters each of which is '.' (there is no obstacle on the cell) or '#' (there is an obstacle). You may assume that there is at least one cell that does not have an obstacle.

The input terminates when H = 0 and W = 0. Your program must not output for this case.

Output

For each test case, print its case number and the number of ways that walls can be built in one line. Since the answer can be very big, output in modulo 1,000,000,007.

Example

Input

2 2
..
..
3 3
...
...
..#
0 0


Output

Case 1: 4
Case 2: 56
#include<stdio.h>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
char str[600][20];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int num[600][20];
long long mod=1000000007;
long long pow(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
typedef map<int,long long> vec;
typedef vector<vec> mat;
long long det(mat A){
	int n=A.size();
	long long val=1;
	for(int i=0;i<n;i++){
		int at=-1;
		for(int j=i;j<n;j++){
			if(A[j].count(i)&&A[j][i]){
				at=j;break;
			}
		}
		if(!~at)return 0;
		if(at!=i){
			swap(A[at],A[i]);
			val=(mod-val);
		}
		val=val*A[i][i]%mod;
		long long t=pow(A[i][i],mod-2);
		for(map<int,long long>::iterator it=A[i].begin();it!=A[i].end();it++){
			A[i][(*it).first]=(*it).second*t%mod;
		}
		for(int j=i+1;j<n;j++){
			if(A[j].count(i)&&A[j][i]){
				long long div=mod-A[j][i];
				for(map<int,long long>::iterator it=A[i].begin();it!=A[i].end();it++){
					if((*it).second==0){continue;}
					if(!A[j].count((*it).first))A[j][(*it).first]=(*it).second*div%mod;
					else A[j][(*it).first]=(A[j][(*it).first]+(*it).second*div)%mod;
				}
			}
		}
	}
	for(int i=0;i<n;i++)val=val*A[i][i]%mod;
	return val;
}
int main(){
	int a,b;
	int T=0;
	while(scanf("%d%d",&a,&b),a){
		T++;
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		int at=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			num[i][j]=-1;
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]!='#')num[i][j]=at++;
		}
		mat A(at-1);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]!='#'){
				int deg=0;
				for(int k=0;k<4;k++){
					if(0<=i+dx[k]&&i+dx[k]<a&&0<=j+dy[k]&&j+dy[k]<b&&~num[i+dx[k]][j+dy[k]]){
						deg++;
						if(num[i][j]<at-1&&num[i+dx[k]][j+dy[k]]<at-1){
							A[num[i][j]][num[i+dx[k]][j+dy[k]]]=mod-1;
						}
					}
				}
				if(num[i][j]<at-1)A[num[i][j]][num[i][j]]=deg;
			}
		}
	//	for(int i=0;i<at-1;i++,printf("\n"))for(int j=0;j<at-1;j++)printf("%lld ",A[i][j]);
		printf("Case %d: %lld\n",T,det(A));
	}
}