#It took pretty long time...
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
sz-=1
while (row<sz and col<sz-1) :
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):
det=0
break
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] )
LCM=matrix [row] [col] *matrix[i] [col] //GCD
m1=LCM//matrix[row] [col]
m2=LCM//matrix[i] [col]
det_denom*=m1*m2
for j in range (col, sz) :
matrix[row][j]*=m1
matrix[i][j]*=m2
matrix[i][j]-=matrix[row][j]
row+=1
col+=1
for i in range (sz):
det*=matrix[i][i]
M=10**9
det=(abs(det//det_denom))%M
if(sz==0):
det=1
print(str(det) )
I0l0IHRvb2sgcHJldHR5IGxvbmcgdGltZS4uLiAKbiwgbT1tYXAgKGludCwgaW5wdXQgKCkuIHNwbGl0ICgpKSAKaG91c2U9W10KcGxhY2U9e30KcmV2X3BsYWNlPXt9IApzej0wCmZvciBpIGluIHJhbmdlIChuKSA6CiAgICBob3VzZS5hcHBlbmQoaW5wdXQgKCkpIAogICAgZm9yIGogaW4gcmFuZ2UgKG0pIDoKICAgICAgICBpZihob3VzZVtpXVtqXSA9PSIuIikgOgogICAgICAgICAgICBwbGFjZVtzel09aSptK2oKICAgICAgICAgICAgcmV2X3BsYWNlW3BsYWNlW3N6XV09c3oKICAgICAgICAgICAgc3orPTEKZnJvbSBmcmFjdGlvbnMgaW1wb3J0IGdjZAptYXRyaXg9W1swIGZvciBpIGluIHJhbmdlIChzeildIGZvciBpIGluIHJhbmdlIChzeildIApmb3IgeCBpbiByYW5nZSAoc3opOgogICAgb3JkZXI9cGxhY2VbeF0gCiAgICBpPW9yZGVyLy9tCiAgICBqPW9yZGVyJW0KICAgIGlmKGo+MCBhbmQgaG91c2VbaV1bai0xXT09Jy4nKToKICAgICAgICBtYXRyaXhbeF1beF0tPTEKICAgICAgICBtYXRyaXhbeF1bcmV2X3BsYWNlW2kqbStqLTFdXT0xCiAgICBpZihpPjAgYW5kIGhvdXNlW2ktMV1bal09PScuJyk6CiAgICAgICAgbWF0cml4W3hdW3hdLT0xCiAgICAgICAgbWF0cml4W3hdW3Jldl9wbGFjZVsoaS0xKSptK2pdXT0xCiAgICBpZihqPG0tMSBhbmQgaG91c2VbaV1baisxXT09Jy4nKToKICAgICAgICBtYXRyaXhbeF1beF0tPTEKICAgICAgICBtYXRyaXhbeF1bcmV2X3BsYWNlW2kqbStqKzFdXT0xCiAgICBpZihpPG4tMSBhbmQgaG91c2VbaSsxXVtqXT09Jy4nKToKICAgICAgICBtYXRyaXhbeF1beF0tPTEKICAgICAgICBtYXRyaXhbeF1bcmV2X3BsYWNlWyhpKzEpKm0ral1dPTEKIApkZXQ9MQpkZXRfZGVub209MQpyb3c9MApjb2w9MApzei09MQp3aGlsZSAocm93PHN6IGFuZCBjb2w8c3otMSkgOgogICAgbWF4X2Ficz1hYnMobWF0cml4W3Jvd11bY29sXSkgCiAgICBuZXh0X3Jvdz1yb3cKICAgIGZvciBpIGluIHJhbmdlIChyb3crMSxzeik6CiAgICAgICAgY3VyX2Ficz1hYnMobWF0cml4IFtpXVtjb2xdKSAKICAgICAgICBpZihjdXJfYWJzPm1heF9hYnMpOgogICAgICAgICAgICBtYXhfYWJzPWN1cl9hYnMKICAgICAgICAgICAgbmV4dF9yb3c9aQogICAgaWYobWF4X2Ficz09MCk6CiAgICAgICAgZGV0PTAKICAgICAgICBicmVhawogICAgZm9yIGkgaW4gcmFuZ2UgKHN6KSA6CiAgICAgICAgbWF0cml4W3Jvd11baV0sIG1hdHJpeFtuZXh0X3Jvd11baV09bWF0cml4W25leHRfcm93XVtpXSwgbWF0cml4W3Jvd11baV0gCiAgICBmb3IgaSBpbiByYW5nZSAocm93KzEsc3opOgogICAgICAgIGlmKG1hdHJpeFtpXSBbY29sXSE9MCk6CiAgICAgICAgICAgIEdDRD1nY2QobWF0cml4IFtyb3ddIFtjb2xdLCBtYXRyaXhbaV0gW2NvbF0gKQogICAgICAgICAgICBMQ009bWF0cml4IFtyb3ddIFtjb2xdICptYXRyaXhbaV0gW2NvbF0gLy9HQ0QKICAgICAgICAgICAgbTE9TENNLy9tYXRyaXhbcm93XSBbY29sXSAKICAgICAgICAgICAgbTI9TENNLy9tYXRyaXhbaV0gW2NvbF0gCiAgICAgICAgICAgIGRldF9kZW5vbSo9bTEqbTIKICAgICAgICAgICAgZm9yIGogaW4gcmFuZ2UgKGNvbCwgc3opIDoKICAgICAgICAgICAgICAgIG1hdHJpeFtyb3ddW2pdKj1tMQogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdKj1tMgogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdLT1tYXRyaXhbcm93XVtqXSAKICAgIHJvdys9MQogICAgY29sKz0xCiAgICAKZm9yIGkgaW4gcmFuZ2UgKHN6KToKICAgIGRldCo9bWF0cml4W2ldW2ldIApNPTEwKio5ICAgIApkZXQ9KGFicyhkZXQvL2RldF9kZW5vbSkpJU0KaWYoc3o9PTApOgogICAgZGV0PTEKcHJpbnQoc3RyKGRldCkgKSA=