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 <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 500 + 5;
const int M = 20;
const int V = 500 * 15 + 5;
const int MOD = (int)1e9 + 7;

struct Matrix
{
	long long a[V][M * 3];
	long long& getEntry(int x, int y) {
		return a[x][y - x + M];
	}
	bool haveEntry(int x, int y) {
		return 0 <= y - x + M && y - x + M < M * 3;
	}
	void clear() {
		memset(a, 0, sizeof a);
	}
} a;

int n, m;
char c[N][M];
int id[N][M];

#define getId(x,y) (id[x][y])

long long modPow(long long a, long long p, long long MOD)
{
	long long ret = 1;
	for( ; p; p >>= 1, a = a * a % MOD) {
		if (p & 1) {
			ret = ret * a % MOD;
		}
	}
	return ret;
}


void solve()
{
	a.clear();
	int v = 0;
	for(int i = 0; i < n; ++ i) {
		scanf("%s", c[i]);
		for(int j = 0; j < m; ++ j) {
			if (c[i][j] == '.') {
				id[i][j] = v ++;
			}
		}
	}
	for(int i = 0; i < n; ++ i) {
		for(int j = 0; j < m; ++ j) {
			if (c[i][j] == '.') {
				if (i + 1 < n && c[i + 1][j] == '.') {
					a.getEntry(getId(i, j), getId(i, j)) ++;
					a.getEntry(getId(i + 1, j), getId(i + 1, j)) ++;
					a.getEntry(getId(i, j), getId(i + 1, j)) --;
					a.getEntry(getId(i + 1, j), getId(i, j)) --;
				}
				if (j + 1 < m && c[i][j + 1] == '.') {
					a.getEntry(getId(i, j), getId(i, j)) ++;
					a.getEntry(getId(i, j + 1), getId(i, j + 1)) ++;
					a.getEntry(getId(i, j), getId(i, j + 1)) --;
					a.getEntry(getId(i, j + 1), getId(i, j)) --;
				}
			}
		}
	}
	--v;
	long long ret = 1;
	for(int col = 0; col < v; ++ col) {
		if (a.getEntry(col, col) == 0) {
			for(int i = col + 1; a.haveEntry(i, col) && i < v; ++ i) {
				if (a.getEntry(i, col)) {
					for(int j = col; a.haveEntry(col, j) && a.haveEntry(i, j) && j < v; ++ j) {
						swap(a.getEntry(col, j), a.getEntry(i, j));
					}
					ret = -ret;
					break;
				}
			}
		}
		if (a.getEntry(col, col)) {
			ret = ret * a.getEntry(col, col) % MOD;
			long long inv = modPow(a.getEntry(col, col), MOD - 2, MOD);
			for(int i = col + 1; a.haveEntry(i, col) && i < v; ++ i) {
				if (a.getEntry(i, col)) {
					long long by = -a.getEntry(i, col) * inv % MOD;
					for(int j = col; a.haveEntry(col, j) && a.haveEntry(i, j) && j < v; ++ j) {
						(a.getEntry(i, j) += a.getEntry(col, j) * by) %= MOD;
					}
				}
			}
		} else {
			ret = 0;
			break;
		}
	}
	cout << (ret + MOD) % MOD << endl;
}

int main()
{
	int t = 0;
	for( ; scanf("%d%d", &n, &m) == 2 && (n || m); ) {
		printf("Case %d: ", ++ t);
		solve();
	}
	return 0;
}