# 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
if(n==1 and m==1):
if(house[0][0]=='.'):
print (1)
else:
print (0)
from sys import exit
exit()
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 (m) :
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
print(det)
IyB5b3VyIGNvZGUgZ29lcyBoZXJlCm4sIG09bWFwIChpbnQsIGlucHV0ICgpLiBzcGxpdCAoKSkgCmhvdXNlPVtdCnBsYWNlPXt9CnJldl9wbGFjZT17fSAKc3o9MApmb3IgaSBpbiByYW5nZSAobikgOgogICAgaG91c2UuYXBwZW5kKGlucHV0ICgpKSAKICAgIGZvciBqIGluIHJhbmdlIChtKSA6CiAgICAgICAgaWYoaG91c2VbaV1bal0gPT0iLiIpIDoKICAgICAgICAgICAgcGxhY2Vbc3pdPWkqbStqCiAgICAgICAgICAgIHJldl9wbGFjZVtwbGFjZVtzel1dPXN6CiAgICAgICAgICAgIHN6Kz0xCmlmKG49PTEgYW5kIG09PTEpOgogICAgaWYoaG91c2VbMF1bMF09PScuJyk6CiAgICAgICAgcHJpbnQgKDEpCiAgICBlbHNlOgogICAgICAgIHByaW50ICgwKQogICAgZnJvbSBzeXMgaW1wb3J0IGV4aXQgCiAgICBleGl0KCkgICAgICAKZnJvbSBmcmFjdGlvbnMgaW1wb3J0IGdjZAptYXRyaXg9W1swIGZvciBpIGluIHJhbmdlIChzeildIGZvciBpIGluIHJhbmdlIChzeildIApmb3IgeCBpbiByYW5nZSAoc3opOgogICAgb3JkZXI9cGxhY2VbeF0gCiAgICBpPW9yZGVyLy9tCiAgICBqPW9yZGVyJW0KICAgIGlmKGo+MCBhbmQgaG91c2VbaV1bai0xXT09Jy4nKToKICAgICAgICBtYXRyaXhbeF1beF0tPTEKICAgICAgICBtYXRyaXhbeF1bcmV2X3BsYWNlW2kqbStqLTFdXT0xCiAgICBpZihpPjAgYW5kIGhvdXNlW2ktMV1bal09PScuJyk6CiAgICAgICAgbWF0cml4W3hdW3hdLT0xCiAgICAgICAgbWF0cml4W3hdW3Jldl9wbGFjZVsoaS0xKSptK2pdXT0xCiAgICBpZihqPG0tMSBhbmQgaG91c2VbaV1baisxXT09Jy4nKToKICAgICAgICBtYXRyaXhbeF1beF0tPTEKICAgICAgICBtYXRyaXhbeF1bcmV2X3BsYWNlW2kqbStqKzFdXT0xCiAgICBpZihpPG4tMSBhbmQgaG91c2VbaSsxXVtqXT09Jy4nKToKICAgICAgICBtYXRyaXhbeF1beF0tPTEKICAgICAgICBtYXRyaXhbeF1bcmV2X3BsYWNlWyhpKzEpKm0ral1dPTEKCgpkZXQ9MQpkZXRfZGVub209MQpyb3c9MApjb2w9MAp3aGlsZSAocm93PHN6LTEgYW5kIGNvbDxzeikgOgogICAgbWF4X2Ficz1hYnMobWF0cml4W3Jvd11bY29sXSkgCiAgICBuZXh0X3Jvdz1yb3cKICAgIGZvciBpIGluIHJhbmdlIChyb3crMSxzeik6CiAgICAgICAgY3VyX2Ficz1hYnMobWF0cml4IFtpXVtjb2xdKSAKICAgICAgICBpZihjdXJfYWJzPm1heF9hYnMpOgogICAgICAgICAgICBtYXhfYWJzPWN1cl9hYnMKICAgICAgICAgICAgbmV4dF9yb3c9aQogICAgaWYobWF4X2Ficz09MCk6CiAgICAgICAgY29sKz0xCiAgICAgICAgY29udGludWUKICAgIGZvciBpIGluIHJhbmdlIChtKSA6CiAgICAgICAgbWF0cml4W3Jvd10gW2ldLCBtYXRyaXhbbmV4dF9yb3ddIFtpXSA9bWF0cml4W25leHRfcm93XSBbaV0sIG1hdHJpeFtyb3ddIFtpXSAKICAgIGZvciBpIGluIHJhbmdlIChyb3crMSxzeik6CiAgICAgICAgaWYobWF0cml4W2ldIFtjb2xdIT0wKToKICAgICAgICAgICAgR0NEPWdjZChtYXRyaXggW3Jvd10gW2NvbF0sIG1hdHJpeFtpXSBbY29sXSApCiAgICAgICAgICAgIG0xPW1hdHJpeCBbaV0gW2NvbF0vL0dDRAogICAgICAgICAgICBtMj1tYXRyaXhbcm93XSBbY29sXS8vR0NECiAgICAgICAgICAgIGRldF9kZW5vbSo9bTEqbTIKICAgICAgICAgICAgZm9yIGogaW4gcmFuZ2UgKGNvbCwgc3opIDoKICAgICAgICAgICAgICAgIG1hdHJpeFtyb3ddW2pdKj1tMQogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdKj1tMgogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdPWFicyhtYXRyaXhbaV0gW2pdKSAtIGFicyhtYXRyaXhbcm93XVtqXSkgCiAgICByb3crPTEKICAgIGNvbCs9MQptYWluX2Q9W10gCmZvciBpIGluIHJhbmdlIChzeik6CiAgICBjdXI9bWF0cml4W2ldIFtpXSAKICAgIGlmKGN1ciE9MCk6CiAgICAgICAgbWFpbl9kLiBhcHBlbmQgKGN1cikgCmlmKGxlbihtYWluX2QpPT0wKToKICAgIGRldD0wOwpmb3IgaSBpbiBtYWluX2QgOgogICAgZGV0Kj1pCgpNPTEwKio5ICAgIApkZXQ9KGFicyhkZXQvL2RldF9kZW5vbSkpJU0KcHJpbnQoZGV0KSA=