# ma vyriesit sady 1, 2, 5, 6
from queue import Queue

R, C = [ int(_) for _ in input().split() ]
mapa = [ input() for r in range(R) ]
komponenty = [ ]
F = 0
farby = [ [ -1 for c in range(C) ] for r in range(R) ]

for sr in range(R):
    for sc in range(C):
        if mapa[sr][sc] == '.' and farby[sr][sc] == -1:
            komponenty.append( [] )
            komponenty[-1].append( (sr, sc) )
            farby[sr][sc] = F
            Q = Queue()
            Q.put( (sr, sc) )
            while not Q.empty():
                cr, cc = Q.get()
                for nr, nc in [ (cr-1, cc), (cr+1, cc), (cr, cc-1), (cr, cc+1) ]:
                    if mapa[nr][nc] != '.': continue
                    if farby[nr][nc] != -1: continue
                    farby[nr][nc] = F
                    komponenty[-1].append( (nr, nc) )
                    Q.put( (nr, nc) )
            F += 1

MOD = 10**9 + 7
odpoved = 1
for K in komponenty:
    rows = max( sr for sr, sc in K ) - min( sr for sr, sc in K ) + 1
    odpoved = (odpoved * (rows+1)) % MOD

print(odpoved)
