import sys

sys.setrecursionlimit(10**9)



H, W = list(map(int, input().split()))

field = [list(eval(input())) for _ in range(H)]

MOD = 10 ** 9 + 7

count = [0]

dp = [[-1] * W for _ in range(H)]



def dfs(x, y):

  if x == W-1 and y == H-1:

    return 1

  ret = 0

  for nx, ny in ((1,0), (0,1)):

    nx += x

    ny += y

    if nx >= W or ny >= H:

      continue

    if dp[ny][nx] > -1:

      ret += dp[ny][nx]

    elif field[ny][nx] == ".":

      ret += dfs(nx, ny)

  dp[y][x] = ret % MOD

  return ret



dfs(0,0)

print((dp[0][0]))

H, W = list(map(int, input().split()))

#field = [list(input()) for _ in range(H)]

field = []

for _ in range(H):

    tmp = list(eval(input()))

    tmp.append("#")

    field.append(tmp)

field.append(["#"] * (W))

dp = [[0] * (W+1) for _ in range(H+1)]

dp[0][0] = 1

mod = 10 ** 9 + 7

for h in range(H):

    for w in range(W):

        if field[h][w] == "#":

            continue

        # 配り先のマスを見て、回数を増やせるか判定

        if field[h+1][w] == ".":

            dp[h+1][w] += dp[h][w]

            dp[h+1][w] %= mod

        if field[h][w+1] == ".":

            dp[h][w+1] += dp[h][w]

            dp[h][w+1] %= mod



print((dp[H-1][W-1]))

        

import sys

sys.setrecursionlimit(10**9)
H, W = list(map(int, input().split()))
field = [list(eval(input())) for _ in range(H)]
MOD = 10**9 + 7
count = [0]
dp = [[-1] * W for _ in range(H)]


def dfs(x, y):
    if x == W - 1 and y == H - 1:
        return 1
    ret = 0
    for nx, ny in ((1, 0), (0, 1)):
        nx += x
        ny += y
        if nx >= W or ny >= H:
            continue
        if dp[ny][nx] > -1:
            ret += dp[ny][nx]
        elif field[ny][nx] == ".":
            ret += dfs(nx, ny)
    dp[y][x] = ret % MOD
    return ret


dfs(0, 0)
print((dp[0][0]))

H, W = list(map(int, input().split()))
# field = [list(input()) for _ in range(H)]
field = []
for _ in range(H):
    tmp = list(eval(input()))
    tmp.append("#")
    field.append(tmp)
field.append(["#"] * (W))
dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[0][0] = 1
mod = 10**9 + 7
for h in range(H):
    for w in range(W):
        if field[h][w] == "#":
            continue
        # 配り先のマスを見て、回数を増やせるか判定
        if field[h + 1][w] == ".":
            dp[h + 1][w] += dp[h][w]
            dp[h + 1][w] %= mod
        if field[h][w + 1] == ".":
            dp[h][w + 1] += dp[h][w]
            dp[h][w + 1] %= mod
print((dp[H - 1][W - 1]))

-import sys - -sys.setrecursionlimit(10**9) -field = [list(eval(input())) for _ in range(H)] -MOD = 10**9 + 7 -count = [0] -dp = [[-1] * W for _ in range(H)] - - -def dfs(x, y): -    if x == W - 1 and y == H - 1: -        return 1 -    ret = 0 -    for nx, ny in ((1, 0), (0, 1)): -        nx += x -        ny += y -        if nx >= W or ny >= H: +# field = [list(input()) for _ in range(H)] +field = [] +for _ in range(H): +    tmp = list(eval(input())) +    tmp.append("#") +    field.append(tmp) +field.append(["#"] * (W)) +dp = [[0] * (W + 1) for _ in range(H + 1)] +dp[0][0] = 1 +mod = 10**9 + 7 +for h in range(H): +    for w in range(W): +        if field[h][w] == "#": -        if dp[ny][nx] > -1: -            ret += dp[ny][nx] -        elif field[ny][nx] == ".": -            ret += dfs(nx, ny) -    dp[y][x] = ret % MOD -    return ret - - -dfs(0, 0) -print((dp[0][0])) +        # 配り先のマスを見て、回数を増やせるか判定 +        if field[h + 1][w] == ".": +            dp[h + 1][w] += dp[h][w] +            dp[h + 1][w] %= mod +        if field[h][w + 1] == ".": +            dp[h][w + 1] += dp[h][w] +            dp[h][w + 1] %= mod +print((dp[H - 1][W - 1]))