h, w = list(map(int, input().split()))

grid = [str(eval(input())) for _ in range(h)]

dp = [[0] * 1050 for _ in range(1050)]

MOD = int(1e9+7)

dp[0][0] = 1

for i in range(h):

    for j in range(w):

        if i + 1 < h and grid[i+1][j] == '.':

            dp[i+1][j] += dp[i][j]

        if j + 1 < w and grid[i][j+1] == '.':

            dp[i][j+1] += dp[i][j]

        dp[i][j] %= MOD

print((dp[h-1][w-1]))
h, w = list(map(int, input().split()))

grid = [str(eval(input())) for _ in range(h)]

dp = [[0] * 1050 for _ in range(1050)]

MOD = int(1e9+7)

dp[0][0] = 1

for i in range(h):

    for j in range(w):

        dp[i][j] %= MOD

        if i + 1 < h and grid[i+1][j] == '.':

            dp[i+1][j] += dp[i][j]

        if j + 1 < w and grid[i][j+1] == '.':

            dp[i][j+1] += dp[i][j]

print((dp[h-1][w-1]))
h, w = list(map(int, input().split()))
grid = [str(eval(input())) for _ in range(h)]
dp = [[0] * 1050 for _ in range(1050)]
MOD = int(1e9 + 7)
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if i + 1 < h and grid[i + 1][j] == ".":
            dp[i + 1][j] += dp[i][j]
        if j + 1 < w and grid[i][j + 1] == ".":
            dp[i][j + 1] += dp[i][j]
        dp[i][j] %= MOD
print((dp[h - 1][w - 1]))

h, w = list(map(int, input().split()))
grid = [str(eval(input())) for _ in range(h)]
dp = [[0] * 1050 for _ in range(1050)]
MOD = int(1e9 + 7)
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        dp[i][j] %= MOD
        if i + 1 < h and grid[i + 1][j] == ".":
            dp[i + 1][j] += dp[i][j]
        if j + 1 < w and grid[i][j + 1] == ".":
            dp[i][j + 1] += dp[i][j]
print((dp[h - 1][w - 1]))

+        dp[i][j] %= MOD -        dp[i][j] %= MOD