from random import randint, seed
from collections import defaultdict
seed(47)

def get_root(boss, v):
    if v == boss[v]:
        return v
    else:
        tmp = get_root(boss, boss[v])
        boss[v] = tmp
        return tmp

def union(boss, u, v):
    ru, rv = get_root(boss, u), get_root(boss, v)
    if ru == rv: return
    if randint(0, 1): ru, rv = rv, ru
    boss[rv] = ru


R, C = [ int(_) for _ in input().split() ]
mapa = [ input() for r in range(R) ]
N = 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] != '.': N += 1
        segment[r][c] = N-1

boss = list(range(N))
T = 0
trieda = [ -1 for _ in range(N) ]
for r in reversed(range(R)):
    for c in range(C):
        if segment[r][c] != -1 and segment[r+1][c] != -1:
            union(boss, segment[r][c], segment[r+1][c] )
    nove_triedy = {}
    for c in range(C):
        if segment[r][c] != -1:
            sr = get_root(boss, segment[r][c])
            if sr not in nove_triedy:
                nove_triedy[sr], T = T, T+1
            trieda[ segment[r][c] ] = nove_triedy[sr]

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[ trieda[ segment[r][c] ] ].add( trieda[ 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)
