# 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
size=sz-1
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):
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] )
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
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))
if(sz==0):
det=1
print(str(det) )
IyB5b3VyIGNvZGUgZ29lcyBoZXJlCm4sIG09bWFwIChpbnQsIGlucHV0ICgpLiBzcGxpdCAoKSkgCmhvdXNlPVtdCnBsYWNlPXt9CnJldl9wbGFjZT17fSAKc3o9MApmb3IgaSBpbiByYW5nZSAobikgOgogICAgaG91c2UuYXBwZW5kKGlucHV0ICgpKSAKICAgIGZvciBqIGluIHJhbmdlIChtKSA6CiAgICAgICAgaWYoaG91c2VbaV1bal0gPT0iLiIpIDoKICAgICAgICAgICAgcGxhY2Vbc3pdPWkqbStqCiAgICAgICAgICAgIHJldl9wbGFjZVtwbGFjZVtzel1dPXN6CiAgICAgICAgICAgIHN6Kz0xCmZyb20gZnJhY3Rpb25zIGltcG9ydCBnY2QKbWF0cml4PVtbMCBmb3IgaSBpbiByYW5nZSAoc3opXSBmb3IgaSBpbiByYW5nZSAoc3opXSAKZm9yIHggaW4gcmFuZ2UgKHN6KToKICAgIG9yZGVyPXBsYWNlW3hdIAogICAgaT1vcmRlci8vbQogICAgaj1vcmRlciVtCiAgICBpZihqPjAgYW5kIGhvdXNlW2ldW2otMV09PScuJyk6CiAgICAgICAgbWF0cml4W3hdW3hdLT0xCiAgICAgICAgbWF0cml4W3hdW3Jldl9wbGFjZVtpKm0rai0xXV09MQogICAgaWYoaT4wIGFuZCBob3VzZVtpLTFdW2pdPT0nLicpOgogICAgICAgIG1hdHJpeFt4XVt4XS09MQogICAgICAgIG1hdHJpeFt4XVtyZXZfcGxhY2VbKGktMSkqbStqXV09MQogICAgaWYoajxtLTEgYW5kIGhvdXNlW2ldW2orMV09PScuJyk6CiAgICAgICAgbWF0cml4W3hdW3hdLT0xCiAgICAgICAgbWF0cml4W3hdW3Jldl9wbGFjZVtpKm0raisxXV09MQogICAgaWYoaTxuLTEgYW5kIGhvdXNlW2krMV1bal09PScuJyk6CiAgICAgICAgbWF0cml4W3hdW3hdLT0xCiAgICAgICAgbWF0cml4W3hdW3Jldl9wbGFjZVsoaSsxKSptK2pdXT0xCiAKZGV0PTEKZGV0X2Rlbm9tPTEKcm93PTAKY29sPTAKc2l6ZT1zei0xCnN6LT0xCndoaWxlIChyb3c8c3ogYW5kIGNvbDxzei0xKSA6CiAgICBtYXhfYWJzPWFicyhtYXRyaXhbcm93XVtjb2xdKSAKICAgIG5leHRfcm93PXJvdwogICAgZm9yIGkgaW4gcmFuZ2UgKHJvdysxLHN6KToKICAgICAgICBjdXJfYWJzPWFicyhtYXRyaXggW2ldW2NvbF0pIAogICAgICAgIGlmKGN1cl9hYnM+bWF4X2Ficyk6CiAgICAgICAgICAgIG1heF9hYnM9Y3VyX2FicwogICAgICAgICAgICBuZXh0X3Jvdz1pCiAgICBpZihtYXhfYWJzPT0wKToKICAgICAgICBjb2wrPTEKICAgICAgICBjb250aW51ZQogICAgZm9yIGkgaW4gcmFuZ2UgKHN6KSA6CiAgICAgICAgbWF0cml4W3Jvd11baV0sIG1hdHJpeFtuZXh0X3Jvd11baV09bWF0cml4W25leHRfcm93XVtpXSwgbWF0cml4W3Jvd11baV0gCiAgICBmb3IgaSBpbiByYW5nZSAocm93KzEsc3opOgogICAgICAgIGlmKG1hdHJpeFtpXSBbY29sXSE9MCk6CiAgICAgICAgICAgIEdDRD1nY2QobWF0cml4IFtyb3ddIFtjb2xdLCBtYXRyaXhbaV0gW2NvbF0gKQogICAgICAgICAgICBMQ009bWF0cml4IFtyb3ddIFtjb2xdICptYXRyaXhbaV0gW2NvbF0gLy9HQ0QKICAgICAgICAgICAgbTE9TENNLy9tYXRyaXhbcm93XSBbY29sXSAKICAgICAgICAgICAgbTI9TENNLy9tYXRyaXhbaV0gW2NvbF0gCiAgICAgICAgICAgIGRldF9kZW5vbSo9bTEqbTIKICAgICAgICAgICAgZm9yIGogaW4gcmFuZ2UgKGNvbCwgc3opIDoKICAgICAgICAgICAgICAgIG1hdHJpeFtyb3ddW2pdKj1tMQogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdKj1tMgogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdLT1tYXRyaXhbcm93XVtqXSAKICAgIHJvdys9MQogICAgY29sKz0xCiAgICAKbWFpbl9kPVtdIApmb3IgaSBpbiByYW5nZSAoc3opOgogICAgY3VyPW1hdHJpeFtpXSBbaV0gCiAgICBpZihjdXIhPTApOgogICAgICAgIG1haW5fZC4gYXBwZW5kIChjdXIpIAppZihsZW4obWFpbl9kKT09MCk6CiAgICBkZXQ9MDsKZm9yIGkgaW4gbWFpbl9kIDoKICAgIGRldCo9aQpNPTEwKio5ICAgIApkZXQ9KGFicyhkZXQvL2RldF9kZW5vbSkpCmlmKHN6PT0wKToKICAgIGRldD0xCnByaW50KHN0cihkZXQpICkg