# your code goes here
n, m=map (int, input (). split ())
house=[]
place={}
rev_place={}
sz=0
for i in range (n) :
house.append(input ())
for j in range (m) :
if(house[i][j] ==".") :
place[sz]=i*m+j
rev_place[place[sz]]=sz
sz+=1
from fractions import gcd
matrix=[[0 for i in range (sz)] for i in range (sz)]
for x in range (sz):
order=place[x]
i=order//m
j=order%m
if(j>0 and house[i][j-1]=='.'):
matrix[x][x]-=1
matrix[x][rev_place[i*m+j-1]]=1
if(i>0 and house[i-1][j]=='.'):
matrix[x][x]-=1
matrix[x][rev_place[(i-1)*m+j]]=1
if(j<m-1 and house[i][j+1]=='.'):
matrix[x][x]-=1
matrix[x][rev_place[i*m+j+1]]=1
if(i<n-1 and house[i+1][j]=='.'):
matrix[x][x]-=1
matrix[x][rev_place[(i+1)*m+j]]=1
det=1
det_denom=1
row=0
col=0
while (row<sz-1 and col<sz) :
max_abs=abs(matrix[row][col])
next_row=row
for i in range (row+1,sz):
cur_abs=abs(matrix [i][col])
if(cur_abs>max_abs):
max_abs=cur_abs
next_row=i
if(max_abs==0):
col+=1
continue
for i in range (sz) :
matrix[row][i], matrix[next_row][i]=matrix[next_row][i], matrix[row][i]
for i in range (row+1,sz):
if(matrix[i] [col]!=0):
GCD=gcd(matrix [row] [col], matrix[i] [col] )
m1=matrix [i] [col]//GCD
m2=matrix[row] [col]//GCD
det_denom*=m1*m2
for j in range (col, sz) :
matrix[row][j]*=m1
matrix[i][j]*=m2
matrix[i][j]=abs(matrix[i] [j]) - abs(matrix[row][j])
row+=1
col+=1
main_d=[]
for i in range (sz):
cur=matrix[i] [i]
if(cur!=0):
main_d. append (cur)
if(len(main_d)==0):
det=0;
for i in main_d :
det*=i
M=10**9
det=(abs(det//det_denom))%M
if det==0 and sz==1:
det=1
print(det)
IyB5b3VyIGNvZGUgZ29lcyBoZXJlCm4sIG09bWFwIChpbnQsIGlucHV0ICgpLiBzcGxpdCAoKSkgCmhvdXNlPVtdCnBsYWNlPXt9CnJldl9wbGFjZT17fSAKc3o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AogICAgbmV4dF9yb3c9cm93CiAgICBmb3IgaSBpbiByYW5nZSAocm93KzEsc3opOgogICAgICAgIGN1cl9hYnM9YWJzKG1hdHJpeCBbaV1bY29sXSkgCiAgICAgICAgaWYoY3VyX2Ficz5tYXhfYWJzKToKICAgICAgICAgICAgbWF4X2Ficz1jdXJfYWJzCiAgICAgICAgICAgIG5leHRfcm93PWkKICAgIGlmKG1heF9hYnM9PTApOgogICAgICAgIGNvbCs9MQogICAgICAgIGNvbnRpbnVlCiAgICBmb3IgaSBpbiByYW5nZSAoc3opIDoKICAgICAgICBtYXRyaXhbcm93XVtpXSwgbWF0cml4W25leHRfcm93XVtpXT1tYXRyaXhbbmV4dF9yb3ddW2ldLCBtYXRyaXhbcm93XVtpXSAKICAgIGZvciBpIGluIHJhbmdlIChyb3crMSxzeik6CiAgICAgICAgaWYobWF0cml4W2ldIFtjb2xdIT0wKToKICAgICAgICAgICAgR0NEPWdjZChtYXRyaXggW3Jvd10gW2NvbF0sIG1hdHJpeFtpXSBbY29sXSApCiAgICAgICAgICAgIG0xPW1hdHJpeCBbaV0gW2NvbF0vL0dDRAogICAgICAgICAgICBtMj1tYXRyaXhbcm93XSBbY29sXS8vR0NECiAgICAgICAgICAgIGRldF9kZW5vbSo9bTEqbTIKICAgICAgICAgICAgZm9yIGogaW4gcmFuZ2UgKGNvbCwgc3opIDoKICAgICAgICAgICAgICAgIG1hdHJpeFtyb3ddW2pdKj1tMQogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdKj1tMgogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdPWFicyhtYXRyaXhbaV0gW2pdKSAtIGFicyhtYXRyaXhbcm93XVtqXSkgCiAgICByb3crPTEKICAgIGNvbCs9MQptYWluX2Q9W10gCmZvciBpIGluIHJhbmdlIChzeik6CiAgICBjdXI9bWF0cml4W2ldIFtpXSAKICAgIGlmKGN1ciE9MCk6CiAgICAgICAgbWFpbl9kLiBhcHBlbmQgKGN1cikgCmlmKGxlbihtYWluX2QpPT0wKToKICAgIGRldD0wOwpmb3IgaSBpbiBtYWluX2QgOgogICAgZGV0Kj1pCgpNPTEwKio5ICAgIApkZXQ9KGFicyhkZXQvL2RldF9kZW5vbSkpJU0KaWYgZGV0PT0wIGFuZCBzej09MToKICAgIGRldD0xCnByaW50KGRldCkg