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

ans = [[0 for i in range(W)] for j in range(H)]

mark = []

for i in range(H):

    mark.append(eval(input()))



ans[0][0] = 1

mod = 10**9 + 7

for i in range(H):

    for j in range(W):

        if mark[i][j] == '#':

            continue

        if i > 0:

            ans[i][j] += ans[i-1][j]

        if j > 0:

            ans[i][j] += ans[i][j-1]

        ans[i][j] %= mod



print((ans[H-1][W-1]))
H, W = list(map(int, input().split()))

mark = []

for i in range(H):

    mark.append(eval(input()))



dp = [[0 for i in range(W)] for j in range(H)]

dp[0][0] = 1

mod = int(1e9) + 7

for i in range(H):

    for j in range(W):

        if i > 0 and mark[i - 1][j] == '.':

            dp[i][j] += dp[i - 1][j] % mod

        if j > 0 and mark[i][j - 1] == '.':

            dp[i][j] += dp[i][j - 1] % mod

        dp[i][j] %= mod



print((dp[H - 1][W - 1]))
H, W = list(map(int, input().split()))
ans = [[0 for i in range(W)] for j in range(H)]
mark = []
for i in range(H):
    mark.append(eval(input()))
ans[0][0] = 1
mod = 10**9 + 7
for i in range(H):
    for j in range(W):
        if mark[i][j] == "#":
            continue
        if i > 0:
            ans[i][j] += ans[i - 1][j]
        if j > 0:
            ans[i][j] += ans[i][j - 1]
        ans[i][j] %= mod
print((ans[H - 1][W - 1]))

H, W = list(map(int, input().split()))
mark = []
for i in range(H):
    mark.append(eval(input()))
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
mod = int(1e9) + 7
for i in range(H):
    for j in range(W):
        if i > 0 and mark[i - 1][j] == ".":
            dp[i][j] += dp[i - 1][j] % mod
        if j > 0 and mark[i][j - 1] == ".":
            dp[i][j] += dp[i][j - 1] % mod
        dp[i][j] %= mod
print((dp[H - 1][W - 1]))

-ans = [[0 for i in range(W)] for j in range(H)] -ans[0][0] = 1 -mod = 10**9 + 7 +dp = [[0 for i in range(W)] for j in range(H)] +dp[0][0] = 1 +mod = int(1e9) + 7 -        if mark[i][j] == "#": -            continue -        if i > 0: -            ans[i][j] += ans[i - 1][j] -        if j > 0: -            ans[i][j] += ans[i][j - 1] -        ans[i][j] %= mod -print((ans[H - 1][W - 1])) +        if i > 0 and mark[i - 1][j] == ".": +            dp[i][j] += dp[i - 1][j] % mod +        if j > 0 and mark[i][j - 1] == ".": +            dp[i][j] += dp[i][j - 1] % mod +        dp[i][j] %= mod +print((dp[H - 1][W - 1]))