# ma vyriesit sady 1, 2, 3, 4
from collections import defaultdict

R, C = [ int(_) for _ in input().split() ]
mapa = [ input() for r in range(R) ]
T = 0
segment = [ [ -1 for c in range(C) ] for r in range(R) ]
for r in reversed(range(R)):
    for c in range(C):
        if mapa[r][c] != '.': continue
        if mapa[r][c-1] != '.': T += 1
        segment[r][c] = T-1

deti = [ set() for _ in range(T) ]
for r in reversed(range(R)):
    for c in range(C):
        if segment[r][c] != -1 and segment[r+1][c] != -1:
            deti[ segment[r][c] ].add( segment[r+1][c] )

MOD = 10**9 + 7
odpovede = [ 1 for _ in range(T) ]
for t in range(T):
    for d in deti[t]:
        odpovede[t] = (odpovede[t] * odpovede[d]) % MOD
    odpovede[t] = (odpovede[t] + 1) % MOD

top = [ True for _ in range(T) ]
for t in range(T):
    for d in deti[t]:
        top[d] = False

spolu = 1
for t in range(T):
    if top[t]:
        spolu = (spolu * odpovede[t]) % MOD

print(spolu)
